summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin@worthe-it.co.za>2018-05-19 13:14:30 +0200
committerJustin Worthe <justin@worthe-it.co.za>2018-05-19 13:14:30 +0200
commit693d503953e2199cc9a64beda21e4f1d9db9a26e (patch)
tree0b07cbc21e3cbe28307e62c029c1605da7b40c9a /src
parent0f8c247f24c110e542862f8c6e96662ca94c5dae (diff)
Inlined unnecessary map
Diffstat (limited to 'src')
-rw-r--r--src/strategy/monte_carlo.rs24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/strategy/monte_carlo.rs b/src/strategy/monte_carlo.rs
index df84cb7..ab13d87 100644
--- a/src/strategy/monte_carlo.rs
+++ b/src/strategy/monte_carlo.rs
@@ -151,23 +151,17 @@ impl CommandScore {
}
fn init_command_scores(settings: &GameSettings, state: &GameState) -> Vec<CommandScore> {
- enumerate_player_commands(settings, state).iter()
- .map(|&c| CommandScore::new(c))
- .collect()
- }
-}
-
-fn enumerate_player_commands(settings: &GameSettings, state: &GameState) -> Vec<Command> {
- let all_buildings = state.player_affordable_buildings(settings);
+ let all_buildings = state.player_affordable_buildings(settings);
- let mut commands = Vec::with_capacity(state.unoccupied_player_cells.len()*all_buildings.len()+1);
- commands.push(Command::Nothing);
+ let mut commands = Vec::with_capacity(state.unoccupied_player_cells.len()*all_buildings.len()+1);
+ commands.push(CommandScore::new(Command::Nothing));
- for &position in &state.unoccupied_player_cells {
- for &building in &all_buildings {
- commands.push(Command::Build(position, building));
+ for &position in &state.unoccupied_player_cells {
+ for &building in &all_buildings {
+ commands.push(CommandScore::new(Command::Build(position, building)));
+ }
}
- }
- commands
+ commands
+ }
}