I'm not writing the complicated part yet, but I've hit a snag. I'm working through my move generation code, and right now I'm looping through all the squares and testing to see if the square is on the board. It prints the first six ranks, and then it gets to 96 in my for loop and quits printing anything.
Here is the relevant code. I really can't see what I'm doing wrong. I want to make sure the loop prints all squares on the board before I do anything with moves, since it's hard to generate the moves for a square it won't hit.
for(int i = 0; i < 120;)
{
if((board[i] & 0x88) != 0)
{
cout << i << " Square not on board..." << endl;
i += 8;
continue;
}
else
{
cout << i << endl;
i++;
}
}
As I see it, it should loop through all 120 iterations. I've check 96 in a decimal to binary converter, and it comes out to be 01100000. It should print it.
Suji wrote:I'm not writing the complicated part yet, but I've hit a snag. I'm working through my move generation code, and right now I'm looping through all the squares and testing to see if the square is on the board. It prints the first six ranks, and then it gets to 96 in my for loop and quits printing anything.
Here is the relevant code. I really can't see what I'm doing wrong. I want to make sure the loop prints all squares on the board before I do anything with moves, since it's hard to generate the moves for a square it won't hit.
for(int i = 0; i < 120;)
{
if((board[i] & 0x88) != 0)
{
cout << i << " Square not on board..." << endl;
i += 8;
continue;
}
else
{
cout << i << endl;
i++;
}
}
As I see it, it should loop through all 120 iterations. I've check 96 in a decimal to binary converter, and it comes out to be 01100000. It should print it.
To terminate the loop, you should be doing "i & 0x88" as "i" is the square number. You don't test the contents of the board squares, you test the square numbers themselves.