From bfbdc52e04a96f222487fd03a248acc6f59ef347 Mon Sep 17 00:00:00 2001 From: fabolous005 Date: Tue, 2 Apr 2024 13:48:40 +0200 Subject: [PATCH] Initial commit --- Cargo.toml | 8 ++++++++ src/chess/mod.rs | 3 +++ src/chess/piece.rs | 13 ++++++++++++ src/chess/position.rs | 48 +++++++++++++++++++++++++++++++++++++++++++ src/chess/square.rs | 4 ++++ src/main.rs | 8 ++++++++ 6 files changed, 84 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/chess/mod.rs create mode 100644 src/chess/piece.rs create mode 100644 src/chess/position.rs create mode 100644 src/chess/square.rs create mode 100644 src/main.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..ac26632 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "saltfish" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/chess/mod.rs b/src/chess/mod.rs new file mode 100644 index 0000000..92cdf3c --- /dev/null +++ b/src/chess/mod.rs @@ -0,0 +1,3 @@ +pub mod position; +pub mod piece; +mod square; diff --git a/src/chess/piece.rs b/src/chess/piece.rs new file mode 100644 index 0000000..2256de2 --- /dev/null +++ b/src/chess/piece.rs @@ -0,0 +1,13 @@ +pub enum PieceVariant { + King, + Queen, + Rook, + Bishop, + Knight, + Pawn +} + +pub struct Piece { + pub white: bool, + pub variant: PieceVariant +} diff --git a/src/chess/position.rs b/src/chess/position.rs new file mode 100644 index 0000000..5ad807d --- /dev/null +++ b/src/chess/position.rs @@ -0,0 +1,48 @@ +use crate::chess::piece::Piece; +use crate::chess::square::Square; + + +pub struct Castling { + pub king_side: bool, + pub queen_side: bool, +} + +pub struct Position { + pub rows: [[Option; 8]; 8], + pub whites_turn: bool, + pub castling: [Castling; 2], + pub en_pessant: Option +} + +impl Default for Position { + fn default() -> Self { + Position { + rows: [ + [None, None, None, None, None, None, None, None], + [None, None, None, None, None, None, None, None], + [None, None, None, None, None, None, None, None], + [None, None, None, None, None, None, None, None], + [None, None, None, None, None, None, None, None], + [None, None, None, None, None, None, None, None], + [None, None, None, None, None, None, None, None], + [None, None, None, None, None, None, None, None], + ], + whites_turn: true, + castling: [ + Castling { king_side: false, queen_side: false }, + Castling { king_side: false, queen_side: false }, + ], + en_pessant: None + } + } +} + +impl Position { + pub fn new() -> Self { + Position::default() + } + + pub fn from_fen(fen: String) -> Self { + todo!("Implement this function") + } +} diff --git a/src/chess/square.rs b/src/chess/square.rs new file mode 100644 index 0000000..019cf76 --- /dev/null +++ b/src/chess/square.rs @@ -0,0 +1,4 @@ +pub struct Square { + x: u8, + y: u8, +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..0e09b75 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,8 @@ +use chess::position::Position; + +mod chess; + + +fn main() { + let mut position = Position::new(); +}