diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2020-04-10 23:37:15 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2020-04-10 23:37:15 +0200 |
commit | 1cd5247ccbd34bb76ab9d1fe80e67f6319fa000c (patch) | |
tree | 9cc2e8aab32887f86614e795cb98cfa5ea1ff4dd /src/main.rs | |
parent | f3f798441e56afec9e6357c96274f90bf4ea6947 (diff) |
Initial bad strategy
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 74428c3..92b0a1b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,5 +26,22 @@ fn main() { } fn choose_command(state: &GameState) -> Command { - Command::Accelerate + let player_moves = state.valid_moves(0); + let naive_result = player_moves + .into_iter() + .map(|player_move| { + let mut state = state.clone(); + state.update([player_move, Command::Nothing]); + (player_move, state) + }) + .max_by(|(_, state_1), (_, state_2)| { + state_1.players[0] + .position + .x + .cmp(&state_2.players[0].position.x) + .then(state_1.players[0].speed.cmp(&state_2.players[0].speed)) + }) + .unwrap() + .0; + naive_result } |