diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2020-05-17 20:05:33 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2020-05-17 20:05:33 +0200 |
commit | 2f23ab85adb7ffc5866cc948bad0c35a7d41a05b (patch) | |
tree | 27ace87492fbb95fd29694b9e44215a49c879b1a /src | |
parent | d28628822e172cf232e5a86764110870baf6fc39 (diff) |
Only match the good moves
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/state.rs | 2 |
2 files changed, 2 insertions, 2 deletions
@@ -128,7 +128,7 @@ fn shortest_path_first_command(initial_state: &GameState) -> Option<Command> { .zip(shortest_path_states.0.iter().skip(1)) .map(|(state, next)| { let player_move = state - .valid_moves(0) + .good_moves(0) .into_iter() .filter(|player_move| *player_move != Command::UseOil) .find(|player_move| { diff --git a/src/state.rs b/src/state.rs index be42228..acbce80 100644 --- a/src/state.rs +++ b/src/state.rs @@ -231,7 +231,7 @@ impl GameState { pub fn good_moves(&self, player_index: usize) -> Vec<Command> { let player = &self.players[player_index]; - let mut result = Vec::with_capacity(7); + let mut result = Vec::with_capacity(5); result.push(Command::Accelerate); if player.position.y > MIN_Y { result.push(Command::TurnLeft); |