diff options
Diffstat (limited to 'server/bot/src/algos')
-rw-r--r-- | server/bot/src/algos/customer.rs | 12 | ||||
-rw-r--r-- | server/bot/src/algos/simple.rs | 2 | ||||
-rw-r--r-- | server/bot/src/algos/test.rs | 4 | ||||
-rw-r--r-- | server/bot/src/algos/waiter.rs | 2 |
4 files changed, 12 insertions, 8 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index 556f5ce5..9c0ce210 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -58,7 +58,6 @@ impl Default for Customer { impl BotAlgo for Customer { fn tick(&mut self, me: PlayerID, game: &Game, dt: f32) -> BotInput { - let _ = (me, game, dt); let Some(playerdata) = game.players.get(&me) else { return BotInput::default(); }; @@ -106,9 +105,14 @@ impl BotAlgo for Customer { }], ..Default::default() } + } else if path.is_stuck() { + if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), *origin) { + *self = Customer::Exiting { path }; + } + BotInput::default() } else { BotInput { - direction: path.next_direction(pos) * 0.5, + direction: path.next_direction(pos, dt) * 0.5, ..Default::default() } } @@ -252,7 +256,7 @@ impl BotAlgo for Customer { } } Customer::Exiting { path } => { - if path.is_done() { + if path.is_done() || path.is_stuck() { info!("{me:?} -> leave"); BotInput { leave: true, @@ -260,7 +264,7 @@ impl BotAlgo for Customer { } } else { BotInput { - direction: path.next_direction(pos) * 0.5, + direction: path.next_direction(pos, dt) * 0.5, ..Default::default() } } diff --git a/server/bot/src/algos/simple.rs b/server/bot/src/algos/simple.rs index 6092e772..1be2cddc 100644 --- a/server/bot/src/algos/simple.rs +++ b/server/bot/src/algos/simple.rs @@ -54,7 +54,7 @@ impl BotAlgo for Simple { } if let Some((path, target, down)) = &mut self.path { - let direction = path.next_direction(pos); + let direction = path.next_direction(pos, dt); let arrived = path.is_done(); let target = *target; if arrived { diff --git a/server/bot/src/algos/test.rs b/server/bot/src/algos/test.rs index dee4cb88..a47befa9 100644 --- a/server/bot/src/algos/test.rs +++ b/server/bot/src/algos/test.rs @@ -29,14 +29,14 @@ pub struct Test { } impl BotAlgo for Test { - fn tick(&mut self, me: PlayerID, game: &Game, _dt: f32) -> BotInput { + fn tick(&mut self, me: PlayerID, game: &Game, dt: f32) -> BotInput { let Some(player) = game.players.get(&me) else { return BotInput::default(); }; let pos = player.movement.position; if let Some(path) = &mut self.path { - let direction = path.next_direction(pos); + let direction = path.next_direction(pos, dt); return BotInput { direction, boost: false, diff --git a/server/bot/src/algos/waiter.rs b/server/bot/src/algos/waiter.rs index ced3097b..adeded23 100644 --- a/server/bot/src/algos/waiter.rs +++ b/server/bot/src/algos/waiter.rs @@ -42,7 +42,7 @@ impl BotAlgo for Waiter { } if let Some((path, target, down)) = &mut self.path { - let direction = path.next_direction(pos); + let direction = path.next_direction(pos, dt); let arrived = path.is_done(); let target = *target; if arrived { |