Skip to content

Commit

Permalink
Tweak medium and hard AI difficulties
Browse files Browse the repository at this point in the history
Using the ai difficulties example, I tweaked the difficulty settings to
to what I think is a good starting place. Playing perfect games, it is
possible to beat hard around 15% of the time.  The medium difficulty
is updated to be more aggressive on picking wining squares ... the
player will have to think a move or two ahead!

See issue #34.
  • Loading branch information
j-richey committed Jul 11, 2020
1 parent 69e37d0 commit f52df00
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,12 @@ impl Difficulty {

// Medium high chance of going for the win or blocking a loss. However, as
// the tree gets deeper it is more likely not evaluate that part of the tree.
fn medium_should_evaluate_node(_depth: i32) -> bool {
rand::thread_rng().gen_bool(0.8)
fn medium_should_evaluate_node(depth: i32) -> bool {
if depth == 0 {
rand::thread_rng().gen_bool(0.9)
} else {
rand::thread_rng().gen_bool(0.75)
}
}

// Hard looks several moves ahead. Past that there is a small chance if it
Expand All @@ -361,7 +365,7 @@ impl Difficulty {
if depth <= 1 {
true
} else {
rand::thread_rng().gen_bool(0.95)
rand::thread_rng().gen_bool(0.97)
}
}

Expand Down

0 comments on commit f52df00

Please sign in to comment.