Refactor time info, update zobrist to tuple struct, naming and clippy
This commit is contained in:
@@ -9,25 +9,26 @@ use crate::{
|
||||
|
||||
use super::{
|
||||
negamax,
|
||||
time::{hard_limit, TimeInfo},
|
||||
time::TimeInfo,
|
||||
};
|
||||
|
||||
pub fn iterative_deepening(
|
||||
game: &mut Game,
|
||||
max_depth: u8,
|
||||
time_info: &TimeInfo,
|
||||
time: &TimeInfo,
|
||||
) -> anyhow::Result<Option<Move>> {
|
||||
let mut best_move = None;
|
||||
|
||||
for depth in 1..=max_depth {
|
||||
if hard_limit(time_info.instant, time_info.time, time_info.inc) {
|
||||
if time.exceed_hard_limit() {
|
||||
return Ok(best_move);
|
||||
}
|
||||
|
||||
let mut nodes = 0;
|
||||
let score = negamax::negamax(game, MIN_SCORE, MAX_SCORE, depth, 0, time_info, &mut nodes);
|
||||
let score = negamax::negamax(game, MIN_SCORE, MAX_SCORE, depth, 0, time, &mut nodes);
|
||||
|
||||
if score.is_err() {
|
||||
if let Err(e) = score {
|
||||
write_response(&mut io::stdout(), &Response::Info(format!("{e}")))?;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -37,9 +38,9 @@ pub fn iterative_deepening(
|
||||
&mut io::stdout(),
|
||||
&log_depth_results(
|
||||
depth,
|
||||
time_info.instant.elapsed().as_millis() as u64,
|
||||
time.instant.elapsed().as_millis() as u64,
|
||||
nodes,
|
||||
time_info.nps(nodes),
|
||||
time.nps(nodes),
|
||||
score?,
|
||||
best_move,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user