From 45c32087019c4335e87d58056440e3d04d216522 Mon Sep 17 00:00:00 2001 From: Bananasmoothii <45853225+bananasmoothii@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:21:58 +0200 Subject: [PATCH] added a print for worst case scenario (actually this scenario pretty much never happens --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/main.rs | 9 +++++++++ src/min_max.rs | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 1dd91b4..a263e80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -119,6 +119,7 @@ dependencies = [ "rayon", "strum", "strum_macros", + "thousands", ] [[package]] @@ -237,6 +238,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "thousands" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" + [[package]] name = "unicode-ident" version = "1.0.12" diff --git a/Cargo.toml b/Cargo.toml index 3f496c0..9485828 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ strum_macros = "0.25" rayon = "1.8" rand = "0.8" console = "0.15" +thousands = "0.2" [profile.release] debug = true diff --git a/src/main.rs b/src/main.rs index a9b0f4e..6ce2bc3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ use std::io; use std::num::{NonZeroU8, NonZeroUsize}; +use thousands::Separable; + use crate::bot::Bot; use crate::game::connect4::Power4; use crate::game::player::Player; @@ -15,6 +17,13 @@ fn main() { let max_depth = 9; let bot_vs_bot = false; + let worst_case: u64 = (1..=max_depth).into_iter().map(|n| 7u64.pow(n)).sum(); + println!( + "Max depth: {max_depth} -> Worst case: 7^{} + 7^{} + ... + 7^1) = {} nodes", + max_depth, + max_depth - 1, + worst_case.separate_with_commas() + ); let p1 = NonZeroU8::new(1).unwrap(); let p2 = NonZeroU8::new(2).unwrap(); diff --git a/src/min_max.rs b/src/min_max.rs index 0170841..f87b18e 100644 --- a/src/min_max.rs +++ b/src/min_max.rs @@ -155,7 +155,7 @@ impl GameNode { let weight = if self.is_parallelize_depth(real_plays) { // parallelize self.children.par_iter_mut().try_for_each(|(_, child)| { - print!("F"); + //print!("F"); maybe_explore_children(child) }); let weight = (*worst_child_score.lock().unwrap()).into();