Skip to content

Commit

Permalink
added a print for worst case scenario (actually this scenario pretty …
Browse files Browse the repository at this point in the history
…much never happens
  • Loading branch information
bananasmoothii committed Oct 11, 2023
1 parent a03f117 commit 45c3208
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ strum_macros = "0.25"
rayon = "1.8"
rand = "0.8"
console = "0.15"
thousands = "0.2"

[profile.release]
debug = true
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/min_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<G: Game> GameNode<G> {
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();
Expand Down

0 comments on commit 45c3208

Please sign in to comment.