From 648dce3cfae16253472ed87674de448555ef0a15 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 12 Aug 2018 12:05:12 +0200 Subject: Test cases that do the iron curtain --- src/strategy/monte_carlo.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/strategy/monte_carlo.rs') diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs index 95d87fa..b02ebf4 100644 --- a/src/strategy/monte_carlo.rs +++ b/src/strategy/monte_carlo.rs @@ -134,12 +134,14 @@ fn random_movePoint>(all_buildings: &[BuildingType], iron_ Command::Nothing } else if iron_curtain_available && building_choice_index == all_buildings.len() + 1 { Command::IronCurtain - } else { + } else if free_positions_count > 0 { let position_choice = rng.gen_range(0, free_positions_count); Command::Build( get_point(position_choice), all_buildings[building_choice_index] ) + } else { + Command::Nothing } } @@ -202,10 +204,12 @@ impl CommandScore { let unoccupied_cells = (0..state.unoccupied_player_cell_count()).map(|i| state.location_of_unoccupied_player_cell(i)); let building_command_count = unoccupied_cells.len()*all_buildings.len(); - let nothing_count = 1; - let mut commands = Vec::with_capacity(building_command_count + nothing_count); + let mut commands = Vec::with_capacity(building_command_count + 2); commands.push(CommandScore::new(Command::Nothing)); + if state.player_can_build_iron_curtain() { + commands.push(CommandScore::new(Command::IronCurtain)); + } for position in unoccupied_cells { for &building in &all_buildings { @@ -238,7 +242,7 @@ fn sensible_buildings(player: &Player, _player_buildings: &PlayerBuildings, has_ } -//TODO: Heuristic that avoids building the initial energy towers all in the same row? +//TODO: Heuristic that avoids building the initial energy towers all in the same row? Max energy in a row? //TODO: Update cutoff to maybe build iron curtains #[cfg(feature = "energy-cutoff")] fn sensible_buildings(player: &Player, player_buildings: &PlayerBuildings, has_max_teslas: bool) -> Vec { -- cgit v1.2.3