Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of monster-chess #8

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/devcontainers/features/rust:1": {}
}
}
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.3"

# temporary fix until https://github.com/jordanbray/chess/pull/67 is merged
[profile.dev.build-override]
Expand Down
1 change: 1 addition & 0 deletions src/games/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
54 changes: 54 additions & 0 deletions src/games/monster_chess.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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<const T: usize> BoardSymmetry<MonsterBoard<'static, T>> for MonsterBoard<'static, T> {
type Symmetry = UnitSymmetry;
type CanonicalKey = ();

fn map(&self, _: Self::Symmetry) -> Self {
self.clone()
}

fn map_move(
&self,
_: Self::Symmetry,
mv: <MonsterBoard<'static, T> as Board>::Move,
) -> <MonsterBoard<'static, T> as Board>::Move {
mv
}

fn canonical_key(&self) -> Self::CanonicalKey {}
}

impl<'a, const T: usize> BoardMoves<'a, MonsterBoard<'static, T>> for MonsterBoard<'static, T> {
type AllMovesIterator = dyn Iterator<Item = Action>;
type AvailableMovesIterator = dyn Iterator<Item = Action>;

fn all_possible_moves() {

}

fn available_moves(&self) -> Result<Self::AvailableMovesIterator, crate::board::BoardDone> {
self.0.generate_legal_moves(0)
}
}

impl<'a, const T: usize> Board for MonsterBoard<'static, T> {

}