Implement basic frontend-engine interaction

Use a Flask-based Python server as an adapter to the engine's
stdin-stdout inferface.
This commit is contained in:
2021-12-11 14:58:16 +01:00
parent 57931b29de
commit b5c252bd4d
4 changed files with 80 additions and 38 deletions

View File

@@ -224,15 +224,17 @@ impl Board {
};
}
pub fn new() -> Board {
let mut board = Board {
Board {
state: Default::default(),
};
}
}
pub fn reset(&mut self) {
self.state.clear();
for piece_type in &[PieceType::Pawn] {
for (piece, position) in piece_type.initial_setup() {
board.set_at(position, Some(piece));
self.set_at(position, Some(piece));
}
}
board
}
pub fn iter(&self) -> impl Iterator<Item = (&Position, &Piece)> {
self.state.iter()