From 9bcd0b21484a9ce65b0f4a5a8de305ff3b47c0b2 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 23 Dec 2023 09:18:01 -0700 Subject: [PATCH] [board] Add neighbor and piece modules Add a Direction enum in the neighbor module Add Color and PieceShape enums, and a Piece struct to the piece module --- board/src/lib.rs | 2 ++ board/src/neighbor.rs | 12 ++++++++++++ board/src/piece.rs | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 board/src/neighbor.rs create mode 100644 board/src/piece.rs diff --git a/board/src/lib.rs b/board/src/lib.rs index 17ba31c..722899f 100644 --- a/board/src/lib.rs +++ b/board/src/lib.rs @@ -1,3 +1,5 @@ mod bitboard; +mod neighbor; +mod piece; mod position; mod square; diff --git a/board/src/neighbor.rs b/board/src/neighbor.rs new file mode 100644 index 0000000..65e3264 --- /dev/null +++ b/board/src/neighbor.rs @@ -0,0 +1,12 @@ +// Eryn Wells + +pub enum Direction { + North, + NorthWest, + West, + SouthWest, + South, + SouthEast, + East, + NorthEast, +} diff --git a/board/src/piece.rs b/board/src/piece.rs new file mode 100644 index 0000000..c4752e0 --- /dev/null +++ b/board/src/piece.rs @@ -0,0 +1,34 @@ +// Eryn Wells + +#[derive(Debug, Eq, PartialEq)] +pub enum Color { + White, + Black, +} + +#[derive(Debug, Eq, PartialEq)] +pub enum PieceShape { + Pawn, + Knight, + Bishop, + Rook, + Queen, + King, +} + +#[derive(Debug, Eq, PartialEq)] +pub enum PiecePlacementError { + PieceExistsOnSquare, +} + +#[derive(Debug, Eq, PartialEq)] +pub struct Piece { + pub color: Color, + pub piece: PieceShape, +} + +impl Piece { + pub fn new(color: Color, piece: PieceShape) -> Piece { + Piece { color, piece } + } +}