From 629c70c86b0bb29d2d0c281add9d0d826a11c419 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sun, 12 Aug 2018 20:01:34 +0200 Subject: Collapsed player info into the rest of the 'buildings' object --- src/strategy/monte_carlo.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/strategy') diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs index 73ebf01..87033cb 100644 --- a/src/strategy/monte_carlo.rs +++ b/src/strategy/monte_carlo.rs @@ -1,7 +1,7 @@ use engine::command::*; use engine::geometry::*; use engine::status::GameStatus; -use engine::bitwise_engine::{Player, PlayerBuildings, BitwiseGameState}; +use engine::bitwise_engine::{Player, BitwiseGameState}; use engine::constants::*; use rand::{Rng, XorShiftRng, SeedableRng}; @@ -115,12 +115,12 @@ fn simulate_to_endstate(command_score: &mut CommandScore, state: &Bitwis } fn random_player_move(state: &BitwiseGameState, rng: &mut R) -> Command { - let all_buildings = sensible_buildings(&state.player, &state.player_buildings, state.player_has_max_teslas()); + let all_buildings = sensible_buildings(&state.player, state.player_has_max_teslas()); random_move(&all_buildings, state.player_can_build_iron_curtain(), rng, state.unoccupied_player_cell_count(), |i| state.location_of_unoccupied_player_cell(i)) } fn random_opponent_move(state: &BitwiseGameState, rng: &mut R) -> Command { - let all_buildings = sensible_buildings(&state.opponent, &state.opponent_buildings, state.opponent_has_max_teslas()); + let all_buildings = sensible_buildings(&state.opponent, state.opponent_has_max_teslas()); random_move(&all_buildings, state.opponent_can_build_iron_curtain(), rng, state.unoccupied_opponent_cell_count(), |i| state.location_of_unoccupied_opponent_cell(i)) } @@ -199,7 +199,7 @@ impl CommandScore { //TODO: Devalue nothing so that it doesn't stand and do nothing when it can do things fn init_command_scores(state: &BitwiseGameState) -> Vec { - let all_buildings = sensible_buildings(&state.player, &state.player_buildings, state.player_has_max_teslas()); + let all_buildings = sensible_buildings(&state.player, state.player_has_max_teslas()); let unoccupied_cells = (0..state.unoccupied_player_cell_count()).map(|i| state.location_of_unoccupied_player_cell(i)); @@ -222,7 +222,7 @@ impl CommandScore { } #[cfg(not(feature = "energy-cutoff"))] -fn sensible_buildings(player: &Player, _player_buildings: &PlayerBuildings, has_max_teslas: bool) -> Vec { +fn sensible_buildings(player: &Player, has_max_teslas: bool) -> Vec { let mut result = Vec::with_capacity(4); if DEFENCE_PRICE <= player.energy { @@ -245,9 +245,9 @@ fn sensible_buildings(player: &Player, _player_buildings: &PlayerBuildings, has_ //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 { +fn sensible_buildings(player: &Player, has_max_teslas: bool) -> Vec { let mut result = Vec::with_capacity(4); - let needs_energy = player_buildings.energy_generated() <= ENERGY_PRODUCTION_CUTOFF || + let needs_energy = player.energy_generated() <= ENERGY_PRODUCTION_CUTOFF || player.energy <= ENERGY_STORAGE_CUTOFF; if DEFENCE_PRICE <= player.energy { -- cgit v1.2.3