Skip to content

Repository files navigation

Hodgepodge Machine

A Python implementation of the Hodgepodge cellular automaton.

What is it?

The Hodgepodge machine is a 2D cellular automaton that simulates wave-like patterns resembling those seen in chemical reactions (like the Belousov-Zhabotinsky reaction). Each cell exists in one of three states:

  • Healthy - may become infected if surrounded by enough infection/sickness
  • Infected - has an infection level (1 to N) that grows based on neighbors; when it exceeds the threshold, the cell becomes sick
  • Sick - becomes healthy again in the next generation

This creates spiraling wave patterns that propagate across the grid.

Requirements

  • Python >=3.11
  • uv
  • numpy and pygame-ce (installed via uv)

FreeBSD

pygame-ce builds from source and will fail. Install py-game first:

pkg install py-game

Usage

uv sync
uv run python hodgepodge.py [FLAGS]

Options

Flag Default Description
-s, --size 300 Grid size
-z, --zoom 3 Size in pixels of the square representing each cell
-H, --hill 30 Size of initial random seed square
-l, --levels 100 Maximum infection level (threshold for sickness)
-m, --maxlevel 20 Maximum initial infection level in seed
-1, --kfirst 2 Divisor for infected neighbor count (higher = slower spread)
-2, --ksecond 3 Divisor for sick neighbor count (higher = slower spread)
-r, --rate 20 Base infection growth rate per step
-M, --multiplier 1.0 Multiplier for neighbor contribution to infection growth
-p, --picture - File to save picture on exit
-v, --video - Save video to file (e.g., output.mp4); size × zoom recommended to be divisible by 16
-g, --generations 0 Number of generations to run (0 = infinite)

Lower values of --kfirst and --ksecond cause faster spreading. Higher --rate and --multiplier cause faster infection progression.

Examples

Example 1 Example 2 Example 3 Example 4

License

BSD 2-Clause

About

Hodgepodge machine: hypnotoad implementation

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Packages

Contributors

Languages