Fixed logic error on when nothing should be avoided
authorJustin Worthe <justin@worthe-it.co.za>
Sun, 12 Aug 2018 19:26:41 +0000 (21:26 +0200)
committerJustin Worthe <justin@worthe-it.co.za>
Sun, 12 Aug 2018 19:26:41 +0000 (21:26 +0200)
src/strategy/monte_carlo.rs

index 4d699c1..78ec4ac 100644 (file)
@@ -116,9 +116,10 @@ fn simulate_to_endstate<R: Rng>(command_score: &mut CommandScore, state: &Bitwis
 
 fn random_move<R: Rng>(player: &Player, rng: &mut R) -> Command {
     let all_buildings = sensible_buildings(player);
-    let nothing_count = if all_buildings.len() > 2 { 1 } else { 0 };
-    let iron_curtain_count = if player.can_build_iron_curtain() { 1 } else { 0 };
     let free_positions_count = player.unoccupied_cell_count();
+    
+    let nothing_count = if all_buildings.len() > 2 && free_positions_count > 0 { 0 } else { 1 };
+    let iron_curtain_count = if player.can_build_iron_curtain() { 1 } else { 0 };
         
     let building_choice_index = rng.gen_range(0, all_buildings.len() + nothing_count + iron_curtain_count);