diff options
Diffstat (limited to 'server/bot')
| -rw-r--r-- | server/bot/src/algos/customer.rs | 20 | ||||
| -rw-r--r-- | server/bot/src/algos/dishwasher.rs | 4 | ||||
| -rw-r--r-- | server/bot/src/algos/simple.rs | 4 | ||||
| -rw-r--r-- | server/bot/src/algos/test.rs | 4 | ||||
| -rw-r--r-- | server/bot/src/algos/waiter.rs | 4 | ||||
| -rw-r--r-- | server/bot/src/main.rs | 4 | ||||
| -rw-r--r-- | server/bot/src/pathfinding.rs | 2 |
7 files changed, 21 insertions, 21 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index 17ade544..010ef48a 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -111,16 +111,16 @@ impl CustomerState { .filter(|(_, t)| game.data.tile_name(t.kind) == "chair") .map(|(p, _)| *p) .collect::<Vec<_>>(); - if let Some(&chair) = chairs.get(random::<usize>(..) % chairs.len().max(1)) { - if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), chair) { - debug!("{me:?} -> entering"); - *self = CustomerState::Entering { - path, - chair, - origin: pos.as_ivec2(), - ticks: 0, - }; - } + if let Some(&chair) = chairs.get(random::<usize>(..) % chairs.len().max(1)) + && let Some(path) = find_path(&game.walkable, pos.as_ivec2(), chair) + { + debug!("{me:?} -> entering"); + *self = CustomerState::Entering { + path, + chair, + origin: pos.as_ivec2(), + ticks: 0, + }; } } BotInput::default() diff --git a/server/bot/src/algos/dishwasher.rs b/server/bot/src/algos/dishwasher.rs index cbeedab9..94368558 100644 --- a/server/bot/src/algos/dishwasher.rs +++ b/server/bot/src/algos/dishwasher.rs @@ -16,9 +16,9 @@ */ use super::simple::State; -use crate::{algos::simple::Context, pathfinding::Path, BotAlgo, BotInput}; +use crate::{BotAlgo, BotInput, algos::simple::Context, pathfinding::Path}; use hurrycurry_client_lib::Game; -use hurrycurry_protocol::{glam::IVec2, ItemIndex, PlayerID}; +use hurrycurry_protocol::{ItemIndex, PlayerID, glam::IVec2}; #[derive(Default)] pub struct DishWasher { diff --git a/server/bot/src/algos/simple.rs b/server/bot/src/algos/simple.rs index 914e8809..f8d01b3a 100644 --- a/server/bot/src/algos/simple.rs +++ b/server/bot/src/algos/simple.rs @@ -16,12 +16,12 @@ */ use crate::{ - pathfinding::{find_path_to_neighbour, Path}, BotAlgo, BotInput, + pathfinding::{Path, find_path_to_neighbour}, }; use hurrycurry_client_lib::Game; use hurrycurry_protocol::{ - glam::IVec2, ItemIndex, Message, PlayerID, Recipe, RecipeIndex, TileIndex, + ItemIndex, Message, PlayerID, Recipe, RecipeIndex, TileIndex, glam::IVec2, }; use log::{debug, warn}; diff --git a/server/bot/src/algos/test.rs b/server/bot/src/algos/test.rs index 5ef11553..361cf4ea 100644 --- a/server/bot/src/algos/test.rs +++ b/server/bot/src/algos/test.rs @@ -16,11 +16,11 @@ */ use crate::{ - pathfinding::{find_path_to_neighbour, Path}, BotAlgo, BotInput, + pathfinding::{Path, find_path_to_neighbour}, }; use hurrycurry_client_lib::Game; -use hurrycurry_protocol::{glam::IVec2, ItemIndex, Message, PlayerID}; +use hurrycurry_protocol::{ItemIndex, Message, PlayerID, glam::IVec2}; use log::info; #[derive(Default)] diff --git a/server/bot/src/algos/waiter.rs b/server/bot/src/algos/waiter.rs index bde87f94..8fccd34a 100644 --- a/server/bot/src/algos/waiter.rs +++ b/server/bot/src/algos/waiter.rs @@ -16,9 +16,9 @@ */ use super::simple::State; -use crate::{algos::simple::Context, pathfinding::Path, BotAlgo, BotInput}; +use crate::{BotAlgo, BotInput, algos::simple::Context, pathfinding::Path}; use hurrycurry_client_lib::Game; -use hurrycurry_protocol::{glam::IVec2, ItemIndex, PlayerID}; +use hurrycurry_protocol::{ItemIndex, PlayerID, glam::IVec2}; use log::debug; #[derive(Default)] diff --git a/server/bot/src/main.rs b/server/bot/src/main.rs index b1b8bb84..d2bd10c5 100644 --- a/server/bot/src/main.rs +++ b/server/bot/src/main.rs @@ -17,8 +17,8 @@ */ use anyhow::Result; use clap::Parser; -use hurrycurry_bot::{algos::ALGO_CONSTRUCTORS, BotAlgo, BotInput}; -use hurrycurry_client_lib::{network::sync::Network, Game}; +use hurrycurry_bot::{BotAlgo, BotInput, algos::ALGO_CONSTRUCTORS}; +use hurrycurry_client_lib::{Game, network::sync::Network}; use hurrycurry_protocol::{Character, Hand, PacketC, PacketS, PlayerClass, PlayerID}; use log::warn; use std::{thread::sleep, time::Duration}; diff --git a/server/bot/src/pathfinding.rs b/server/bot/src/pathfinding.rs index 211f1890..41bc79c7 100644 --- a/server/bot/src/pathfinding.rs +++ b/server/bot/src/pathfinding.rs @@ -70,7 +70,7 @@ pub fn find_path(walkable: &HashSet<IVec2>, from: IVec2, to: IVec2) -> Option<Pa struct Open(i32, IVec2, IVec2, i32); impl PartialOrd for Open { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { - Some(self.0.cmp(&other.0)) + Some(self.cmp(other)) } } impl Ord for Open { |