-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Evaluate by attacks on the squares around the king. Elo | 24.27 +- 10.43 (95%) SPRT | 8.0+0.08s Threads=1 Hash=16MB LLR | 3.00 (-2.94, 2.94) [0.00, 5.00] Games | N: 2452 W: 864 L: 693 D: 895 Penta | [78, 248, 464, 297, 139]
- Loading branch information
1 parent
a167027
commit f954772
Showing
7 changed files
with
211 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use super::PhasedEval; | ||
use crate::chess::bitboard::Bitboard; | ||
use crate::chess::game::Game; | ||
use crate::chess::movegen::tables; | ||
use crate::chess::player::Player; | ||
use crate::engine::eval::params::{ | ||
ATTACKED_KING_SQUARES, BISHOP_MOBILITY, KNIGHT_MOBILITY, QUEEN_MOBILITY, ROOK_MOBILITY, | ||
}; | ||
|
||
fn mobility_and_opp_king_safety_for(game: &Game, player: Player) -> PhasedEval { | ||
let mut eval = PhasedEval::ZERO; | ||
let blockers = game.board.occupancy(); | ||
|
||
let mut attacked_squares = Bitboard::EMPTY; | ||
|
||
for p in game.board.knights(player) { | ||
let moves = tables::knight_attacks(p); | ||
attacked_squares |= moves; | ||
eval += KNIGHT_MOBILITY[moves.count() as usize]; | ||
} | ||
|
||
for p in game.board.bishops(player) { | ||
let moves = tables::bishop_attacks(p, blockers); | ||
attacked_squares |= moves; | ||
eval += BISHOP_MOBILITY[moves.count() as usize]; | ||
} | ||
|
||
for p in game.board.rooks(player) { | ||
let moves = tables::rook_attacks(p, blockers); | ||
attacked_squares |= moves; | ||
eval += ROOK_MOBILITY[moves.count() as usize]; | ||
} | ||
|
||
for p in game.board.queens(player) { | ||
let moves = tables::bishop_attacks(p, blockers) | tables::rook_attacks(p, blockers); | ||
attacked_squares |= moves; | ||
eval += QUEEN_MOBILITY[moves.count() as usize]; | ||
} | ||
|
||
let enemy_king = game.board.king(player.other()).single(); | ||
let enemy_king_surrounding_squares = tables::king_attacks(enemy_king); | ||
let attacks_on_enemy_king = attacked_squares & enemy_king_surrounding_squares; | ||
|
||
eval -= ATTACKED_KING_SQUARES[attacks_on_enemy_king.count() as usize]; | ||
|
||
eval | ||
} | ||
|
||
pub fn eval(game: &Game) -> PhasedEval { | ||
mobility_and_opp_king_safety_for(game, Player::White) | ||
- mobility_and_opp_king_safety_for(game, Player::Black) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.