Initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
pub mod position;
|
||||
pub mod piece;
|
||||
mod square;
|
||||
@@ -0,0 +1,13 @@
|
||||
pub enum PieceVariant {
|
||||
King,
|
||||
Queen,
|
||||
Rook,
|
||||
Bishop,
|
||||
Knight,
|
||||
Pawn
|
||||
}
|
||||
|
||||
pub struct Piece {
|
||||
pub white: bool,
|
||||
pub variant: PieceVariant
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
pub struct Square {
|
||||
x: u8,
|
||||
y: u8,
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
use chess::position::Position;
|
||||
|
||||
mod chess;
|
||||
|
||||
|
||||
fn main() {
|
||||
let mut position = Position::new();
|
||||
}
|
||||
Reference in New Issue
Block a user