From 6f5064a308b8c71d7b6076d273b7d704d2af800e Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Sun, 19 May 2024 22:14:39 -0700 Subject: [PATCH] Initial pass at bogo AI Not fully wired up. Need to figure out how to gate the pass-n-play based on the state and only change the state when in human mode. When in AI mode, just let the AI pick a piece and move without the camera changing. --- src/ai.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 2 ++ src/prelude.rs | 2 +- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/ai.rs diff --git a/src/ai.rs b/src/ai.rs new file mode 100644 index 0000000..9a66638 --- /dev/null +++ b/src/ai.rs @@ -0,0 +1,50 @@ +use crate::prelude::*; + +pub(crate) struct AiPlugin; + +impl Plugin for AiPlugin { + fn build(&self, app: &mut App) { + app.init_state::() + // Bogo AI Systems + .add_systems(Update, + bogo_ai.run_if(in_state(PlayState::AiBogo)) + ); + } +} + +#[derive(Debug, States, Hash, Default, PartialEq, Eq, Clone)] +enum PlayState { + #[default] + Human, + AiBogo, +} + +// Bogo AI logic +fn bogo_ai( + mut board: ResMut, + mut move_events: EventWriter, + time: Res