OK I have read a lot of things on the web most of them using Java that doesn't have unsigned int. I am working on Objective-C that has unsigned int.
Lets consider the following scenario.
The board is like this:
A1 is on the lower left and is the least significant bit and
H8 is on the top right and is the most significant bit.
I have constructed the bitmasks for the movements of all pieces for all positions on the board.
Suppose the following simple situation:
- the game will start. All pieces are on their initial positions.
- the user tries to move the knight on
Obviously this movement is impossible because there is a pawn on
How do I discover if a movement is valid?
Ok I have the bitmask of all pieces that is this:
and I have the bitmask of the possible movements for the knight at
G1 that is
00000000 00000000 00000000 00000000 00000000 00000X0X 0000X000 00000000
or in bits
AND these two
all I know is that there is a piece at that point but I am not seeing how this tells me if that is a valid move or not.
Another question is this: suppose this move would let my king under attack. Obviously the move would be technically possible under the knight rules of movement but impossible because I cannot do a move that puts my king under attack.
How do I get these informations? Thanks