A simple chess system written in Rust. The project is still in work in progress, you can find the missing features below. (See TODO)
The system can be controller through the game controller function. It takes two inputs Position 1 and Position 2. At Position 1 we should find a valid Unit, which we want to move to Position 2 to the Target Position. Then the controller evaluates the Unit's Type and the Target Position and mutates the board based on the results.
For user-friendly usability we can produce Positions from Chess Notations.
For example, the .to function produces a vector, which contains all the Positions between two Positions excluding the starting and ending Positions.
To validate a Step we are using basic math, where we substract the Unit's Position from the Target's Position. Furthermore there are additional conditions to each Step. The whole Step System is build around the Type State Pattern, which in my mind really fits the process. (Or maybe I just really wanted to try my hands on this pattern.)
There are 3 different States to a Step.
ConditionState
- Where we can add Conditions like Unit is not a King at Position or Unit is an Enemy at Position.
- We can also add Actions like Move/Remove. This can be usefull for special cases like En passant or Castling, where we want to do more than one thing.
ResultState
- This state holds information about the evaluation process.
- In the ResultState we can execute the Actions.
ImageState
- This State holds information about the former state of the board, so we can reconstruct the old state if necessary.
The pictures below show the calculations for each unit.
Currently there are two examples to test out the system, one of them is using eGUI and the other one is using notan. Right now I'm more focused on notan, which I can gladly recommend to anyone, who wants to quickly implement and test out things in Rust.
cargo run --example app_notan
or
cargo run --example app_egui --features egui
List of missing features and future plans.
- CheckMate / StaleMate