Skip to content

Commit

Permalink
📦 NEW: Add dead simple time managment
Browse files Browse the repository at this point in the history
  • Loading branch information
ianagbip1oti committed Aug 14, 2021
1 parent 4bd9c88 commit db9c7a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ feature_whitelist.txt
run_goose.sh
*.pb
expanded_feature_list.txt
bin/princhess
24 changes: 21 additions & 3 deletions engine/src/search.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use mcts::GameState;
use mcts::{MCTS, MCTSManager, AsyncSearchOwned, CycleBehaviour};
use mcts::tree_policy::AlphaGoPolicy;
use mcts::transposition_table::ApproxTable;
use state::{State, Move};
use state::{Player, State, Move};
use std::sync::mpsc::Sender;
use std::thread;
use std::time::Duration;
Expand All @@ -10,9 +11,10 @@ use uci::{TIMEUP, Tokens};
use evaluation::GooseEval;
use features::Model;
use args::options;
use chess::Piece;
use chess::{Color,Piece};

const DEFAULT_MOVE_TIME_SECS: u64 = 10;
const DEFAULT_MOVE_TIME_FRACTION: u64 = 15;

pub const SCALE: f32 = 1e9;

Expand Down Expand Up @@ -74,7 +76,7 @@ impl Search {
}
pub fn new(state: State) -> Self {
let search = Self::create_manager(state).into();
Self {search}
Self { search }
}
fn stop_and_print_m(self) -> MCTSManager<GooseMCTS> {
if self.search.num_threads() == 0 {
Expand Down Expand Up @@ -112,6 +114,22 @@ impl Search {
think_time = Some(Duration::from_millis(t));
}
}
"wtime" => {
if manager.tree().root_state().current_player() == Color::White {
let t = tokens.next().unwrap_or("".into());
if let Ok(t) = t.parse::<u64>() {
think_time = Some(Duration::from_millis(t / DEFAULT_MOVE_TIME_FRACTION))
}
}
}
"btime" => {
if manager.tree().root_state().current_player() == Color::Black {
let t = tokens.next().unwrap_or("".into());
if let Ok(t) = t.parse::<u64>() {
think_time = Some(Duration::from_millis(t / DEFAULT_MOVE_TIME_FRACTION))
}
}
}
"infinite" => think_time = None,
_ => (),
}
Expand Down

0 comments on commit db9c7a4

Please sign in to comment.