bob wrote:Crafty only considers a2/a7/h2/h7. No other squares. I tested the a3-a6-h3-h6 idea and got zero. And as a general rule, I leave anything out that produces nothing, UNLESS it simplifies the code.
And I don't do it as above today anyway. A long while back I combined the concept of "outpost bishops" with "trapped bishops" to get the test for free.
At least you also used b1/b8/g1/g8 from Crafty 19.2 (2003) until you dropped it in 23.0 (2009). See the code history further down, which does also show the following:
1. Crafty did almost always have the trapped bishop eval term in some kind, even long before Fruit appeared. (Not denied by anone, of course, just to clarify.)
2. Crafty *never* implemented it in the way as you proposed in your example above (I already fixed the two bugs

):
Code: Select all
if (trapped_mask[bishop_square] & pawns[enemy]) score -= 64;
but instead always used a form where pairs of explicit squares, like A7/B6 or B8/C7, were checked (with several improvements over time), as can also be seen in Fruit later on.
3. The Rybka 1.0beta implementation (see my previous post for the asm) was really different from all that, by doing the whole "trapped bishop" test once per corner [I previously wrote "once per color" but actually "corner" is more accurate] instead of once per bishop (Crafty) resp. on square-by-square base, and also by not using any additional memory space for it. Also: who else has something similar to that "B5/C6/C7" masking concept of R1.0beta?
So my basic point of the "trapped bishop" story w.r.t. its analysis in EVAL_COMP comes down to:
- Attributing "0.5" as feature overlap of Crafty 19.0 and Fruit 2.1 is highly exaggerated, the difference is significant so "0.0" or "0.1" would be more appropriate IN MY VIEW since even the set of tested squares differs a lot.
- Attributing "0.7" as feature overlap of R1.0beta and Fruit 2.1 is highly exaggerated as well, also here the difference is very significant. Since the set of tested squares is the same but everything else differs a lot one might perhaps want to assign "0.2" IN MY VIEW.
- Furthermore, this "trapped bishop" stuff is one of several examples where the whole "feature overlap" concept simply breaks down since we are talking about one of many elements of "common chess knowledge", only the details (only check bishop on A7, or also check B8, or even also A6) make tiny differences, so there is very low information content (IC) in any actual implementation of that term. Measuring "code overlap" might make sense, instead, but here R1.0 is certainly at "0.0" in this case.
Now, as promised, here is the relevant part of the "Crafty trapped bishop" code history, to back up some of my statements above.
Code: Select all
Crafty 17.0 (nov-1999) until 19.1 (oct-2002):
[once per color, example for White]
if (WhiteBishops) {
if (WhiteBishops&mask_A7H7) {
if (WhiteBishops&SetMask(A7) && SetMask(B6)&BlackPawns)
score-=BISHOP_TRAPPED;
else if (WhiteBishops&SetMask(H7) && SetMask(G6)&BlackPawns)
score-=BISHOP_TRAPPED;
}
}
Crafty 19.2 (jan-2003) until 20.0 (aug-2005):
[once per color, example for White; introduced B8/G8 test]
if (WhiteBishops) {
if (WhiteBishops&mask_WBT) {
if (WhiteBishops&SetMask(A7) && SetMask(B6)&BlackPawns)
score-=BISHOP_TRAPPED;
else if (WhiteBishops&SetMask(B8) && SetMask(C7)&BlackPawns)
score-=BISHOP_TRAPPED;
else if (WhiteBishops&SetMask(H7) && SetMask(G6)&BlackPawns)
score-=BISHOP_TRAPPED;
else if (WhiteBishops&SetMask(G8) && SetMask(F7)&BlackPawns)
score-=BISHOP_TRAPPED;
}
}
Crafty 20.1 (oct-2005) until at least 21.6 (oct-2007):
[done for each bishop within the bishop eval loop, example for White]
if (square == A7 && SetMask(B6) & BlackPawns)
score -= bishop_trapped;
else if (square == B8 && SetMask(C7) & BlackPawns)
score -= bishop_trapped;
else if (square == H7 && SetMask(G6) & BlackPawns)
score -= bishop_trapped;
else if (square == G8 && SetMask(F7) & BlackPawns)
score -= bishop_trapped;
Crafty 22.0 (feb-2008) until 22.1 (apr-2008):
[done for each bishop within the bishop eval loop; now generic code for both sides]
if (square == sqflip[side][A7] && SetMask(sqflip[side][B6]) & Pawns(enemy))
score -= bishop_trapped;
else if (square == sqflip[side][B8] &&
SetMask(sqflip[side][C7]) & Pawns(enemy))
score -= bishop_trapped;
else if (square == sqflip[side][H7] &&
SetMask(sqflip[side][G6]) & Pawns(enemy))
score -= bishop_trapped;
else if (square == sqflip[side][G8] &&
SetMask(sqflip[side][F7]) & Pawns(enemy))
score -= bishop_trapped;
Crafty 22.2 (nov-2008) until 22.10 (jan-2009):
[same as before but introduced score_mg/score_eg concept in Crafty eval]
if (square == sqflip[side][A7] && SetMask(sqflip[side][B6]) & Pawns(enemy)) {
score_eg -= bishop_trapped;
score_mg -= bishop_trapped;
} else if (square == sqflip[side][B8] &&
SetMask(sqflip[side][C7]) & Pawns(enemy)) {
score_eg -= bishop_trapped;
score_mg -= bishop_trapped;
} else if (square == sqflip[side][H7] &&
SetMask(sqflip[side][G6]) & Pawns(enemy)) {
score_eg -= bishop_trapped;
score_mg -= bishop_trapped;
} else if (square == sqflip[side][G8] &&
SetMask(sqflip[side][F7]) & Pawns(enemy)) {
score_eg -= bishop_trapped;
score_mg -= bishop_trapped;
}
Crafty 23.0 (feb-2009) until 23.4 (nov-2010):
[still done for each bishop within the bishop eval loop;
now combined with "bishop outpost" evaluation and also dropped B8/G8 from pattern]
if (square == sqflip[side][A7]) {
if (SetMask(sqflip[side][B6]) & Pawns(enemy)) {
score_eg -= bishop_trapped;
score_mg -= bishop_trapped;
}
} else if (SetMask(sqflip[side][G6]) & Pawns(enemy)) {
score_eg -= bishop_trapped;
score_mg -= bishop_trapped;
}
Sven