diff options
author | Justin Worthe <justin@worthe-it.co.za> | 2019-05-14 11:12:50 +0200 |
---|---|---|
committer | Justin Worthe <justin@worthe-it.co.za> | 2019-05-14 11:12:50 +0200 |
commit | 56627fa6c913919acef6799c489ba9c5cf25cd0a (patch) | |
tree | 46d00b0f10f0b152bcf982ca87f1397aaf68fa2b /src/strategy.rs | |
parent | dcbd04dfdc6dd6dac88020d3a51f23fa5905c356 (diff) |
Better performance for finding things to shoot at
Diffstat (limited to 'src/strategy.rs')
-rw-r--r-- | src/strategy.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/strategy.rs b/src/strategy.rs index d6f92a6..3506e75 100644 --- a/src/strategy.rs +++ b/src/strategy.rs @@ -217,8 +217,8 @@ fn valid_moves(state: &GameBoard, player_index: usize) -> Vec<Command> { _ => None }) .collect::<Vec<_>>(); - let mut shoots = Direction::all().iter() - .filter(|dir| state.find_target(worm.position, **dir, worm.weapon_range).is_some()) + let mut shoots = state.find_targets(worm.position, worm.weapon_range) + .iter() .map(|d| Command::Shoot(*d)) .collect::<Vec<_>>(); moves.append(&mut shoots); |