https://github.com/paulrobello/rich_life
https://github.com/paulrobello/rich_life
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/paulrobello/rich_life
- Owner: paulrobello
- License: mit
- Created: 2024-09-16T22:07:48.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-19T03:54:54.000Z (about 1 year ago)
- Last Synced: 2024-11-27T21:19:12.732Z (12 months ago)
- Language: Python
- Size: 723 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cli-apps-in-a-csv - rich_life - Conway's Game of Life and Langton's Ant. (<a name="animation"></a>Animation)
- awesome-cli-apps - rich_life - Conway's Game of Life and Langton's Ant. (<a name="animation"></a>Animation)
README
# Conway's Game of Life and Langton's Ant
[](https://pypi.org/project/rich_life/)
[](https://pypi.org/project/rich_life/)



## About
This project implements Conway's Game of Life and Langton's Ant.
Both are cellular automaton simulations.
Uses Rich for terminal visualization.
[](https://buymeacoffee.com/probello3)
## Screenshots


## Installation
To install make sure you have Python 3.11 or higher and [uv](https://pypi.org/project/uv/) installed.
### Installation From Source
1. Clone the repository:
```bash
git clone https://github.com/paulrobello/rich_life.git
cd rich_life
```
2. Install the required dependencies:
```bash
uv sync
```
### Installation From PyPI
To install from PyPI, run any of the following commands:
```bash
uv tool install rich-life
```
```bash
pipx install rich-life
```
## Usage
### Running if installed from PyPI
```bash
rich_life
```
### Running from source
Run the Game of Life simulation using the following command:
```bash
uv run rich_life
```
You can customize the grid size, number of generations, and neighborhood rules using command-line options:
```bash
uv run rich_life --width 50 --height 30 --generations 300 --rules moore
```
Run the Langton's Ant simulation using the following command:
```bash
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:
```bash
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](LICENSE).
## Author
Paul Robello (probello@gmail.com)