GameDev.net Posting Guidelines (please read before posting)
Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 28 June 2012 - 12:35 PM
Posted 28 June 2012 - 06:34 PM
. . . . . . . 5 12 19 26 33 40 47 4 11 18 25 32 39 46 3 10 17 24 31 38 45 2 9 16 23 30 37 44 1 8 15 22 29 36 43 0 7 14 21 28 35 42
u64 generate_moves() { u64 occupied = pieces[0] | pieces[1]; return BOARD_MASK & (occupied >> 1) & ~occupied; }
for (u64 moves = generate_moves(); moves; moves &= moves-1) { u64 move = moves & -moves; // `move' now has a bitboard with a single 1 in the position where you can move. // You can use the De Bruijn sequence trick if you want to convert it to an index. }
Edited by alvaro, 28 June 2012 - 07:55 PM.
Posted 29 June 2012 - 11:58 PM
Edited by ashish123, 30 June 2012 - 02:56 AM.
Posted 30 June 2012 - 05:08 AM
Posted 01 July 2012 - 10:59 AM
Just compute `empties & shift_north(occupied)'. Then extract all the bits that are set, using a loop like the one I showed you.
Posted 01 July 2012 - 03:06 PM
Just compute `empties & shift_north(occupied)'. Then extract all the bits that are set, using a loop like the one I showed you.
On an empty board, occupied will be 0, so according to the pseudo-code, only available move is 0.
am I missing something? I adopted the Fhourstones structure for a while.
Posted 07 September 2012 - 10:13 AM
long occupied = (xBits | yBits); long empty = ~occupied; long bitMoves = 0L; bitMoves = bitBoard & empty & ((occupied >> 9) | lastrow); //Find the forced moves long xThreats = 0L; long yThreats = 0L; yThreats |= ((yBits << 1) & (yBits << 2) & (yBits << 3) & empty & bitBoard);//XXX_ yThreats |= ((yBits >> 2) & (yBits << 1) & (yBits >> 1) & empty & bitBoard);//X_XX yThreats |= ((yBits << 2) & (yBits << 1) & (yBits >> 1) & empty & bitBoard);//XX_X yThreats |= ((yBits >> 1) & (yBits >> 2) & (yBits >> 3) & empty & bitBoard);//_XXX yThreats |= ((yBits << 10) & (yBits << 20) & (yBits << 30) & empty & bitBoard);//XXX_ yThreats |= ((yBits >> 20) & (yBits << 10) & (yBits >> 10) & empty & bitBoard);//X_XX yThreats |= ((yBits << 20) & (yBits << 10) & (yBits >> 10) & empty & bitBoard);//XX_X yThreats |= ((yBits >> 10) & (yBits >> 20) & (yBits >> 30) & empty & bitBoard);//_XXX yThreats |= ((yBits << 8) & (yBits << 16) & (yBits << 24) & empty & bitBoard);//XXX_ yThreats |= ((yBits >> 16) & (yBits << 8) & (yBits >> 8) & empty & bitBoard);//X_XX yThreats |= ((yBits << 16) & (yBits << 8) & (yBits >> 8) & empty & bitBoard);//XX_X yThreats |= ((yBits >> 8) & (yBits >> 16) & (yBits >> 24) & empty & bitBoard);//_XXX xThreats |= ((xBits << 1) & (xBits << 2) & (xBits << 3) & empty & bitBoard);//XXX_ xThreats |= ((xBits >> 2) & (xBits << 1) & (xBits >> 1) & empty & bitBoard);//X_XX xThreats |= ((xBits << 2) & (xBits << 1) & (xBits >> 1) & empty & bitBoard);//XX_X xThreats |= ((xBits >> 1) & (xBits >> 2) & (xBits >> 3) & empty & bitBoard);//_XXX xThreats |= ((xBits << 10) & (xBits << 20) & (xBits << 30) & empty & bitBoard);//XXX_ xThreats |= ((xBits >> 20) & (xBits << 10) & (xBits >> 10) & empty & bitBoard);//X_XX xThreats |= ((xBits << 20) & (xBits << 10) & (xBits >> 10) & empty & bitBoard);//XX_X xThreats |= ((xBits >> 10) & (xBits >> 20) & (xBits >> 30) & empty & bitBoard);//XXX_ xThreats |= ((xBits << 8) & (xBits << 16) & (xBits << 24) & empty & bitBoard);//XXX_ xThreats |= ((xBits >> 16) & (xBits << 8) & (xBits >> 8) & empty & bitBoard);//X_XX xThreats |= ((xBits << 16) & (xBits << 8) & (xBits >> 8) & empty & bitBoard);//XX_X xThreats |= ((xBits >> 8) & (xBits >> 16) & (xBits >> 24) & empty & bitBoard);//_XXX if((((yThreats|xThreats)&bitMoves)!=0)) { bitMoves = bitMoves&(yThreats|xThreats);// play on the threatend empty square only. }
Edited by ashish123, 07 September 2012 - 10:19 AM.
Posted 07 September 2012 - 10:31 AM
long bitMoves = 0L; bitMoves = bitBoard & empty & ((occupied >> 9) | lastrow);
long bitMoves = bitBoard & empty & ((occupied >> 9) | lastrow);
Posted 08 September 2012 - 03:12 AM
Posted 09 September 2012 - 06:33 AM
Posted 22 September 2012 - 10:52 AM
Posted 22 September 2012 - 01:28 PM
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ X 1 Y Z _ _ _ 1 2 1 _ _ _ _ 2 1 2 _ _It is 2's turn to move, and if it plays at X, player 1 can play at Y, which leads to a straight-forward victory (fill up the rightmost column, stay out of trouble elsewhere and win at Z). Unless you incorporate some knowledge in your program, it will have to search to depth 30 or so before it realizes it. Because I have some knowledge of the game, I can see it with essentially no search.
Edited by alvaro, 22 September 2012 - 01:29 PM.
Posted 23 September 2012 - 06:11 AM
Posted 23 September 2012 - 08:30 AM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.