Skip to main content

Terminal-based life and ant simulation.

Project description

Conway's Game of Life and Langton's Ant

PyPI PyPI - Python Version
Runs on Linux | MacOS | Windows Arch x86-63 | ARM | AppleSilicon
PyPI - License

About

This project implements Conway's Game of Life and Langton's Ant.
Both are cellular automaton simulations. Uses Rich for terminal visualization.

"Buy Me A Coffee"

Screenshots

Game of Life Screenshot Langton's Ant Screenshot

Installation

To install make sure you have Python 3.11 or higher and uv installed.

Installation From Source

  1. Clone the repository:

    git clone https://github.com/paulrobello/rich_life.git
    cd rich_life
    
  2. Install the required dependencies:

    uv sync
    

Installation From PyPI

To install from PyPI, run any of the following commands:

uv tool install rich-life
pipx install rich-life

Usage

Running if installed from PyPI

rich_life

Running from source

Run the Game of Life simulation using the following command:

uv run rich_life

You can customize the grid size, number of generations, and neighborhood rules using command-line options:

uv run rich_life --width 50 --height 30 --generations 300 --rules moore

Run the Langton's Ant simulation using the following command:

uv run rich_life --mode ants

Available options:

  • --width or -w: Width of the grid (default: half of console height)
  • --height or -h: Height of the grid (default: half of console height minus 2)
  • --infinite or -i: Enable infinite mode. Simulation grid has no bounds (default: False)
  • --generations or -g: Number of generations to simulate (default: 100)
  • --mode or -m: Simulation mode (options: 'life' or 'ants', default: 'ants')
  • --rules or -r: Neighborhood rules for game of life (options: 'moore' or 'van_neumann', default: 'moore')
  • --offset-x or -x: Bord display X-coordinate offset for infinite mode (default: 0)
  • --offset-y or -y: Bord display Y-coordinate offset for infinite mode (default: 0)
  • --rps or -r: Refresh / generations per second (default: 10)
  • --follow or -f: Follow the ant in ANTS mode (default: False)

Keys:

  • 'Arrows' / 'WSAD': Pan the grid

Running Tests

To run the tests, use the following command:

uv run pytest tests/test_game_of_life.py

What's New

  • Version 0.3.0: Added follow mode for Langton's Ant
  • Version 0.2.0: Better keyboard handling
  • Version 0.1.0: Initial release

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is open source and available under the MIT License.

Author

Paul Robello (probello@gmail.com)

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

rich_life-0.3.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

rich_life-0.3.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file rich_life-0.3.0.tar.gz.

File metadata

  • Download URL: rich_life-0.3.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for rich_life-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8fe2bdb0d1d2e1489b906a2f6bdfcb71a9f1d921febcb90b3cf8bb976a2b32fe
MD5 1acb9065343b61027e686f731e519e4d
BLAKE2b-256 636f04e13700cfe15dd14f73f80deb0ca5aeab847da7471c4adde92c79412f77

See more details on using hashes here.

File details

Details for the file rich_life-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: rich_life-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for rich_life-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64c1708376f86d5ae2534cbedb917fba0c557ce894a4d338562ccbab8a89e317
MD5 d0c20fac1b2932f8fbc28c145acb2f60
BLAKE2b-256 5616d6df9e3bc833ca98d07bd051a694a5bc5f2333d7c5ec215a0382b851aee1

See more details on using hashes here.

Supported by

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