aboutsummaryrefslogtreecommitdiff
path: root/server/bot/src/algos/customer.rs
diff options
context:
space:
mode:
authornokoe <nokoe@mailbox.org>2026-02-26 05:15:54 +0100
committernokoe <nokoe@mailbox.org>2026-02-27 19:31:14 +0100
commita859bceeddc8e746bba630b3cc197532b68adbcb (patch)
treef8e033595d21e4de34774e4caed8b483c7eba5c6 /server/bot/src/algos/customer.rs
parent6419d8c8139d697af309b7db2e698effa8290582 (diff)
downloadhurrycurry-a859bceeddc8e746bba630b3cc197532b68adbcb.tar
hurrycurry-a859bceeddc8e746bba630b3cc197532b68adbcb.tar.bz2
hurrycurry-a859bceeddc8e746bba630b3cc197532b68adbcb.tar.zst
use stable rust toolchainstable-rust
Diffstat (limited to 'server/bot/src/algos/customer.rs')
-rw-r--r--server/bot/src/algos/customer.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs
index fe665f47..ba4d43a8 100644
--- a/server/bot/src/algos/customer.rs
+++ b/server/bot/src/algos/customer.rs
@@ -17,8 +17,7 @@
*/
use crate::{
BotAlgo, PacketSink,
- pathfinding::{Path, find_path},
- random_float,
+ pathfinding::{Path, find_path}, random_usize,
};
use hurrycurry_game_core::Game;
use hurrycurry_protocol::{
@@ -26,7 +25,7 @@ use hurrycurry_protocol::{
glam::{IVec2, Vec2},
};
use log::debug;
-use std::random::random;
+use rand::{random, seq::IndexedRandom};
#[derive(Debug, Clone)]
pub struct Customer {
@@ -107,7 +106,7 @@ 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(&chair) = chairs.choose(&mut rand::rng())
&& let Some(path) = find_path(game, pos.as_ivec2(), chair)
{
debug!("{me:?} -> entering");
@@ -129,10 +128,10 @@ impl CustomerState {
*ticks += 1;
let check = *ticks % 10 == 0;
if path.is_done() {
- let demand = DemandIndex(random::<usize>(..) % game.data.demands.len());
+ let demand = DemandIndex(random_usize(&mut rand::rng()) % game.data.demands.len());
let requested_item = game.data.demands[demand.0].input;
debug!("{me:?} -> waiting");
- let timeout = 90. + random_float() * 60.;
+ let timeout = 90. + random::<f32>() * 60.;
let mut facing = Vec2::ZERO;
for off in [IVec2::NEG_X, IVec2::NEG_Y, IVec2::X, IVec2::Y] {
if game.tiles.get(&(off + *chair)).is_some_and(|t| {