Jump to content
  • Advertisement
Sign in to follow this  


This topic is 5410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Imagine we have a bitboard of all white pieces, one of all black pieces, and one of all white pawns. How do we generate all possible white pawn moves? In conventional notation, we cycle through the board, pick out each pawn, and then evaluate the moves directly. In bitboard notation we can do much better. Firstly we take the pawn bitboard and shift it right 8 bits. Right-shift does just what it says, moving the bits 8 places to the right, and filling the 8 most significant bits on the left with zeros. Effectively, this is the same as a divide by 2^8, or 256. What this gives us is a list of all the places on the board that are exactly one square in front of a white pawn. Next we need to make sure that we don't push a pawn into another piece. To do this we simply take an AND of this shifted board with another board consisting of all the empty squares on the board. Either this is stored separately, or it is simply equal to ~(WHITEPIECES | BLACKPIECES), where the tilde sign represents bitwise NOT, and the | sign represents bitwise OR. We can simply add in all initial 2 square pushes by taking all pawns on Rank 2 (a2-h2), and then shifting them right 16 (two full ranks), and then checking that both the target square and the intermediate 'step-over' square are empty. The command (WHITEPAWNS & (255<<48)) gives us all of white's unmoved pawns. '<<' means 'shift left', 255 is a full row of 8 1's, and thus 255 << 48 gives us a row of 1's between a2 and h2. We can now get the legal moves by taking the AND of these pawns with ~(ALLPIECES << 8) and also ~(ALLPIECES << 16). The final target squares are the result of this final board >> 16.
This is from a website(beowolf). My question is: how do I know where each individual pawn can move too? Also, how much does not using a 64 bit processor instead of a 32 bit processor hurt performance? Also, even if I have a 64 bit processor(AMD), if I don't have a 64 bit OS, will this hurt too?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!