Skip to main content

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.

Metadata

Release files for batara-guru 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for batara-guru 0.0.1
File Size Uploaded
batara_guru-0.0.1.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for batara-guru 0.0.1
File Interpreter ABI Platform
batara_guru-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.4 kB

Release files / batara_guru-0.0.1.tar.gz

Download URL batara_guru-0.0.1.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ab8d018cf48df5775161886153c3923d4822687badf6d34cfd5dc085bc3cef54
BLAKE2b-256 checksum
How to use checksums
8df6a3f42a00c9c3f6550af9aed2c13455574b82f694041c67388c9c1693afaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64

Release files / batara_guru-0.0.1-py3-none-any.whl

Download URL batara_guru-0.0.1-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa6d2377dddfaf42bc303bbb2086d32e6e3372956ec08b0e42a5e00268bb2c0b
BLAKE2b-256 checksum
How to use checksums
6fba8b1e8475baac788d7debba5236a8b4c84ce640f653d1121f2f7dfc91b6c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page