diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-09-02 20:48:15 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-09-02 20:48:15 +0200 |
commit | b78eae28a11edefb27599d16307f248b52f74b6d (patch) | |
tree | 22a6c9b7ccfa55c572d211d8f88c3f81db3dc33e /src/strategy | |
parent | 4c8b8667cbd0d16f6da056c1404a841196654e9b (diff) |
Made it possible to build iron curtains as they become available
Diffstat (limited to 'src/strategy')
-rw-r--r-- | src/strategy/monte_carlo.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs index 1a4c400..f6b8956 100644 --- a/src/strategy/monte_carlo.rs +++ b/src/strategy/monte_carlo.rs @@ -257,7 +257,7 @@ fn random_move<R: Rng>(player: &Player, opponent: &Player, rng: &mut R) -> Comma 0 } else { // TODO: take into account opponent attacks and defence in row? - 8 + opponent.count_energy_towers_in_row(point.y()) - player.count_attack_towers_in_row(point.y()) + 8 + opponent.count_energy_towers_in_row(point.y()) + opponent.count_towers_in_row(point.y()) - player.count_attack_towers_in_row(point.y()) }; attack_end += weight; @@ -402,9 +402,11 @@ impl CommandScore { } let building_command_count = unoccupied_cells.len()*all_buildings.len(); - + let mut commands = Vec::with_capacity(building_command_count + 1); - if state.player.can_build_iron_curtain() && IRON_CURTAIN_PRICE.saturating_sub(state.player.energy) / energy_generated < 4 { + let time_to_curtain_energy = (IRON_CURTAIN_PRICE.saturating_sub(state.player.energy) / energy_generated) as u8; + + if time_to_curtain_energy < 4 && state.player.can_build_iron_curtain_in(state.round, time_to_curtain_energy) { commands.push(CommandScore::new(Command::IronCurtain, state.player.energy < IRON_CURTAIN_PRICE)); } |