Skip to main content

No project description provided

Project description

cligames

Board games in your terminal

  • Connect4 and Tic-tac-toe with a text-based interface.
  • Playable computer opponent, implemented using the minimax algorithm (with alpha–beta pruning).
  • Each board game can be played as human versus human, human versus computer or computer versus computer.

Setup

Install via pip

$ pip install cligames

Build from source

$ git clone https://github.com/tombch/cligames.git
$ cd cligames/
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install .

How to play

Connect4

To start a game of Connect4 against the computer, enter:

$ cligames connect4
A new game has started.
┌───┬───┬───┬───┬───┬───┬───┐
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │
└───┴───┴───┴───┴───┴───┴───┘
Player X - choose a move: 

To make a move, enter the column number you wish to make a move in:

Player X - choose a move: 3   
┌───┬───┬───┬───┬───┬───┬───┐
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │ X │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │
└───┴───┴───┴───┴───┴───┴───┘
Player X chose move 3.
Decision time: 2.556 seconds
Player O is choosing... 
┌───┬───┬───┬───┬───┬───┬───┐
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │   │   │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│   │   │ O │ X │   │   │   │
├───┼───┼───┼───┼───┼───┼───┤
│ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │
└───┴───┴───┴───┴───┴───┴───┘
Player O chose move 2.
Decision time: 1.437 seconds
Player X - choose a move: 

Tic-tac-toe

To start a game of Tic-tac-toe against the computer, enter:

$ cligames tictactoe
A new game has started.
┌───┬───┬───┬───┐
│ 2 │   │   │   │
├───┼───┼───┼───┤
│ 1 │   │   │   │
├───┼───┼───┼───┤
│ 0 │   │   │   │
├───┼───┼───┼───┤
│   │ 0 │ 1 │ 2 │
└───┴───┴───┴───┘
Player X - choose a move: 

To make a move, enter the (x, y) coordinates of the position you wish to make a move in:

Player X - choose a move: (1, 1)
┌───┬───┬───┬───┐
│ 2 │   │   │   │
├───┼───┼───┼───┤
│ 1 │   │ X │   │
├───┼───┼───┼───┤
│ 0 │   │   │   │
├───┼───┼───┼───┤
│   │ 0 │ 1 │ 2 │
└───┴───┴───┴───┘
Player X chose move (1, 1).
Decision time: 1.567 seconds
Player O is choosing... 
┌───┬───┬───┬───┐
│ 2 │   │   │   │
├───┼───┼───┼───┤
│ 1 │   │ X │   │
├───┼───┼───┼───┤
│ 0 │ O │   │   │
├───┼───┼───┼───┤
│   │ 0 │ 1 │ 2 │
└───┴───┴───┴───┘
Player O chose move (0, 0).
Decision time: 0.02 seconds
Player X - choose a move: 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cligames-0.2.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cligames-0.2.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file cligames-0.2.1.tar.gz.

File metadata

  • Download URL: cligames-0.2.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cligames-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ab7db7142571bdd87952114858d7b8b7b34fd8ef25fdc50b8ec075f54f82780a
MD5 bab338dd2bcf92095f94baf696ca0034
BLAKE2b-256 41c37cd74a8fa130a860c138613edce059c73265a92ad61842f777dd60bfb408

See more details on using hashes here.

Provenance

The following attestation bundles were made for cligames-0.2.1.tar.gz:

Publisher: publish.yml on tombch/cligames

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cligames-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cligames-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cligames-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b052f3c42ff04a4d8b8294feeaef0b634b8a144d8be323b73432b1da41582b74
MD5 69f45b19841779498cc574e4971c3b01
BLAKE2b-256 72ec38eb44923f18f287ce4cab4e9ab5d18dbf4a3d6b2449c580860d2db5ca09

See more details on using hashes here.

Provenance

The following attestation bundles were made for cligames-0.2.1-py3-none-any.whl:

Publisher: publish.yml on tombch/cligames

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page