Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node count TM #50

Merged
merged 8 commits into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Internal Iterative Reduction (IIR)
https://chess.swehosting.se/test/757/

====================================================================================
Release 5 [May 31/June 6 2023]
Release 5 [May 31/June 1 2023]

Fail-Hard NMP

Expand All @@ -323,4 +323,21 @@ TT Move alpha
GAMES | N: 1424 W: 463 L: 314 D: 647
https://chess.swehosting.se/test/1203/

====================================================================================
====================================================================================
5.1 [June 3]

Node count TM

ELO | 8.15 +- 5.55 (95%)
SPRT | 8.0+0.08s Threads=1 Hash=16MB
LLR | 3.03 (-2.94, 2.94) [0.00, 5.00]
GAMES | N: 8104 W: 2277 L: 2087 D: 3740
https://chess.swehosting.se/test/1278/

ELO | 14.31 +- 7.76 (95%)
SPRT | 40.0+0.40s Threads=1 Hash=256MB
LLR | 2.99 (-2.94, 2.94) [0.00, 5.00]
GAMES | N: 3888 W: 1061 L: 901 D: 1926
https://chess.swehosting.se/test/1276/

====================================================================================
30 changes: 28 additions & 2 deletions engine/src/body/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ pub struct SearchInfo {
pub stop: bool,
pub search_type: SearchType,
pub timer: Option<Instant>,
pub base_optimum: Option<u64>,
pub max_time: Option<u64>,
pub nodes: u64,
pub node_table: [[u64; 64]; 64],
pub seldepth: usize,
pub game_history: Vec<u64>,
pub killers: [[Option<Move>; 2]; MAX_PLY],
Expand All @@ -53,8 +55,10 @@ impl SearchInfo {
stop: false,
search_type: SearchType::Depth(0),
timer: None,
base_optimum: None,
max_time: None,
nodes: 0,
node_table: [[0; 64]; 64],
seldepth: 0,
game_history: vec![],
killers: [[None; 2]; MAX_PLY],
Expand Down Expand Up @@ -285,6 +289,7 @@ impl Search {
moves_played += 1;
self.info.game_history.push(board.hash());
self.info.nodes += 1;
let previous_nodes = self.info.nodes;
let gives_check = !board.checkers().is_empty();

let mut score: i32;
Expand Down Expand Up @@ -344,6 +349,12 @@ impl Search {
self.info.game_history.pop();
self.nnue.pop();

if root {
// Difference in node count
self.info.node_table[mv.from as usize][mv.to as usize] +=
self.info.nodes - previous_nodes;
}

if score <= best_score {
continue;
}
Expand Down Expand Up @@ -503,6 +514,7 @@ impl Search {
depth = MAX_PLY;
self.info.timer = Some(Instant::now());
self.info.max_time = Some(max);
self.info.base_optimum = Some(opt);
opt_time = Some(opt);
}
SearchType::Infinite => {
Expand Down Expand Up @@ -559,8 +571,20 @@ impl Search {
}
}

// Optimal time is up
if let Some(opt) = opt_time {
// Optimal time check
if let Some(mut opt) = opt_time {
// Time bound adjustments
#[rustfmt::skip]
let best_move_fraction =
self.info.node_table
[best_move.unwrap().from as usize]
[best_move.unwrap().to as usize] as f64
/ self.info.nodes as f64;

let time_factor = (1.5 - best_move_fraction) * 1.35;
opt = (self.info.base_optimum.unwrap() as f64 * time_factor) as u64;


if info_timer.elapsed().as_millis() as u64 >= opt {
break;
}
Expand Down Expand Up @@ -646,7 +670,9 @@ impl Search {
self.info.search_type = SearchType::Depth(0);
self.info.timer = None;
self.info.max_time = None;
self.info.base_optimum = None;
self.info.nodes = 0;
self.info.node_table = [[0; 64]; 64];
self.info.seldepth = 0;
self.info.killers = [[None; 2]; MAX_PLY];
self.info.history.age_table();
Expand Down
2 changes: 0 additions & 2 deletions engine/src/ideas.txt

This file was deleted.

2 changes: 1 addition & 1 deletion engine/src/uci/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum SearchType {
}

fn id() {
println!("id name Svart 5");
println!("id name Svart 5.1");
println!("id author Crippa");
}

Expand Down