/*
Hurry Curry! - a game about cooking
Copyright (C) 2025 Hurry Curry! Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License only.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
#![feature(random)]
pub mod algos;
pub mod pathfinding;
pub mod step;
use hurrycurry_game_core::Game;
use hurrycurry_protocol::PacketS;
#[cfg(feature = "debug_events")]
use hurrycurry_protocol::{PlayerID, glam::Vec3};
use std::{collections::VecDeque, random::random};
pub struct PacketSink<'a> {
buf: &'a mut VecDeque,
}
impl<'a> PacketSink<'a> {
pub fn new(buf: &'a mut VecDeque) -> Self {
Self { buf }
}
pub fn push(&mut self, p: PacketS) {
self.buf.push_back(p);
}
}
pub type DynBotAlgo = Box;
pub trait BotAlgo {
fn tick(&mut self, out: PacketSink, game: &Game, dt: f32);
fn is_finished(&self) -> bool {
false
}
}
impl BotAlgo for Box {
fn tick(&mut self, out: PacketSink, game: &Game, dt: f32) {
(**self).tick(out, game, dt)
}
fn is_finished(&self) -> bool {
(**self).is_finished()
}
}
fn random_float() -> f32 {
random::(..) as f32 / u32::MAX as f32
}
#[cfg(feature = "debug_events")]
fn debug_player_color(d: PlayerID) -> Vec3 {
use std::f32::consts::TAU;
Vec3::new(
(d.0 as f32 + TAU / 3. * 0.).sin(),
(d.0 as f32 + TAU / 3. * 1.).sin(),
(d.0 as f32 + TAU / 3. * 2.).sin(),
)
}