{"id":26046618,"url":"https://github.com/ratwolfzero/cellular-automaton","last_synced_at":"2026-04-27T05:02:07.199Z","repository":{"id":281250169,"uuid":"939712315","full_name":"ratwolfzero/Cellular-Automaton","owner":"ratwolfzero","description":"Cellular Automata","archived":false,"fork":false,"pushed_at":"2025-02-27T01:30:30.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T21:11:52.862Z","etag":null,"topics":["alive","birth","cellular","cellular-automata","cellular-automaton","chaos","conways-game-of-life","dead","emergence","grid-based","kernel","neighbourhood","self-replicating","survival","unpredictable"],"latest_commit_sha":null,"homepage":"https://github.com/ratwolfzero/Cellular-Automaton","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ratwolfzero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-27T01:30:28.000Z","updated_at":"2025-02-27T01:34:13.000Z","dependencies_parsed_at":"2025-03-07T21:11:56.636Z","dependency_job_id":"03423e31-8220-4ab9-b3c6-0d65cfda8223","html_url":"https://github.com/ratwolfzero/Cellular-Automaton","commit_stats":null,"previous_names":["ratwolfzero/cellular-automaton"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ratwolfzero/Cellular-Automaton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FCellular-Automaton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FCellular-Automaton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FCellular-Automaton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FCellular-Automaton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ratwolfzero","download_url":"https://codeload.github.com/ratwolfzero/Cellular-Automaton/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FCellular-Automaton/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32323215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alive","birth","cellular","cellular-automata","cellular-automaton","chaos","conways-game-of-life","dead","emergence","grid-based","kernel","neighbourhood","self-replicating","survival","unpredictable"],"created_at":"2025-03-07T21:11:47.592Z","updated_at":"2026-04-27T05:02:07.165Z","avatar_url":"https://github.com/ratwolfzero.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cellular Automata: Exploring Complexity from Simplicity\n\n## What are Cellular Automata?\n\nCellular automata (CAs) are grid-based mathematical models where cells evolve according to simple, local rules. They demonstrate how complex, global behavior can emerge from these simple rules.\n\n![CA](ca.png)\n\n## Historical Context\n\n- **Early Work:** John von Neumann and Stanisław Ulam pioneered CAs in the 1940s to explore self-replication.\n- **Game of Life:** John Conway’s *Game of Life* (1970) showcased emergent behavior, where simple rules lead to complex, unpredictable patterns.\n- **Formal Classification:** Stephen Wolfram’s research in the 1980s classified CAs and highlighted their computational universality.\n\n## How This Code Works\n\nThis implementation simulates a **2D cellular automaton** on an `x × y` grid, where each cell is either alive (`1`) or dead (`0`).\n\n### **Neighborhood and Rules**\n\n- **Neighborhood Type:** The default is the **Moore neighborhood**, where a cell interacts with its 8 immediate neighbors.\n- **B/S Notation:** Rules are defined using **B/S notation** (e.g., `B3/S23`):\n  - `B3`: A dead cell becomes alive if it has **3** live neighbors (**Birth**).\n  - `S23`: A live cell survives if it has **2 or 3** live neighbors (**Survival**).\n- **Rule Validation:** The program ensures correct formatting and prevents invalid rules from causing crashes.\n\n### **Kernel Scaling**\n\nThe **convolution kernel** determines how neighbors influence a cell. The default implementation uses a **Moore neighborhood** with `KERNEL_SIZE = 3`, meaning each cell interacts with **8 neighbors** (3×3 grid, excluding the center).\n\n#### **Increasing `KERNEL_SIZE` while keeping Moore neighborhood**\n\n- Increasing `KERNEL_SIZE` to **5** expands the neighborhood to a **5×5** grid, meaning each cell interacts with **24 neighbors** instead of 8.\n- The **B/S rule must be adjusted** to reflect the larger neighborhood.\n- No changes to the kernel function are needed—only updating `KERNEL_SIZE` is required.\n\n#### **Switching to a different neighborhood type (e.g., Von Neumann)**\n\n- The **convolution kernel must be redefined** to match the new neighborhood structure.\n- For example, a **Von Neumann neighborhood (5×5)** considers a **Manhattan distance of 2**, interacting with **12 neighbors** instead of 24.\n- Simply increasing `KERNEL_SIZE` does **not** change the neighborhood type automatically—you must modify the **kernel definition function**.\n\n#### **Users should ensure that:**\n\n✔ The `create_kernel()` function matches the intended neighborhood type.  \n✔ The **B/S rules** are adjusted for the expanded neighborhood.  \n✔ **Performance** is considered, as larger kernels increase computational cost.\n\n## Optimizations: Efficient Computation\n\n- **Convolution:** `scipy.signal.convolve2d` efficiently computes neighbor counts.\n- **Vectorization:** NumPy’s `np.isin` applies rules to all cells simultaneously.\n- **Efficient Animation:** `matplotlib` is used for smooth visualization.\n\n## **Understanding the Dynamics**\n\n### **Key Metrics**\n\nThe code (only the version with statistics `cellular_w_statistics`) tracks two key statistics to analyze the CA’s behavior:\n\n1. **Population Decay (Live Cells):** The count of live cells (`1`s) over time.\n2. **Shannon Entropy:** Measures the \"disorder\" in the distribution of live and dead cells.\n\n### **Entropy Interpretation**\n\n- **High Entropy (~1):** High randomness, often in dynamic, oscillating patterns.\n- **Low Entropy (~0):** High order, typically seen in static or repetitive patterns.\n\n### **Live, Dead, Static, and Dynamic Cells**\n\n- **Live Cell (`1`)**: Active in the simulation.\n- **Dead Cell (`0`)**: Inactive state.\n- **Static Cell:** A cell that never changes state.\n- **Dynamic Cell:** A cell that alternates between live and dead states.\n\n## **Exploring Different Rule Sets**\n\nThe behavior of the automaton depends on the chosen rule set:\n\n| Rule Name        | Rule (`B/S`)   | Description                                                                    |\n| ---------------- | -------------- | ------------------------------------------------------------------------------ |\n| **Game of Life** | `B3/S23`       | Classic rule set producing rich emergent structures.                           |\n| **HighLife**     | `B36/S23`      | Similar to Game of Life but allows self-replication.                           |\n| **Day \u0026 Night**  | `B3678/S34678` | Symmetric rule where patterns evolve similarly in positive and negative space. |\n| **Seeds**        | `B2/S`         | Explosive automaton where all cells die unless new ones are born.              |\n| **Replicator**   | `B1357/S1357`  | Produces self-replicating patterns.                                            |\n| **Diamoeba**     | `B35678/S5678` | Expanding and contracting structures resembling amoebas.                       |\n| **Morley**       | `B368/S245`    | Produces chaotic, glider-like movement.                                        |\n| **Long Evol**    | `B356/S23`     | Extended evolution dynamics.                                                   |\n\nUsers can **experiment** by modifying the `RULE` variable. If using a **larger kernel**, adjust the **B/S rules** to maintain meaningful behavior.\n\n## **Applications and Significance**\n\nCellular automata are used in:\n\n- **Natural Systems:** Modeling population dynamics, crystal growth, and fluid behavior.\n- **Artificial Intelligence:** Studying emergent behavior and decentralized computing.\n- **Computational Theory:** Demonstrating how simple rules can perform universal computation.\n\n### **Key Concepts Illustrated**\n\n✔ **Emergence:** Complex patterns arising from simple local interactions.  \n✔ **Computation:** Cellular automata’s connection to Turing completeness.  \n✔ **Chaos Theory:** The interplay of order and randomness in evolving systems.\n\nThis implementation efficiently visualizes the evolution of a CA, showcasing the fascinating relationship between **local rules and global complexity**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratwolfzero%2Fcellular-automaton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fratwolfzero%2Fcellular-automaton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratwolfzero%2Fcellular-automaton/lists"}