Outside Passed Pawns
Posted: 08 Aug 2007, 13:14
Hello everyone
Doing a Google search on "outside passed pawn" I find the following:-
Outside Passed Pawn
Definition
A passed pawn that is near the edge of the board and far away from other pawns.
I could determine if white had an outside passed pawn by first condensing all the pawns down to 8 bits with a bit of magic then look up a pre-computed table[8][256] :-
But this is not strictly accurate... is it?
If white had a passed pawn on a5 far and away from other pawns except for a black pawn on b4, the above code would not find the outside passed pawn. So maybe I should mask off any black pawns that are behind the passed pawn :-
What if white only had one pawn? This code would then treat white's only pawn as being outside passed, which is not possible. So maybe I should check that white has at least 2 pawns :-
The above definition of outside passed pawns seems ambiguous to me and I am not clear as to the best way of coding it. Any help would be appreciated.
Thanks
Grant
Doing a Google search on "outside passed pawn" I find the following:-
Outside Passed Pawn
Definition
A passed pawn that is near the edge of the board and far away from other pawns.
I could determine if white had an outside passed pawn by first condensing all the pawns down to 8 bits with a bit of magic then look up a pre-computed table[8][256] :-
- Code: Select all
square = lsb(WhitePassedPawns);
rankOccupancy = (int) ((AllPawns * 0x0101010101010101) >> 56);
outsidePassed = table[COL(square)][rankOccupancy];
But this is not strictly accurate... is it?
If white had a passed pawn on a5 far and away from other pawns except for a black pawn on b4, the above code would not find the outside passed pawn. So maybe I should mask off any black pawns that are behind the passed pawn :-
- Code: Select all
square = lsb(WhitePassedPawns);
temp = (pawnMask[ROW(square)] & BlackPawns) | WhitePawns;
rankOccupancy = (int) ((temp * 0x0101010101010101) >> 56);
outsidePassed = table[COL(square)][rankOccupancy];
What if white only had one pawn? This code would then treat white's only pawn as being outside passed, which is not possible. So maybe I should check that white has at least 2 pawns :-
- Code: Select all
if (WhitePawns & WhitePawns - 1) {
square = lsb(WhitePassedPawns);
temp = (pawnMask[ROW(square)] & BlackPawns) | WhitePawns;
rankOccupancy = (int) ((temp * 0x0101010101010101) >> 56);
outsidePassed = table[COL(square)][rankOccupancy];
}
else
ousidePassed = FALSE;
The above definition of outside passed pawns seems ambiguous to me and I am not clear as to the best way of coding it. Any help would be appreciated.
Thanks
Grant