diff --git a/engine/src/boardsquare.rs b/engine/src/boardsquare.rs new file mode 100644 index 0000000..b4613fe --- /dev/null +++ b/engine/src/boardsquare.rs @@ -0,0 +1,32 @@ + +pub struct BoardSquare { + pub x: usize, + pub y: usize +} + +impl BoardSquare { + + pub fn new() -> Self { + return Self{ + x: 0, + y: 0 + }; + } + + pub fn from_coord(x: usize, y: usize) -> Self { + + #[cfg(debug_assertions)] + { + if x > 7 { + println!("Warning: x coordinate of square is bigger than 7, it might not be on the board!"); + } + if y > 7 { + println!("Warning: y coordinate of square is bigger than 7, it might not be on the board!"); + } + } + return Self { + x: x, + y: y + }; + } +} \ No newline at end of file diff --git a/engine/src/chessmove.rs b/engine/src/chessmove.rs new file mode 100644 index 0000000..cf92de1 --- /dev/null +++ b/engine/src/chessmove.rs @@ -0,0 +1,71 @@ +use crate::piecetype; + +use super::boardsquare::BoardSquare; +use super::piecetype::PieceType; +use super::movetype::MoveType; + + +pub struct ChessMove { + pub move_type: MoveType, + pub piece_type: PieceType, + pub from_square: BoardSquare, + pub to_square: BoardSquare, + pub rook_from: BoardSquare, + pub rook_to: BoardSquare, + pub promotion_piece: Option +} + +impl ChessMove { + + pub fn quiet( + piece_type: PieceType, + from_square: BoardSquare, + to_square: BoardSquare, + promotion_piece: Option + ) -> Self { + return Self { + move_type: MoveType::Quiet, + piece_type: piece_type, + from_square: from_square, + to_square: to_square, + rook_from: BoardSquare::new(), + rook_to: BoardSquare::new(), + promotion_piece: promotion_piece + } + } + + pub fn capture( + piece_type: PieceType, + from_square: BoardSquare, + to_square: BoardSquare, + promotion_piece: Option + ) -> Self { + return Self { + move_type: MoveType::Capture, + piece_type: piece_type, + from_square: from_square, + to_square: to_square, + rook_from: BoardSquare::new(), + rook_to: BoardSquare::new(), + promotion_piece: promotion_piece + } + } + + pub fn castle( + piece_type: PieceType, + from_square: BoardSquare, + to_square: BoardSquare, + rook_from: BoardSquare, + rook_to: BoardSquare + ) -> Self { + return Self { + move_type: MoveType::Quiet, + piece_type: piece_type, + from_square: from_square, + to_square: to_square, + rook_from: rook_from, + rook_to: rook_to, + promotion_piece: None + } + } +} \ No newline at end of file diff --git a/engine/src/gameend.rs b/engine/src/gameend.rs new file mode 100644 index 0000000..43dd158 --- /dev/null +++ b/engine/src/gameend.rs @@ -0,0 +1,6 @@ + +pub enum GameEnd { + WhiteWon(String), + BlackWon(String), + Draw(String) +} \ No newline at end of file diff --git a/engine/src/lib.rs b/engine/src/lib.rs new file mode 100644 index 0000000..b7bc67b --- /dev/null +++ b/engine/src/lib.rs @@ -0,0 +1,24 @@ +mod bitboard; +pub mod chessmove; +pub mod piecetype; +pub mod boardsquare; +pub mod movetype; +pub mod gameend; + +use chessmove::ChessMove; +use gameend::GameEnd; + +pub fn get_available_moves(fen: &str) -> Vec { + println!("get_available_moves answered"); + return vec![]; +} + +pub fn is_game_over(fen: &str) -> Option { + println!("is_game_over answered"); + return None; +} + +pub fn get_board_after_move(fen: &str, chess_move: &ChessMove) -> String { + println!("get_board_after_move answered"); + return String::from("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); +} \ No newline at end of file diff --git a/engine/src/movetype.rs b/engine/src/movetype.rs new file mode 100644 index 0000000..ec045a5 --- /dev/null +++ b/engine/src/movetype.rs @@ -0,0 +1,7 @@ + +pub enum MoveType { + Quiet, + Capture, + Castle, + EnPassant +} \ No newline at end of file diff --git a/engine/src/piecetype.rs b/engine/src/piecetype.rs new file mode 100644 index 0000000..3eb23f1 --- /dev/null +++ b/engine/src/piecetype.rs @@ -0,0 +1,15 @@ + +pub enum PieceType { + WhitePawn, + WhiteKnight, + WhiteBishop, + WhiteRook, + WhiteQueen, + WhiteKing, + BlackPawn, + BlackKnight, + BlackBishop, + BlackRook, + BlackQueen, + BlackKing +} \ No newline at end of file