diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2018-08-09 20:50:25 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2018-08-09 20:50:25 +0200 |
commit | 2c7870073e70ac19a6959c5627b04ad3c62d8173 (patch) | |
tree | fc6905f5acaa349b602aaa615ea49d4258f8feb7 /src/strategy | |
parent | ea78e266cff3f57c39442aefc21295a758419e69 (diff) |
Removed unnecessary Player field
Diffstat (limited to 'src/strategy')
-rw-r--r-- | src/strategy/monte_carlo.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs index cf0d77c..25b5a66 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, BitwiseGameState}; +use engine::bitwise_engine::{Player, PlayerBuildings, BitwiseGameState}; use engine::constants::*; use rand::{Rng, XorShiftRng, SeedableRng}; @@ -115,12 +115,12 @@ fn simulate_to_endstate<R: Rng>(command_score: &mut CommandScore, state: &Bitwis } fn random_player_move<R: Rng>(state: &BitwiseGameState, rng: &mut R) -> Command { - let all_buildings = sensible_buildings(&state.player(), state.player_has_max_teslas()); + let all_buildings = sensible_buildings(&state.player, &state.player_buildings, state.player_has_max_teslas()); random_move(&all_buildings, rng, state.unoccupied_player_cell_count(), |i| state.location_of_unoccupied_player_cell(i)) } fn random_opponent_move<R: Rng>(state: &BitwiseGameState, rng: &mut R) -> Command { - let all_buildings = sensible_buildings(&state.opponent(), state.opponent_has_max_teslas()); + let all_buildings = sensible_buildings(&state.opponent, &state.opponent_buildings, state.opponent_has_max_teslas()); random_move(&all_buildings, 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<CommandScore> { - let all_buildings = sensible_buildings(&state.player(), state.player_has_max_teslas()); + let all_buildings = sensible_buildings(&state.player, &state.player_buildings, state.player_has_max_teslas()); let unoccupied_cells = (0..state.unoccupied_player_cell_count()).map(|i| state.location_of_unoccupied_player_cell(i)); @@ -220,7 +220,7 @@ impl CommandScore { } #[cfg(not(feature = "energy-cutoff"))] -fn sensible_buildings(player: &Player, has_max_teslas: bool) -> Vec<BuildingType> { +fn sensible_buildings(player: &Player, _player_buildings: &PlayerBuildings, has_max_teslas: bool) -> Vec<BuildingType> { let mut result = Vec::with_capacity(4); if DEFENCE_PRICE <= player.energy { @@ -243,9 +243,9 @@ fn sensible_buildings(player: &Player, has_max_teslas: bool) -> Vec<BuildingType //TODO: Heuristic that avoids building the initial energy towers all in the same row? //TODO: Update cutoff to maybe build iron curtains #[cfg(feature = "energy-cutoff")] -fn sensible_buildings(player: &Player, has_max_teslas: bool) -> Vec<BuildingType> { +fn sensible_buildings(player: &Player, player_buildings: &PlayerBuildings, has_max_teslas: bool) -> Vec<BuildingType> { let mut result = Vec::with_capacity(4); - let needs_energy = player.energy_generated <= ENERGY_PRODUCTION_CUTOFF || + let needs_energy = player_buildings.energy_generated() <= ENERGY_PRODUCTION_CUTOFF || player.energy <= ENERGY_STORAGE_CUTOFF; if DEFENCE_PRICE <= player.energy { |