diff options
author | metamuffin <metamuffin@disroot.org> | 2024-08-13 19:44:23 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-08-13 19:44:23 +0200 |
commit | f24a9001ef0fafcdbcf20e23eef67f4b71dcf3a5 (patch) | |
tree | fa5a27b29f54acfef803713dc16a3631008df25c /server/bot | |
parent | 3f3c38326128518c653f1b731c28d028c2a45c40 (diff) | |
download | hurrycurry-f24a9001ef0fafcdbcf20e23eef67f4b71dcf3a5.tar hurrycurry-f24a9001ef0fafcdbcf20e23eef67f4b71dcf3a5.tar.bz2 hurrycurry-f24a9001ef0fafcdbcf20e23eef67f4b71dcf3a5.tar.zst |
summonbot command
Diffstat (limited to 'server/bot')
-rw-r--r-- | server/bot/src/algos/mod.rs | 2 | ||||
-rw-r--r-- | server/bot/src/lib.rs | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/server/bot/src/algos/mod.rs b/server/bot/src/algos/mod.rs index d3aba8f4..54cdd495 100644 --- a/server/bot/src/algos/mod.rs +++ b/server/bot/src/algos/mod.rs @@ -25,7 +25,7 @@ pub use simple::Simple; pub use test::Test; pub use waiter::Waiter; -pub const ALGO_CONSTRUCTORS: &'static [(&'static str, fn() -> Box<dyn crate::BotAlgo>)] = &[ +pub const ALGO_CONSTRUCTORS: &'static [(&'static str, fn() -> crate::DynBotAlgo)] = &[ ("test", || Box::new(Test::default())), ("simple", || Box::new(Simple::default())), ("waiter", || Box::new(Waiter::default())), diff --git a/server/bot/src/lib.rs b/server/bot/src/lib.rs index b2334333..ce8ac8f2 100644 --- a/server/bot/src/lib.rs +++ b/server/bot/src/lib.rs @@ -38,3 +38,9 @@ pub type DynBotAlgo = Box<dyn BotAlgo + Send + Sync + 'static>; pub trait BotAlgo { fn tick(&mut self, me: PlayerID, game: &Game, dt: f32) -> BotInput; } + +impl<T: BotAlgo + ?Sized> BotAlgo for Box<T> { + fn tick(&mut self, me: PlayerID, game: &Game, dt: f32) -> BotInput { + (**self).tick(me, game, dt) + } +} |