Skip to main content

Rule 30 Cellular Automaton Analyzer with Parallel Processing

Project description

batara-guru: Python-based rule 30 cellular automaton analyzer

Python PyPI Code style: black License: MIT

NumPy Matplotlib Numba

DOI

A fundamental implementation of Rule 30 cellular automaton with parallel processing for educational and research purposes.

Context

Rule 30 is an elementary cellular automaton introduced by Stephen Wolfram that exhibits complex, chaotic behavior from simple deterministic rules.

Mathematical Definition: Let $s_i^t \in {0,1}$ denote the state of cell $i$ at time $t$. The evolution rule is:

$$s_i^{t+1} = s_{i-1}^t \oplus (s_i^t \lor s_{i+1}^t),$$

where $\oplus$ is XOR, $\lor$ is OR.

Binary representation: $00011110_2 = 30_{10}$

The system exhibits:

  • Chaos: Sensitive dependence on initial conditions
  • Irreversibility: Information loss over time
  • Complexity: Wolfram Class III behavior

Features

This implementation provides basic tools for studying Rule 30:

  • Parallel Numba JIT: Multi-core evolution for computational efficiency
  • Entropy Analysis: Shannon entropy $H = -\sum p_i \log_2 p_i$ and local complexity
  • Complete Pyramids: Non-truncated patterns for boundary-free analysis
  • NetCDF & CSV Output: Standard formats for data archiving and analysis
  • Publication Figures: High-resolution plots (350-600 DPI)

Installation

From PyPI:

pip install batara-guru

From source:

git clone https://github.com/sandyherho/batara-guru.git
cd batara-guru
pip install -e .

Quick Start

Command line:

# Run single case (uses all CPU cores by default)
batara-guru case1

# Run all test cases
batara-guru --all

# Specify CPU cores
batara-guru case1 --cores 4

# Custom DPI
batara-guru case1 --dpi 600

Python API:

from batara_guru import Rule30Solver

solver = Rule30Solver(width=501, steps=250, n_cores=8)
result = solver.evolve(initial_condition='single')

print(f"Final entropy: {result['entropy'][-1]:.4f}")
print(f"Mean complexity: {result['mean_complexity']:.4f}")

Test Cases

Provided test cases for pedagogical purposes:

Case Description Width Steps DPI Purpose
1 Small 251 125 350 Quick demonstration
2 Medium 501 250 400 Standard analysis
3 Large 1001 500 500 High-detail study
4 Extra Large 2001 1000 600 Publication quality

All cases maintain $t < w/2$ to ensure complete pyramidal patterns without boundary interactions.

Configuration

Example configuration file:

grid_width = 501           # Number of cells
time_steps = 250           # Evolution steps (< width/2 for full pyramid)
initial_condition = single # Single center cell (standard)
center_position = 250      # Auto-calculated if not specified
plot_dpi = 400            # Output image resolution
save_netcdf = true        # Save NetCDF file
save_plot = true          # Save PNG plot
colormap = binary         # Color scheme

Output Files

For each simulation, the following files are generated:

NetCDF (.nc):

  • grid(time, x): Complete evolution history
  • entropy(time): Shannon entropy $H(t)$
  • complexity(time): Normalized transition density

CSV (.csv):

  • {scenario}_entropy.csv: Time series of entropy values
  • {scenario}_complexity.csv: Time series of complexity values
  • {scenario}_composite.csv: Combined entropy and complexity

PNG (.png):

  • Spatio-temporal visualization of evolution

Metrics

Shannon Entropy: $$H(t) = -p_1 \log_2 p_1 - p_0 \log_2 p_0$$ where $p_1 = N_1/N$ is the fraction of alive cells.

Local Complexity: $$C(t) = \frac{1}{N} \sum_{i=1}^{N} |s_i^t - s_{i+1}^t|$$ measuring spatial transition density.

Parallel Processing

Utilizes all available CPU cores by default. Override with:

batara-guru case3 --cores 8

Or programmatically:

solver = Rule30Solver(width=1001, steps=500, n_cores=8)

Citation

If this tool is useful for your research or teaching, please cite:

@software{batara_guru_2025,
  author = {Herho, Sandy H. S. and Napitupulu, Gandhi},
  title = {\texttt{batara-guru}: Python-based Rule 30 cellular automaton analyzer},
  year = {2025},
  version = {0.0.1},
  url = {https://github.com/yourusername/batara-guru},
  license = {MIT}
}

Authors

License

MIT License - See LICENSE for details.

Acknowledgments

This is an educational implementation inspired by Wolfram's pioneering work on cellular automata. For comprehensive cellular automata research, see Wolfram's A New Kind of Science.

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

batara_guru-0.0.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

batara_guru-0.0.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file batara_guru-0.0.1.tar.gz.

File metadata

  • Download URL: batara_guru-0.0.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64

File hashes

Hashes for batara_guru-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ab8d018cf48df5775161886153c3923d4822687badf6d34cfd5dc085bc3cef54
MD5 e27abe2091435acbfe376346d726dc36
BLAKE2b-256 8df6a3f42a00c9c3f6550af9aed2c13455574b82f694041c67388c9c1693afaa

See more details on using hashes here.

File details

Details for the file batara_guru-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: batara_guru-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64

File hashes

Hashes for batara_guru-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa6d2377dddfaf42bc303bbb2086d32e6e3372956ec08b0e42a5e00268bb2c0b
MD5 18b4eaff8eba095d355c2cd0bb31b236
BLAKE2b-256 6fba8b1e8475baac788d7debba5236a8b4c84ce640f653d1121f2f7dfc91b6c7

See more details on using hashes here.

Supported by

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