start to write Breakthrough
This commit is contained in:
1 parent
18d6a96b0d
commit
e27482082b
8 files changed
+158
-15
No files matched your search
@@ -0,0 +1,57 @@
|
||||
use std::collections::HashMap;
|
||||
use super::*;
|
||||
|
||||
pub const WHITE_WON_ZONE: u64 = 0xff;
|
||||
pub const BLACK_WON_ZONE: u64 = 0xff << 56;
|
||||
|
||||
struct Breakthrough{
|
||||
board: Board<1>,
|
||||
side: Color,
|
||||
legal_moves: Option<HashMap<Move, MaskPatch>>,
|
||||
}
|
||||
|
||||
impl Breakthrough {
|
||||
fn generate_legal(&self) -> HashMap<Move, MaskPatch>{
|
||||
todo!();
|
||||
HashMap::new()
|
||||
}
|
||||
|
||||
pub fn refresh_legal_moves(&mut self) {
|
||||
self.legal_moves = Some(self.generate_legal());
|
||||
}
|
||||
}
|
||||
|
||||
impl ChessEngine for Breakthrough {
|
||||
fn legal_moves(&self) -> Vec<Move> {
|
||||
self.legal_moves.clone().unwrap().keys().cloned().collect()/*.expect("cache empty; call refresh first")*/
|
||||
}
|
||||
|
||||
fn apply(&mut self, mv: Move) -> Result<(), MoveErrors> {
|
||||
if let Some(ref h) = self.legal_moves {
|
||||
todo!();
|
||||
} else {
|
||||
Err(MoveErrors::NoMove)
|
||||
}
|
||||
}
|
||||
|
||||
fn status(&self) -> GameStatus {
|
||||
if self.board.is_mask_zero(0, 0) {
|
||||
return GameStatus::Won(Color::White);
|
||||
}
|
||||
if self.board.is_mask_zero(0, 1) {
|
||||
return GameStatus::Won(Color::Black);
|
||||
}
|
||||
if !self.board.and_mask_is_zero(0, 1, WHITE_WON_ZONE){
|
||||
return GameStatus::Won(Color::White);
|
||||
}
|
||||
if !self.board.and_mask_is_zero(0, 0, BLACK_WON_ZONE){
|
||||
return GameStatus::Won(Color::Black);
|
||||
}
|
||||
|
||||
GameStatus::Ongoing
|
||||
}
|
||||
|
||||
fn side_to_move(&self) -> Color{
|
||||
self.side
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
use super::*;
|
||||
|
||||
mod breakthrough;
|
||||
Reference in new issue
Block a user