2 releases
| 0.1.1 | Jan 13, 2024 |
|---|---|
| 0.1.0 | Jan 13, 2024 |
#1314 in Math
24KB
573 lines
Fenx Chess Library (Unfinished)
Fenx is a Rust library for handling chess game logic. It provides support for parsing Forsyth-Edwards Notation (FEN) strings, handling chess moves in algebraic notation, and more.
Features
Fen Module
The Fen module provides the Fen struct for representing a chess position in Forsyth-Edwards Notation (FEN).
Fen Struct
-
Constructor:
Fen::new(board: &str) -> Fen- Creates a new
Fenstruct from a given board position string.
- Creates a new
-
Parser:
Fen::parse_fen(fen_str: &str) -> Result<Fen, &'static str>- Parses a FEN string into a
Fenstruct.
- Parses a FEN string into a
-
Debug Printing:
Fen::debug()- Prints the values inside the
Fenstruct for debugging purposes.
- Prints the values inside the
-
Board Printing:
Fen::print_to_board()- Prints the chess board to the console.
-
Board Conversion:
Fen::boardify() -> String- Converts the
Fenstruct into a string representation of a chess board.
- Converts the
Coordinates Module
The Coordinates module provides the Coordinates struct for representing a position on the chess board.
Coordinates Struct
-
Constructor:
Coordinates { x: i8, y: i8 }- Creates a new
Coordinatesstruct with given x and y values.
- Creates a new
-
From Notation:
Coordinates::from_notation(notation: Notation) -> Result<Coordinates, &'static str>- Converts a
Notationstruct into aCoordinatesstruct.
- Converts a
-
To Notation:
Coordinates::to_notation(&self) -> Result<Notation, &'static str>- Converts the
Coordinatesstruct into aNotationstruct.
- Converts the
Notation Module
The Notation module provides the Notation struct for representing a chess move in algebraic notation.
Notation Struct
-
Constructor:
Notation::new(file: char, rank: char) -> Option<Notation>- Creates a new
Notationstruct with given file and rank values.
- Creates a new
-
From Coordinates:
Notation::from_coordinates(coordinates: Coordinates) -> Result<Notation, &'static str>- Converts a
Coordinatesstruct into aNotationstruct.
- Converts a
-
To Coordinates:
Notation::to_coordinates(&self) -> Result<Coordinates, &'static str>- Converts the
Notationstruct into aCoordinatesstruct.
- Converts the
Contribution
Contributions to Fenix are welcome! Please ensure your code is formatted with cargo fmt before creating a pull request.