#chess #pacifist-chess #chess-simulation

app pacifist-chess-simulation

Have you ever wondered what a game of chess would look like if it were played by two pacifists?

3 releases

0.1.2 Jun 13, 2022
0.1.1 Jun 7, 2022
0.1.0 Jun 7, 2022

#89 in Games

MIT license

352 lines

Pacifist Chess Simulation

🙃 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.

Player modes

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.

  • Pacifist - Whenever possible, choose non-capture moves! But do prioritize non-capture checkmate turns! The only reason capture move could be played is if there is no other possible move to be played - such scenario happens more often when king is in check.
  • Aggressive - Always prefer capture/check turns. Only the checkmate turn has a higher priorty.
  • SemiPacifist - Pacifist mode where pawns are allowed to capture other pawns. We can call it promotion party mode.
  • Random - Turn is decided completely randomly from the pool of all available turns.

Pacifist player vs Pacifist player

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).

Pacifist player vs Aggressive player

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.

Aggressive player vs Aggressive player

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.

SemiPacifist player vs SemiPacifist player

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.

Random player vs Random player

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. 🙃

How to run

# 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
    pacifist-chess-simulation [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]


~108K SLoC