Description
The Convoys_GameofLife/GameOfLife.py script contained several critical bugs, crashes on Windows, unhandled screen resize exceptions, dead code, and documentation placeholders:
- Windows Crash on Launch: Standard
import curses fails on Windows with ModuleNotFoundError: No module named '_curses'. The README incorrectly instructed pip install curses instead of windows-curses.
- Terminal Bounds / Resize Crash: Calling
stdscr.addstr() on screen boundaries and bottom-right coordinate without clamping caused curses.error: addstr() returned ERR when resized to smaller terminal sizes.
- Dead / Unimplemented Code:
pause = False was initialized but never used in the main loop, preventing users from pausing or stepping through generations.
- Performance Issues: Using
copy.deepcopy(grid) every frame in a tight loop added heavy performance overhead.
- Missing Features & Presets: No support for famous pattern presets (Glider, Pulsar, Gosper Glider Gun, Blinker, Beacon, Toad), no single-step mode, and no fallback rendering mode when curses is not available.
- Documentation Placeholders & Typos:
README.md had unfilled template headers (# Script Title) and typos in titles and status bars (Genration:). Missing requirements.txt and automated tests.
Type of issue
Checklist:
Steps to Reproduce:
- Open a terminal on Windows and run
python GameOfLife.py.
- Notice immediate crash
ModuleNotFoundError: No module named '_curses'.
- In a curses terminal, resize window smaller than status bar length ->
curses.error crash.
- Try pressing pause -> feature does not exist.
Proposed Solution:
- Decouple simulation engine into
GameOfLifeEngine for clean testing and modularity.
- Add safe coordinate rendering with
safe_addstr() to prevent curses boundary exceptions.
- Implement ANSI terminal fallback mode for seamless execution without curses.
- Add built-in pattern presets (Glider, Blinker, Toad, Beacon, Pulsar, Gosper Gun).
- Add interactive controls: Pause (
Space/p), Step (n), Randomize (r), Clear (c), Wrap toggle (w), Presets (1-5), Speed adjustment.
- Add CLI automation support (
argparse).
- Add unit test suite in
test_game_of_life.py and create requirements.txt.
- Update
README.md with complete documentation.
Description
The
Convoys_GameofLife/GameOfLife.pyscript contained several critical bugs, crashes on Windows, unhandled screen resize exceptions, dead code, and documentation placeholders:import cursesfails on Windows withModuleNotFoundError: No module named '_curses'. The README incorrectly instructedpip install cursesinstead ofwindows-curses.stdscr.addstr()on screen boundaries and bottom-right coordinate without clamping causedcurses.error: addstr() returned ERRwhen resized to smaller terminal sizes.pause = Falsewas initialized but never used in the main loop, preventing users from pausing or stepping through generations.copy.deepcopy(grid)every frame in a tight loop added heavy performance overhead.README.mdhad unfilled template headers (# Script Title) and typos in titles and status bars (Genration:). Missingrequirements.txtand automated tests.Type of issue
Checklist:
Steps to Reproduce:
python GameOfLife.py.ModuleNotFoundError: No module named '_curses'.curses.errorcrash.Proposed Solution:
GameOfLifeEnginefor clean testing and modularity.safe_addstr()to prevent curses boundary exceptions.Space/p), Step (n), Randomize (r), Clear (c), Wrap toggle (w), Presets (1-5), Speed adjustment.argparse).test_game_of_life.pyand createrequirements.txt.README.mdwith complete documentation.