Skip to content

Commit

Permalink
Tweak shelter and tropism values
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes committed Sep 17, 2023
1 parent a5fe144 commit 6dc1ba8
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/evaluation/position/king.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ fn king_pawn_shelter(position: &Position, king_color: Color, king_square: Square
let mut shelter = 0;

let our_pawns = position.board.pieces_bb(Piece::Pawn) & position.board.occupancy_bb(king_color);
let their_pawns =
position.board.pieces_bb(Piece::Pawn) & position.board.occupancy_bb(king_color.opposite());
let their_queen_rooks = (position.board.pieces_bb(Piece::Queen)
| position.board.pieces_bb(Piece::Rook))
& position.board.occupancy_bb(king_color.opposite());

let file_min = match king_square.file() {
0 => 0,
Expand All @@ -22,7 +17,6 @@ fn king_pawn_shelter(position: &Position, king_color: Color, king_square: Square
_ => king_square.file() + 1,
};

const OPEN_FILE_PENALTY: ValueScore = -20;
const SHELTER_PENALTY: ValueScore = -20;

for file in file_min..=file_max {
Expand All @@ -42,14 +36,7 @@ fn king_pawn_shelter(position: &Position, king_color: Color, king_square: Square
};
shelter += shelter_penalty;
} else {
let file_mask = Bitboard::file_mask(file);
let their_pawns_on_file = their_pawns & file_mask;
let their_queen_rooks_on_file = their_queen_rooks & file_mask;
if their_pawns_on_file.is_empty() && their_queen_rooks_on_file.is_not_empty() {
shelter += OPEN_FILE_PENALTY;
} else {
shelter += OPEN_FILE_PENALTY / 2;
}
shelter += SHELTER_PENALTY * 2;
}
}

Expand All @@ -64,8 +51,7 @@ fn king_tropism(position: &Position, king_color: Color, king_square: Square) ->
let tropism = them_occupancy.fold(0, |acc, sq| {
let distance = sq.distance(king_square);
let piece_cof = match position.board.piece_at(sq) {
Some(Piece::Queen) => 3,
Some(Piece::Rook) => 2,
Some(Piece::Queen) | Some(Piece::Rook) => 2,
Some(Piece::Bishop) | Some(Piece::Knight) => 1,
_ => unreachable!(),
};
Expand Down

0 comments on commit 6dc1ba8

Please sign in to comment.