1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194 |
# Pablo's Terminal Games
A collection of ten small board, strategy and puzzle games designed to
be played entirely inside the terminal. No browser, no GUI, no
accounts, no internet — just games.
```
+================================+
| |
| PABLO'S TERMINAL GAMES |
| |
| VERSION 0.0.1 |
| |
+================================+
> 1. Tic-Tac-Toe
2. Connect Four
3. Checkers
4. Reversi
5. Naval Battle
6. Gomoku
7. Mancala
8. Minesweeper
9. 2048
0. Fifteen Puzzle
Arrows/W-S move - Enter select - H help - S stats - A about - Q quit
```
## Games included
| # | Game | Modes |
| --- | -------------- | ----------------------- |
| 1 | Tic-Tac-Toe | vs Computer, vs Player |
| 2 | Connect Four | vs Computer, vs Player |
| 3 | Checkers | vs Computer, vs Player |
| 4 | Reversi | vs Computer, vs Player |
| 5 | Naval Battle | vs Computer |
| 6 | Gomoku | vs Computer, vs Player |
| 7 | Mancala | vs Computer, vs Player |
| 8 | Minesweeper | single player, 3 levels |
| 9 | 2048 | single player |
| 0 | Fifteen Puzzle | single player |
Every game has its own help screen (press `H` in-game) explaining the
objective, controls and rules.
## Features
- Retro terminal interface with arrow-key menus, ANSI colors and
Unicode box drawing (with automatic ASCII fallback).
- Cross-platform keyboard input: works on Windows (msvcrt) and
Linux/Unix (termios) with no configuration.
- Correct game rules kept separate from rendering, so they are fully
unit-tested (236 tests).
- Local JSON statistics: games played, won, lost and drawn, plus
records (2048 high score and best tile, Minesweeper best times,
Fifteen Puzzle best moves/time).
- Graceful behavior: invalid input is explained and re-asked, the
terminal is always restored on exit, and a corrupted statistics
file never crashes the program.
- Completely offline. No telemetry, no analytics, no network
requests, no accounts. Everything stays on your computer.
## Requirements
- Python 3.8 or newer (standard library only — nothing to install).
- A terminal of at least 80x24 characters.
## Installation
Clone or copy this directory anywhere. There is no build step and no
dependency to install.
## Running
### Windows
```
python main.py
```
or double-click / run:
```
play.bat
```
Works in Windows PowerShell, cmd and Windows Terminal.
### Linux
```
python3 main.py
```
or:
```
./play.sh
```
Works in any standard terminal emulator (Debian/Ubuntu included).
## Controls
- **Menus**: Arrow keys or `W`/`S` to move, `Enter` to select,
number keys as shortcuts, `Q` or `ESC` to go back.
- **Board games** (Tic-Tac-Toe, Connect Four, Checkers, Reversi,
Naval Battle, Gomoku, Mancala): type coordinates or numbers
(e.g. `b2`, `d3`, `b6-a5`, `E5`, `1-6`) and press Enter.
- **Real-time games** (Minesweeper, 2048, Fifteen Puzzle): arrow
keys and WASD. Minesweeper: `Enter`/`Space` reveals, `F` flags.
- **Everywhere**: `H` for help, `Q`/`ESC` to return to the menu.
Note: game 10 (Fifteen Puzzle) is selected with the `0` key.
## Statistics
Statistics are stored in a local `stats.json` file next to `main.py`
and survive between executions. View them from the main menu with
`S`. No data ever leaves your computer; delete the file to reset
everything.
## Project structure
```
terminal-games/
|
├── main.py entry point, main menu, help/stats/about
├── play.bat Windows launcher
├── play.sh Linux launcher
├── GAME_SPEC.md internal contract for game modules
│
├── core/
│ ├── __init__.py app metadata (version lives here, once)
│ ├── terminal.py screen, colors, boxes, centering, prompts
│ ├── input.py cross-platform single-key and line input
│ ├── menu.py reusable arrow-key menu
│ ├── storage.py local JSON statistics
│ └── utils.py small shared helpers
│
├── games/ one module per game, all following
│ ├── tic_tac_toe.py GAME_SPEC.md (pure logic + UI layer)
│ ├── connect_four.py
│ ├── checkers.py
│ ├── reversi.py
│ ├── naval_battle.py
│ ├── gomoku.py
│ ├── mancala.py
│ ├── minesweeper.py
│ ├── game_2048.py
│ └── fifteen.py
│
└── tests/ one unittest file per game (headless)
```
## Development
Game rules live in pure logic classes with no printing or input,
which is what the tests drive. The `Game` class in each module is the
terminal UI on top. To add a new game, follow `GAME_SPEC.md` and
register the module in `main.py`.
## Running tests
```
python -m unittest discover -s tests
```
All 236 tests should pass in well under a second.
## Author
Pablo Murad
[pablomurad@pm.me](mailto:pablomurad@pm.me)
Made for people who still enjoy the command line.
## License
MIT — see [LICENSE](LICENSE). Copyright (c) 2026 Pablo Murad. |