Install
Use pnpm. Installing with both npm and pnpm registers the same command twice, so use pnpm add -g only.
pnpm add -g @lapius/cli-othello
This installs the othello command. It needs Node.js 18+ and Python 3.9+.
With pip:
pip install cli-othello
On Windows, curses needs windows-curses. pip installs it automatically. If you installed with npm, run py -m pip install windows-curses.
Usage
othello
A screen to choose the AI level (Lv.1 to Lv.5) appears before the game. To skip it:
othello --level 3 # or -l 3
othello --version # or -V
Keys
| Key | Action |
|---|---|
| Arrow keys (or h/j/k/l) | Move the cursor |
| Enter / Space | Place a disc at the cursor |
| q | Quit |
On the board, the squares where you can play are marked with a green ·.
AI levels
| Level | Description |
|---|---|
| Lv.1 (beginner) | Highly random; plays almost at will |
| Lv.2 (easy) | Shallow search plus positional weights of the squares |
| Lv.3 (medium) | Also weighs corners, edges and the number of available moves (mobility) |
| Lv.4 (hard) | Looks further ahead while evaluating the board |
| Lv.5 (strongest) | Deepest search of the five levels |
The AI uses minimax with alpha-beta pruning; search depth and evaluation detail grow with the level. In the endgame, Lv.3 to Lv.5 switch to an exact solver once 8, 9 and 10 squares or fewer remain, respectively.
[!NOTE] The old README said Lv.5 searches "up to 6 plies" and that the terminal must be 57x36. Neither matched the code: Lv.5 searches 4 plies in the middle game, and the minimum is 56 columns by 27 rows. Game play itself was not run for this rewrite (unverified).
Requirements
- Python 3.9+ (and Node.js 18+ if installed with npm)
- A terminal of at least 56 columns by 27 rows. The board is drawn larger when the terminal is at least 56 by 35.
License
MIT (LICENSE)