Skip to content

Bug & Feature(Convoys_GameofLife): Fix Windows curses crash, screen bounds errors, dead pause var, add presets & ANSI fallback #529

Description

@Prayas340

Description

The Convoys_GameofLife/GameOfLife.py script contained several critical bugs, crashes on Windows, unhandled screen resize exceptions, dead code, and documentation placeholders:

  1. 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.
  2. 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.
  3. Dead / Unimplemented Code: pause = False was initialized but never used in the main loop, preventing users from pausing or stepping through generations.
  4. Performance Issues: Using copy.deepcopy(grid) every frame in a tight loop added heavy performance overhead.
  5. 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.
  6. 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

  • Feature (New Script / Enhancements)
  • Bug
  • Documentation

Checklist:

  • I have read the project guidelines.
  • I have checked previous issues to avoid duplicates.
  • This issue will be meaningful for the project.
  • I have added steps to reproduce the bug
  • I have proposed a possible solution for the bug

Steps to Reproduce:

  1. Open a terminal on Windows and run python GameOfLife.py.
  2. Notice immediate crash ModuleNotFoundError: No module named '_curses'.
  3. In a curses terminal, resize window smaller than status bar length -> curses.error crash.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions