Initial commit

This commit is contained in:
fabolous005 2024-04-02 13:48:40 +02:00
parent 4e640d4796
commit bfbdc52e04
6 changed files with 84 additions and 0 deletions

8
Cargo.toml Normal file
View File

@ -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]

3
src/chess/mod.rs Normal file
View File

@ -0,0 +1,3 @@
pub mod position;
pub mod piece;
mod square;

13
src/chess/piece.rs Normal file
View File

@ -0,0 +1,13 @@
pub enum PieceVariant {
King,
Queen,
Rook,
Bishop,
Knight,
Pawn
}
pub struct Piece {
pub white: bool,
pub variant: PieceVariant
}

48
src/chess/position.rs Normal file
View File

@ -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<Piece>; 8]; 8],
pub whites_turn: bool,
pub castling: [Castling; 2],
pub en_pessant: Option<Square>
}
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")
}
}

4
src/chess/square.rs Normal file
View File

@ -0,0 +1,4 @@
pub struct Square {
x: u8,
y: u8,
}

8
src/main.rs Normal file
View File

@ -0,0 +1,8 @@
use chess::position::Position;
mod chess;
fn main() {
let mut position = Position::new();
}