From 2e232ecbc9b97a1558d49a0c55c72b50e1c9eeea Mon Sep 17 00:00:00 2001 From: Bananasmoothii <45853225+bananasmoothii@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:58:25 +0200 Subject: [PATCH] re-improved performances --- src/game/connect4.rs | 15 ++++++++++----- src/main.rs | 2 +- src/min_max.rs | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/game/connect4.rs b/src/game/connect4.rs index 143a9f4..75ddeef 100644 --- a/src/game/connect4.rs +++ b/src/game/connect4.rs @@ -336,6 +336,8 @@ impl ConnectFour { } } } + + const RANDOMIZE_POSSIBLE_PLAYS: bool = false; } impl Game for ConnectFour { @@ -455,11 +457,14 @@ impl Game for ConnectFour { } fn possible_plays(&self) -> Vec { - let order: [usize; 7] = match rand::thread_rng().gen_range(0..=4) { - 0 => [4, 3, 5, 2, 6, 1, 7], - 1 => [3, 5, 4, 2, 6, 1, 7], - 2 => [2, 6, 4, 3, 5, 1, 7], - _ => [7, 1, 6, 2, 5, 3, 4], + let order: [usize; 7] = if Self::RANDOMIZE_POSSIBLE_PLAYS { + match rand::thread_rng().gen_range(0..=2) { + 0 => [4, 3, 5, 2, 6, 1, 7], + 1 => [3, 5, 4, 2, 6, 1, 7], + _ => [2, 6, 4, 3, 5, 1, 7], + } + } else { + [4, 3, 5, 2, 6, 1, 7] }; order .iter() diff --git a/src/main.rs b/src/main.rs index 6408af7..349e26a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ mod scalar; fn main() { let max_depth = 10; - let bot_vs_bot = false; + let bot_vs_bot = true; let worst_case: u64 = (1..=max_depth).into_iter().map(|n| 7u64.pow(n)).sum(); println!( diff --git a/src/min_max.rs b/src/min_max.rs index f87b18e..0b18bd9 100644 --- a/src/min_max.rs +++ b/src/min_max.rs @@ -58,7 +58,7 @@ impl GameNode { } } - const FORK_DEPTH: u32 = 2; + const FORK_DEPTH: u32 = 3; const USE_GAME_SCORE: bool = true;