This project implements a Knights Tour simulation using Rust and SDL2. The goal of the simulation is to move a knight around a chessboard, touching each square exactly once.
- Displays an 8x8 chessboard
- Moves the knight to each square on the board exactly once
- Shows the current state of the tour and indicates when the tour is complete
- Allows users to restart the tour by pressing
Enter
- Rust
- SDL2
- SDL2_ttf
- Ensure you have Rust installed. If not, you can install it from rust-lang.org.
- Install SDL2 and SDL2_ttf on your system. For installation instructions, refer to SDL2 Installation Guide.
- Clone this repository:
git clone https://github.com/lostjared/Knights_Tour.git
cd Knights_Tour/knights_tour
- Build the project using Cargo:
cargo build --release
- Run the executable:
cargo run --release
- Press
Space
to move the knight to the next position. - Press
Enter
to restart the tour. - Press
Escape
to exit the simulation.
- Position: Represents the knight's position on the board.
- drawboard: Draws the chessboard on the SDL2 canvas.
- drawknight: Draws the knight at its current position on the board.
- clearboard: Clears the board for a new tour.
- nextmove: Calculates the knight's next move using Warnsdorff's rule.
data/font.ttf
: The font used for rendering text.data/knight.bmp
: The knight image used for the simulation.
If you would like to contribute to this project, please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
This project uses the following libraries and resources: