Skip to content

Commit

Permalink
Fix uci promotion print and check hash move check
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes committed Dec 25, 2024
1 parent 5aa2be1 commit 8d0adaa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/.vscode

# External tooling
fast-chess/
fastchess/
lichess-bot/

# Performance outputs
Expand Down
4 changes: 2 additions & 2 deletions src/core/moves/gen/pawns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ mod tests {
"8/8/8/8/8/3K1k1p/6p1/5R2 b - - 1 54",
pawn_moves_front,
[
vec!["g2g1=Q", "g2g1=R", "g2g1=B", "g2g1=N", "h3h2"],
vec!["g2g1=Q", "g2g1=R", "g2g1=B", "g2g1=N"],
vec!["g2g1q", "g2g1r", "g2g1b", "g2g1n", "h3h2"],
vec!["g2g1q", "g2g1r", "g2g1b", "g2g1n"],
vec!["h3h2"],
],
);
Expand Down
5 changes: 2 additions & 3 deletions src/core/moves/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ impl Display for Move {
"{}{}{}",
self.from(),
self.to(),
self.promotion_piece()
.map_or(String::new(), |p| format!("={}", p.to_string().to_uppercase()))
self.promotion_piece().map_or(String::new(), |p| p.to_string())
)
}
}
Expand Down Expand Up @@ -221,6 +220,6 @@ mod tests {
assert_eq!(mov1.to_string(), "e4e5".to_string());

let mov1 = Move::new(E7, D8, QueenPromotionCapture);
assert_eq!(mov1.to_string(), "e7d8=Q".to_string());
assert_eq!(mov1.to_string(), "e7d8q".to_string());
}
}
9 changes: 8 additions & 1 deletion src/search/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use portable_atomic::AtomicU128;

use super::{Depth, MAX_DEPTH};
use crate::{
core::{moves::Move, Position},
core::{
moves::{make::make_move, Move},
Position,
},
evaluation::{Score, ValueScore},
};
use std::{
Expand Down Expand Up @@ -166,6 +169,10 @@ impl SearchTable {
.get(position)
.map(|entry| entry.best_move)
.filter(|mov| mov.is_pseudo_legal(position))
.filter(|m| {
let new_position = make_move::<false>(position, *m);
!new_position.is_check()
})
}

pub fn get_table_score(
Expand Down

0 comments on commit 8d0adaa

Please sign in to comment.