diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2019-08-07 14:37:36 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2019-08-07 14:37:36 +0200 |
commit | d4539771bca817add851ef484de4773cbbe43f79 (patch) | |
tree | 371556db78894f666425d8d28a67b23f89aed196 /src/strategy | |
parent | 096091af6a3a4d16da133037321c81a51e1bb4b2 (diff) |
Assertions to test that my lava logic is right
Diffstat (limited to 'src/strategy')
-rw-r--r-- | src/strategy/mcts.rs | 10 | ||||
-rw-r--r-- | src/strategy/minimax.rs | 2 |
2 files changed, 5 insertions, 7 deletions
diff --git a/src/strategy/mcts.rs b/src/strategy/mcts.rs index 5a43c6e..b7478b8 100644 --- a/src/strategy/mcts.rs +++ b/src/strategy/mcts.rs @@ -41,9 +41,9 @@ pub fn choose_move( let _ = mcts(&mut root_node); } - //eprintln!("Number of simulations: {}", root_node.score_sum.visit_count); + eprintln!("Number of simulations: {}", root_node.score_sum.visit_count); for (command, score_sum) in &root_node.player_score_sums[0] { - //eprintln!( + eprintln!( "{} = {} ({} visits)", command, score_sum.avg().val, @@ -164,8 +164,8 @@ fn mcts(node: &mut Node) -> Score { } fn mcts_move_combo(state: &GameBoard) -> Vec<[Command; 2]> { - let player_moves = self.valid_moves(0); - let opponent_moves = self.valid_moves(1); + let player_moves = state.valid_moves(0); + let opponent_moves = state.valid_moves(1); debug_assert!(!player_moves.is_empty(), "No player moves"); debug_assert!(!opponent_moves.is_empty(), "No opponent moves"); @@ -228,5 +228,3 @@ fn update(node: &mut Node, commands: [Command; 2], score: Score) { .or_insert_with(ScoreSum::new) += score; node.score_sum += score; } - - diff --git a/src/strategy/minimax.rs b/src/strategy/minimax.rs index 4b10014..be0c485 100644 --- a/src/strategy/minimax.rs +++ b/src/strategy/minimax.rs @@ -289,7 +289,7 @@ fn pruned_moves(state: &GameBoard, player_index: usize) -> Vec<Command> { .filter(|command| { //NB: These rules should pass for doing nothing, otherwise // we need some other mechanism for sticking in a do - // nothing option + // nothing option. Unfortunately, sitting in lava is a situation where this prunes all moves currently :( let idle_opponent_state = sim_with_idle_opponent(*command); let hurt_self = idle_opponent_state.players[player_index].health() < my_starting_health; |