Skip to content

Commit

Permalink
On playouts, if a player cannot make a move then they lose
Browse files Browse the repository at this point in the history
  • Loading branch information
UsAndRufus committed Jan 7, 2018
1 parent 52b9aaa commit 88707ae
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/monty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ impl Monty {
assert!(!(game_state.ply_to_get_here.is_mill() && game_state.next_ply.is_mill()),
"Got here from a mill and next move is a mill: {:?}", game_state);

//println!("{:?}", game_state);

let winner = game_state.winner();

match winner {
Expand All @@ -77,10 +79,14 @@ impl Monty {
},
None => {
// TODO: currently breaks here because we never have children beyond placement
let new = thread_rng().choose(&game_state.children())
.expect(&format!("Failed to get random child from GameState: {:?}", &game_state))
.clone();
game_state = new;

let new_game_state = thread_rng().choose(&game_state.children()).cloned();


match new_game_state {
Some(new) => game_state = new,
None => break 0, // Cannot move so have lost the game
}
}
}
}
Expand Down

0 comments on commit 88707ae

Please sign in to comment.