File pawn.cpp line 525
Code: Select all
rank = BIT_LAST(board->pawn_file[me][file]);
Code: Select all
if(me == White) rank = BIT_LAST(board->pawn_file[me][file]);
else rank = BIT_FIRST(BitRev[board->pawn_file[me][file]]);
Borko
Moderator: Ras
Code: Select all
rank = BIT_LAST(board->pawn_file[me][file]);
Code: Select all
if(me == White) rank = BIT_LAST(board->pawn_file[me][file]);
else rank = BIT_FIRST(BitRev[board->pawn_file[me][file]]);
I think that:borko wrote:It seems there is bug in TogaII.
File pawn.cpp line 525
fix:Code: Select all
rank = BIT_LAST(board->pawn_file[me][file]);
Regards,Code: Select all
if(me == White) rank = BIT_LAST(board->pawn_file[me][file]); else rank = BIT_FIRST(BitRev[board->pawn_file[me][file]]);
Borko
Code: Select all
BIT_LAST(board->pawn_file[me][file] == BIT_FIRST(BitRev[board->pawn_file[me][file]]
Not if you change bitfirst to bitlast AND do a bitreverse.borko wrote:I think you find the same pawn but rank is different.
Borko
I would like to say how I understand the code.Tony wrote:Not if you change bitfirst to bitlast AND do a bitreverse.borko wrote:I think you find the same pawn but rank is different.
Borko
Your idea seems correct but since you correct it double, it gives exactly the same as before.
Tony
Code: Select all
board->pawn_file[me][file]
Code: Select all
BitRev[BIT_FIRST(BitRev[pf])] == BIT_LAST(pf)
/* and also: */
BitRev[BIT_LAST(BitRev[pf])] == BIT_FIRST(pf)
Yes, you are rightSven Schüle wrote:I would like to say how I understand the code.Tony wrote:Not if you change bitfirst to bitlast AND do a bitreverse.borko wrote:I think you find the same pawn but rank is different.
Borko
Your idea seems correct but since you correct it double, it gives exactly the same as before.
Tonyshows presence of pawns on ranks of a given file relative to a given color 'me', so for white and rank 2 the same bit is used as for black and rank 7. (Edit: Actually the numbers for 'rank 2' and 'rank 7' may be different from 2 and 7 but this is an implementation detail.) 'pawn_file' has some bits set between bit positions p and q (as widest possible range), where p < q (in this case p=4 and q=11, I think, but it should not matter).Code: Select all
board->pawn_file[me][file]
AFAIK (from Fruit 2.1 code - correct me if this has changed in Toga), BIT_FIRST(pf) returns the smallest position x of all set bits in the argument pf (x >= p), and BIT_LAST(pf) returns the greatest position y of all set bits in pf (y <= q).
BitRev[pf] reverts the color viewpoint, it has bits set between bit positions K-q and K-p, with K as total number of "pseudo" ranks minus 1 (here K=15 but again this should not matter). The smallest positions of set bits are closer to K-q and the greatest ones closer to K-p.
BIT_FIRST(BitRev[pf]) therefore returns K-y IMHO. I do not see why this should always be the same as y (in fact it is almost never the same). This means that Borko's idea would not work anyway. Another BitRev[] around it would be necessary:but since the resulting 'rank' of the whole operation shall still be color-independent this is not necessary at all.Code: Select all
BitRev[BIT_FIRST(BitRev[pf])] == BIT_LAST(pf) /* and also: */ BitRev[BIT_LAST(BitRev[pf])] == BIT_FIRST(pf)
So unfortunately I disagree with Borko, Karlo and Tony at onceBut at least I agree with that part of the Toga (and Fruit 2.1) code.
Of course I may be wrong, please correct me in this case.
Sven
Code: Select all
if(me == White) rank = BIT_LAST(board->pawn_file[me][file]);
else rank = BIT_FIRST(BitRev[board->pawn_file[me][file]]);
single_file[me] = SQUARE_MAKE(file,rank);