Skip to content

Commit

Permalink
re-improved performances
Browse files Browse the repository at this point in the history
  • Loading branch information
bananasmoothii committed Oct 12, 2023
1 parent 57afd6a commit 2e232ec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/game/connect4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ impl ConnectFour {
}
}
}

const RANDOMIZE_POSSIBLE_PLAYS: bool = false;
}

impl Game for ConnectFour {
Expand Down Expand Up @@ -455,11 +457,14 @@ impl Game for ConnectFour {
}

fn possible_plays(&self) -> Vec<NonZeroUsize> {
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()
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion src/min_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<G: Game> GameNode<G> {
}
}

const FORK_DEPTH: u32 = 2;
const FORK_DEPTH: u32 = 3;

const USE_GAME_SCORE: bool = true;

Expand Down

0 comments on commit 2e232ec

Please sign in to comment.