fours 0.1.0

Four in a row in your terminal, with three levels of opponent.
Documentation

fours

CI Crates.io Documentation License: MIT Rust 1.88+ Built with ratatui Built with tudi

Four in a row in your terminal, against an opponent you can change mid-game.

A game against the hard opponent

Install

cargo install fours

Play

fours

You are red and you move first. The opponent answers straight away, and the board is drawn a little larger when the window has room for it.

Key What it does
← →, h l Move between columns
1 … 9 Point at a column
⏎, space, ↓, j Place a disc
d Next level, easy again after hard
r Start a new game
q, esc, ctrl-c Leave

Changing the level swaps the opponent and leaves the board alone, so you can finish a game against someone else.

Level How the opponent plays
Easy Places discs anywhere legal.
Medium Takes a win when it has one, avoids handing you one, and plays towards the middle.
Hard Searches ahead with alpha beta pruning and judges what it cannot see the end of.

Options

      --difficulty <name>  Play against easy, medium or hard [default: medium]
      --columns <number>   Columns of the board [default: 7]
      --rows <number>      Rows of the board [default: 6]
      --seed <number>      Seed of the opponent, for a reproducible game
  -h, --help               Show the help text
  -V, --version            Show the version

Minimum supported Rust version

Rust 1.88. Raising it is a breaking change and comes with a minor version bump. The version is checked on every push, next to the test suite on Linux, macOS and Windows.

Contributing

Contributions are welcome!

License

MIT.