tune: time limits for games longer than 5'
This commit is contained in:
parent
e44cc0586e
commit
ab1dfb3aa1
@ -69,7 +69,7 @@ impl From<Color> for char {
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
enum Piece {
|
||||
pub enum Piece {
|
||||
Rook,
|
||||
Bishop,
|
||||
Knight,
|
||||
|
12
src/main.rs
12
src/main.rs
@ -135,18 +135,26 @@ fn cmd_go(mut tokens: std::str::SplitWhitespace<'_>, state: &mut MainState) {
|
||||
}
|
||||
}
|
||||
|
||||
let (ourtime_ms, theirtime_ms) = if state.board.get_turn() == Color::White {
|
||||
let (mut ourtime_ms, theirtime_ms) = if state.board.get_turn() == Color::White {
|
||||
(wtime, btime)
|
||||
} else {
|
||||
(btime, wtime)
|
||||
};
|
||||
|
||||
if ourtime_ms == 0 {
|
||||
ourtime_ms = 300_000
|
||||
}
|
||||
|
||||
state
|
||||
.tx_engine
|
||||
.send(MsgToEngine::Go(Box::new(GoMessage {
|
||||
board: state.board,
|
||||
config: state.config,
|
||||
time_lims: TimeLimits::from_ourtime_theirtime(ourtime_ms, theirtime_ms),
|
||||
time_lims: TimeLimits::from_ourtime_theirtime(
|
||||
ourtime_ms,
|
||||
theirtime_ms,
|
||||
eval_metrics(&state.board),
|
||||
),
|
||||
})))
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ Copyright © 2024 dogeystamp <dogeystamp@disroot.org>
|
||||
|
||||
//! Prelude that you can import entirely to use the library conveniently.
|
||||
|
||||
pub use crate::eval::{eval_metrics, EvalMetrics};
|
||||
pub use crate::eval::{eval_metrics, EvalMetrics, EvalInt, Eval};
|
||||
pub use crate::fen::{FromFen, ToFen};
|
||||
pub use crate::movegen::{FromUCIAlgebraic, Move, MoveGen, ToUCIAlgebraic};
|
||||
pub use crate::search::{best_line, best_move, SearchEval, TranspositionTable, EngineState, SearchConfig, TimeLimits};
|
||||
pub use crate::{Board, Color, BOARD_HEIGHT, BOARD_WIDTH, N_COLORS, N_PIECES, N_SQUARES};
|
||||
pub use crate::{Board, Color, BOARD_HEIGHT, BOARD_WIDTH, N_COLORS, N_PIECES, N_SQUARES, ColPiece, Piece};
|
||||
pub use crate::coordination::{UCIMode, UCIModeTransition, UCIModeMachine, MsgBestmove, MsgToMain, MsgToEngine, GoMessage};
|
||||
|
@ -13,11 +13,8 @@ Copyright © 2024 dogeystamp <dogeystamp@disroot.org>
|
||||
|
||||
//! Game-tree search.
|
||||
|
||||
use crate::coordination::MsgToEngine;
|
||||
use crate::eval::{Eval, EvalInt};
|
||||
use crate::prelude::*;
|
||||
use crate::hash::ZobristTable;
|
||||
use crate::movegen::{Move, MoveGen};
|
||||
use crate::{Board, Piece};
|
||||
use std::cmp::{max, min};
|
||||
use std::sync::mpsc;
|
||||
use std::time::{Instant, Duration};
|
||||
@ -345,12 +342,19 @@ pub struct TimeLimits {
|
||||
|
||||
impl TimeLimits {
|
||||
/// Make time limits based on wtime, btime (but color-independent).
|
||||
pub fn from_ourtime_theirtime(ourtime_ms: u64, _theirtime_ms: u64) -> TimeLimits {
|
||||
///
|
||||
/// Also takes in eval metrics, for instance to avoid wasting too much time in the opening.
|
||||
pub fn from_ourtime_theirtime(ourtime_ms: u64, _theirtime_ms: u64, eval: EvalMetrics) -> TimeLimits {
|
||||
// hard timeout (max)
|
||||
let mut hard_ms = 100_000;
|
||||
// soft timeout (max)
|
||||
let mut soft_ms = 1_200;
|
||||
|
||||
// if we have more than 5 minutes, and we're out of the opening, we can afford to think longer
|
||||
if ourtime_ms > 300_000 && eval.phase <= 13 {
|
||||
soft_ms = 3_000
|
||||
}
|
||||
|
||||
let factor = if ourtime_ms > 5_000 { 10 } else { 40 };
|
||||
hard_ms = min(ourtime_ms / factor, hard_ms);
|
||||
soft_ms = min(ourtime_ms / 50, soft_ms);
|
||||
|
Loading…
Reference in New Issue
Block a user