Python program that runs a cellular automata simulation on a 2D grid and exports the result as an animated HTML visualization.
FILES
automata.py
- Runs the simulation
- Defines tile types and rules
- Prints the grid in the terminal
- Controls timestep delay
- Exports frames to HTML
export_html.py
- Takes simulation frames
- Generates an HTML file with a colored grid animation
REQUIREMENTS
- Python 3.x
- Web browser (to open the exported HTML file)
No external libraries are required.
USAGE
Run with default settings:
python automata.py
Run with custom parameters:
python automata.py <rows> <cols> <steps> <delay> <seed>
Example:
python automata.py 30 80 400 0.1 42
Arguments:
- rows : grid height
- cols : grid width
- steps : number of simulation steps
- delay : time between steps in seconds
- seed : random seed (optional)
OUTPUT
- Terminal output: ASCII grid updated every timestep
- File output: automata.html
Open automata.html in a browser to view the animated grid.
TILES
' ' Empty '#' Wall 'T' Tree '~' Water '.' Grass '^' Mountain
Tile behavior is defined in automata.py.
CONTRIBUTING
- Fork the repository
- Make changes in a separate branch
- Submit a pull request with a short description
NOTES
- All simulation updates are synchronous
- HTML export does not affect simulation logic
- Changing tile colors only requires editing export_html.py