From e72bbb9d115acfe28c4673c03cf2aa97f892b8cc Mon Sep 17 00:00:00 2001 From: Corman <32941017+Cormanz@users.noreply.github.com> Date: Thu, 16 Mar 2023 10:30:19 -0400 Subject: [PATCH 1/3] Create .devcontainer/devcontainer.json --- .devcontainer/devcontainer.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d864174 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,6 @@ +{ + "image": "mcr.microsoft.com/devcontainers/universal:2", + "features": { + "ghcr.io/devcontainers/features/rust:1": {} + } +} From 5a02101678f741430553958aab6211f39dfea3bd Mon Sep 17 00:00:00 2001 From: Corman <32941017+Cormanz@users.noreply.github.com> Date: Thu, 16 Mar 2023 17:04:23 +0000 Subject: [PATCH 2/3] Demo Commit of monster_chess --- Cargo.toml | 1 + src/games/mod.rs | 1 + src/games/monster_chess.rs | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 src/games/monster_chess.rs diff --git a/Cargo.toml b/Cargo.toml index fd60ba6..fbd0118 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ rayon = "1.5.2" chess = "3.2.0" arimaa_engine_step = { version = "1.0.1" } # , path = "../arimaa-engine-step" once_cell = "1.12.0" +monster_chess = "0.0.1" # temporary fix until https://github.com/jordanbray/chess/pull/67 is merged [profile.dev.build-override] diff --git a/src/games/mod.rs b/src/games/mod.rs index 58b5e86..58e2d13 100644 --- a/src/games/mod.rs +++ b/src/games/mod.rs @@ -5,6 +5,7 @@ pub mod connect4; pub mod oware; pub mod sttt; pub mod ttt; +pub mod monster_chess; pub mod dummy; pub mod max_length; diff --git a/src/games/monster_chess.rs b/src/games/monster_chess.rs new file mode 100644 index 0000000..a6835d7 --- /dev/null +++ b/src/games/monster_chess.rs @@ -0,0 +1,38 @@ +use monster_chess::board::Board as NativeBoard; + +use crate::{board::{Board, Player, BoardMoves, BoardSymmetry}, impl_unit_symmetry_board, symmetry::UnitSymmetry}; + +pub struct MonsterBoard<'a, const T: usize>(pub NativeBoard<'a, T>); + +// Couldn't use the `impl_unit_symmetry_board` because of MonsterBoard's generics. +impl<'a, const T: usize> BoardSymmetry> for MonsterBoard<'a, T> { + type Symmetry = UnitSymmetry; + type CanonicalKey = (); + + fn map(&self, _: Self::Symmetry) -> Self { + self.clone() + } + + fn map_move( + &self, + _: Self::Symmetry, + mv: as Board>::Move, + ) -> as Board>::Move { + mv + } + + fn canonical_key(&self) -> Self::CanonicalKey {} +} + +impl<'a, const T: usize> BoardMoves<'a, MonsterBoard<'a, T>> for MonsterBoard<'a, T> { + +} + +impl<'a, const T: usize> Board for MonsterBoard<'a, T> { + fn next_player(&self) -> Player { + match self.0.state.moving_team { + 0 => Player::A, + 1 => Player::B + } + } +} \ No newline at end of file From 8b91b2c88ac04fda4ea60a7b681b170558048a27 Mon Sep 17 00:00:00 2001 From: Cormanz Date: Thu, 16 Mar 2023 23:36:28 -0400 Subject: [PATCH 3/3] Implement Basic Layout of BoardMoves --- Cargo.toml | 2 +- src/games/monster_chess.rs | 42 ++++++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ae0f1e..3056fca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ rayon = "1.5.2" chess = "3.2.0" arimaa_engine_step = { version = "1.0.1" } # , path = "../arimaa-engine-step" once_cell = "1.12.0" -monster_chess = "0.0.1" +monster_chess = "0.0.3" # temporary fix until https://github.com/jordanbray/chess/pull/67 is merged [profile.dev.build-override] diff --git a/src/games/monster_chess.rs b/src/games/monster_chess.rs index a6835d7..8153045 100644 --- a/src/games/monster_chess.rs +++ b/src/games/monster_chess.rs @@ -1,11 +1,23 @@ -use monster_chess::board::Board as NativeBoard; +use internal_iterator::InternalIterator; +use monster_chess::board::{Board as NativeBoard, actions::Action}; +use std::fmt; +use std::fmt::Display; +use std::slice::Iter; use crate::{board::{Board, Player, BoardMoves, BoardSymmetry}, impl_unit_symmetry_board, symmetry::UnitSymmetry}; +#[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct MonsterBoard<'a, const T: usize>(pub NativeBoard<'a, T>); +impl<'a, const T: usize> Display for MonsterBoard<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // Use `self.number` to refer to each positional data point. + write!(f, "{}", self.0); + } +} + // Couldn't use the `impl_unit_symmetry_board` because of MonsterBoard's generics. -impl<'a, const T: usize> BoardSymmetry> for MonsterBoard<'a, T> { +impl BoardSymmetry> for MonsterBoard<'static, T> { type Symmetry = UnitSymmetry; type CanonicalKey = (); @@ -16,23 +28,27 @@ impl<'a, const T: usize> BoardSymmetry> for MonsterBoard<'a, fn map_move( &self, _: Self::Symmetry, - mv: as Board>::Move, - ) -> as Board>::Move { + mv: as Board>::Move, + ) -> as Board>::Move { mv } fn canonical_key(&self) -> Self::CanonicalKey {} } -impl<'a, const T: usize> BoardMoves<'a, MonsterBoard<'a, T>> for MonsterBoard<'a, T> { - -} +impl<'a, const T: usize> BoardMoves<'a, MonsterBoard<'static, T>> for MonsterBoard<'static, T> { + type AllMovesIterator = dyn Iterator; + type AvailableMovesIterator = dyn Iterator; -impl<'a, const T: usize> Board for MonsterBoard<'a, T> { - fn next_player(&self) -> Player { - match self.0.state.moving_team { - 0 => Player::A, - 1 => Player::B - } + fn all_possible_moves() { + } + + fn available_moves(&self) -> Result { + self.0.generate_legal_moves(0) + } +} + +impl<'a, const T: usize> Board for MonsterBoard<'static, T> { + } \ No newline at end of file