Gary
Joined: 12 Dec 2006 Posts: 349
|
Post subject: Undefended pieces Posted: Mon Mar 05, 2012 11:20 pm |
|
|
I thought I would try this out after the recent thread on loose pieces. The idea is that in the opening, it's good to have pieces defended by each other. So, pieces that are undefended get a small penalty. This is in addition to the penalty they may receive by being attacked by an enemy piece.
Unfortunately, it did not seem to help. It was decently promising in 16k games at 5ply fixed depth matches, showing +3-4 elo. Due to the loss of speed, this didn't carry over to timed matches that I could see.
The current version of the modification for Stockfish is below. I really like that Marco has posted Stockfish on github! Forking and playing around with the code is so easy. I should note that the branch of the fork is available here: https://github.com/glinscott/Stockfish/tree/undefended_pieces.
| Code: |
const Score UndefendedPenalty[] = {
S(0, 0), S(3, 0), S(12, 2), S(12, 2), S(25, 6), S(45, 15)
};
// Enemy pieces not defended by a pawn
Bitboard weakEnemies = pos.pieces(Them)
& ~ei.attackedBy[Them][PAWN];
Bitboard undefended = weakEnemies & ~ei.attackedBy[Them][0] & ~(Rank1BB | Rank8BB);
if (undefended)
{
const int multipliers[] = { 0, 1, 3, 6, 12, 22, 36, 36, 36, 36, 36, 36, 36, 36, 36 };
int undefendedCount = 0;
while (undefended)
{
Square s = pop_1st_bit(&undefended);
PieceType pt = type_of(pos.piece_on(s));
if (pt != KING)
{
score += UndefendedPenalty[pt];
if (pt != PAWN)
undefendedCount++;
}
}
score = (multipliers[undefendedCount] * score) / 32;
}
|
|
|