From 693d503953e2199cc9a64beda21e4f1d9db9a26e Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Sat, 19 May 2018 13:14:30 +0200 Subject: Inlined unnecessary map --- src/strategy/monte_carlo.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src') 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 { - enumerate_player_commands(settings, state).iter() - .map(|&c| CommandScore::new(c)) - .collect() - } -} - -fn enumerate_player_commands(settings: &GameSettings, state: &GameState) -> Vec { - 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 + } } -- cgit v1.2.3