diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-19 18:00:11 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-19 18:00:43 +0200 |
commit | c94ece5f5071d4d9fec46daa59db008aa3f6cf32 (patch) | |
tree | 9ca4d621a04d84a7e50b52cdb617ef3fc65646cd /server/bot | |
parent | 3aff746f7960a8372ba4624d214dc1ae39632b36 (diff) | |
download | hurrycurry-c94ece5f5071d4d9fec46daa59db008aa3f6cf32.tar hurrycurry-c94ece5f5071d4d9fec46daa59db008aa3f6cf32.tar.bz2 hurrycurry-c94ece5f5071d4d9fec46daa59db008aa3f6cf32.tar.zst |
untested customer collision
Diffstat (limited to 'server/bot')
-rw-r--r-- | server/bot/src/algos/customer.rs | 19 | ||||
-rw-r--r-- | server/bot/src/pathfinding.rs | 3 |
2 files changed, 22 insertions, 0 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index 6ac4d599..c3d72d49 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -32,6 +32,7 @@ pub enum Customer { path: Path, chair: IVec2, origin: IVec2, + ticks: usize, }, Waiting { demand: DemandIndex, @@ -73,6 +74,7 @@ impl BotAlgo for Customer { path, chair, origin: pos.as_ivec2(), + ticks: 0, }; } } @@ -82,7 +84,10 @@ impl BotAlgo for Customer { path, chair, origin, + ticks, } => { + *ticks += 1; + let check = *ticks % 10 == 0; if path.is_done() { let demand = DemandIndex(random::<u32>() as usize % game.data.demands.len()); info!("{me:?} -> waiting"); @@ -101,6 +106,20 @@ impl BotAlgo for Customer { }], ..Default::default() } + } else if check + && path.remaining_segments() < 5 + && game + .players + .iter() + .find(|(id, p)| { + p.character < 0 + && **id != me + && p.movement.position.distance(chair.as_vec2() + 0.5) < 1. + }) + .is_some() + { + *self = Customer::New; + BotInput::default() } else if path.is_stuck() { if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), *origin) { *self = Customer::Exiting { path }; diff --git a/server/bot/src/pathfinding.rs b/server/bot/src/pathfinding.rs index 593b5900..96d6b37a 100644 --- a/server/bot/src/pathfinding.rs +++ b/server/bot/src/pathfinding.rs @@ -48,6 +48,9 @@ impl Path { pub fn is_stuck(&self) -> bool { self.seg_time > 5. } + pub fn remaining_segments(&self) -> usize { + self.segments.len() + } } pub fn find_path_to_neighbour(walkable: &HashSet<IVec2>, from: IVec2, to: IVec2) -> Option<Path> { |