Crates.io | pacifist-chess-simulation |
lib.rs | pacifist-chess-simulation |
version | 0.1.2 |
source | src |
created_at | 2022-06-07 20:44:54.354467 |
updated_at | 2022-06-13 07:44:45.416693 |
description | Have you ever wondered what a game of chess would look like if it were played by two pacifists? |
homepage | |
repository | https://github.com/Rqnsom/pacifist-chess-simulation |
max_upload_size | |
id | 601695 |
size | 6,109,203 |
🙃 Living person 1
: Have you ever wondered what a game of chess would look like if it were played by two pacifists?
😐 Living person 2
: What?
🙃 Living person 1
: Exactly!
💀 Person 3
: 💀
😐 Living person 2
: Does that make any sense?
🙃 Living person 1
: Well, yes! It's probably fun! Or... mostly boring! Please check out these animations below.
Simulation actually supports four AI modes. Although AI is not the right word here, since there is no smart logic implemented. It's all random! But with a few small factors taken in mind. We can call it RandomAI, if you like.
In the first game below, the black player wins with Qb3#
.
In the second game below, the game ends in a draw (50 move rule).
We can assume such a game will not last very long.
In the example below, the aggressive player was black, and it won the game in 18 moves.
Two random AI players that both prefer capture turns? Would such a game end quickly? What would be the outcome?
Well. Unfortunately, most games with aggressive players end up with a draw. Too aggressive and too dumb to be able to win the game more often.
This mode has some quite interesting stats!
Example #1
: The black player wins with Qg3#
on the 123rd move.
Example #2
: The white player wins with b8=Q#
on the 107th move.
Two fully random players have the most randomized results. Which kind of makes sense.
Example #1
: On the 111th move, this game ends in a stalemate.
Example #2
: The white player wins with Qa7#
on the 93th move.
This is how I decided to practice my Rust skills. This small experiment was done for, well, mostly fun... I believe! So enjoy these silly statistics and have fun!
These two Rust crates below were created just for this project, but now could be reused for something more useful. Less absurd.
But why didn't you use any existing chess tools or libraries for this funny project?
That was not the point! The fastest route is not always the best one. The main goal was to learn Rust! And doing the whole chess thing from scratch was an interesting challenge and a jolly adventure. 🙃
# Build
cargo build --release # Find binary in target/release directory
# Running tests
cargo test
cargo clippy
Snippet from the help usage text:
√ ~/pacifist-chess-simulation/target/release (main) $ ./pacifist-chess-simulation --help
USAGE:
pacifist-chess-simulation [OPTIONS]
OPTIONS:
-b, --player-black <PLAYER_BLACK>
White player mode: Random/Pacifist/Aggressive/SemiPacifist [default: Pacifist]
-t, --animation-frame-duration <ANIMATION_FRAME_DURATION>
Animation frame duration in microseconds (animation lasts 20 frames) [default: 50000]
-w, --player-white <PLAYER_WHITE>
White player mode: Random/Pacifist/Aggressive/SemiPacifist [default: Pacifist]
[...]