Cellular Automata Lab banner

Cellular Automata Lab

11 devlogs
15h 20m 45s

a complete playground for Cellular Automata simulations like Conway’s Game of Life and many other variations, you can use your own rules too!

This project uses AI

Used ChatGPT for project idea and finding more patterns
(NOT A SINGLE LINE OF CODE WAS WRITTEN BY AI, THIS IS A VERY SIMPLE PROJECT)

Demo Repository

Loading README...

Pratik

Shipped this project!

I built a Cellular Automata Lab

like Conway’s Game of Life, but it has many more presets and pre-loaded patterns.
you can even try your own custom B/S notation rules and watch cool patterns emerge :3

you control simulation using play/pause/step to seee everything better, there is also grid lines toggle for clarity, and information pannel for generation and alive cells count!

if you have no idea about any of this please check out /whatthehell page :3
enjoy! yay

Pratik

What the hell? page added! yay

visit if you dont know anything, it will help you so you can enjoy the lab more!

Attachment
0
Pratik

Readme + More keyboard shortcuts

oof i hate this one
fixed some errors in grid due to grid being null and what not, and also added readme

and yes a couple more keyboard shortcut

Attachment
0
Pratik

Custom Rule Input! yay

added that, now you can try your own rules with the B/S notation where B is birth and S is survival
for example: B3/S23 is the rule of conway, it means if there are 3 neighbours then a dead cell will become alive, and if there are 2 or 3 neighbor cell then the cell will survive in next generation, if no conditions are met the cell will die in next generation

and also some minor changes

  • made Seed rule use a block as starter in grid instead of randomizing the grid
  • added new rule Diamoeba after i fell in love with it while trying the custom input (pic attached)

well now its real “lab” ig cuz you can try your own input lol 33

Attachment
0
Pratik

More patterns yay

to be honest, this took so long of messing around to have them work that i dont even remember the specifics of what i added, but i added some patterns for conway and other rules, conway still dominates i dont think i need that many patterns for every rule right now, but i surely added cool patterns

and also made the pattern selector in controls handle the categories dynamically, before it was just hardcoded stuff

Attachment
0
Pratik

Major Rule and Pattern changes yay


things added:

  1. density to rules, it is an integer which tells the % of grid to be activated for seeding before simulation starts, not every rule uses it tho
  2. thats why i added Patterns for seeding lol, some rules requires patterns or they wont look good with random seeding of grid
  3. added usePattern in rule which is a boolean, and it tells where to use pattern by default when user selects a rule, if set to false it will randomize the grid instead with given density
  4. added more “Recommended Patterns:” section in controls, it has buttons which loads patterns, and recommendation is just recommended: boolean on some patterns i find important and beautiful lol

so far this is the rule type right now:

export type Rule = {
  name: string;
  b: number[];
  s: number[];
  density?: number;
  recommendedPattern?: string;
  usePattern?: boolean;
};

right now only Conway’s Game of Life has patterns, will add more in next dev log, it is very hard to find coordinates and set them properly sob-ios

Attachment
0
Pratik

added more rules! yay

so far added:

  1. Conway’s Game of Life
  2. HighLife
  3. Seeds
  4. Life without Death
  5. Mezectrics <–– MY FAV :3
  6. Snowflakes
  7. Vote (pls vote good)
  8. Inversed Life
  9. Diamonds
  10. Day & Night
  11. Replicator

these are so beautiful i am working on adding some set patterns so users can see them at their best

Attachment
0
Pratik

Added Grid Lines Toggle! yay

so you can toggle grid lines from a button, really helps making it look better

Fixed: zoom not working while simulation is playing

now it zooms anytime you press it

Attachment
0
Pratik

Pattern Library! yay

added lots of patterns for Conway’s Game of Life, these patterns were found long ago randomly, cuz thats the coolest thing about Cellular Automata, it creates complex patterns over time!

i made pattern selectable through a select after selecting the rule, and it clears the grid then creates pattern which you can run

and every pattern i have added is just bunch of coordinates like this:

[5, 5], [6, 5], [7, 4], [7, 6], [8, 5], [9, 5], [10, 5], [11, 5], [12, 4], [12, 6], [13, 5], [14, 5]

^ this is the “Pentadecathlon” pattern which is a period 15 oscillator first found in 1970!

so i have added many types of patterns, they are:

  1. Still Life: 6 patterns
  2. Oscillators: 5 patterns
  3. Spaceships: 2 pattern
  4. Guns: 1 pattern

PS: and i added alive cell counter

0
Pratik

Many Changes:

  1. Added step button, so user can see next generation and see them one by one instead of running the loop
  2. added an infopanel, where i am showing generation count, rule name, rule B/S notation, state, and more in future
  3. and i fixed speed range slider, which was not working as intended, i had to pause and play again for it work, now its simultaneous
  4. added keyboard shortcuts!, you can press ? to see them
  5. reduced default cell sizes to 8px
  6. added zoom buttons
  7. better control buttons UI (grouping them)
Attachment
Attachment
Attachment
0
Pratik

Createad first simulation and controls! yay

so i added Conway’s Game of Life but after adding that i remembered that this lab will have multiple pre-defined simulation rules and presets and even custom ones, so i deleted the conway logic seperately i made and instead i made a Rule type which stores preset rules for simulations B/S format where B is birth and S is survival.

and wrote a bunch of nested loops so i can check for neighbor cells dynamically based on provided rule so i dont have to write logic for each simuation preset, it works like a charm! gave me a hard time tho

oh yes and i added control buttons above the grid container, the buttons i added:

  • Random 20%: activates random 20% cells in grid to seed it for simulation
  • Random 50%: same, with 50%, i will make it based on input later if i feel like it
  • Play/Pause: duh, ofc it will be this
  • Speed Range Slider: right now its betweens 50ms to 500ms for each generation but i was also thinking generations per seconds as speed unit but i am still confused what to go so i picked this, seemed easier lol

okay bye see you in next oneeee

0
Pratik

Home Page and Grid 33

first dev log!!!
so i made a simple home page with title and grid, and also /whatthehell as about page

Grid took a long time because i rewrote it multiple times, the first of grid was just simple 20x20 with no toggle on click, then it was dynamically took the size of parent div and had toggle on and off on click, and third one had click-and-drag to toggle multiple instead of just clicking but it was very laggy as it rendered entire grid everytime even once cell roggled on and off so i scrapped the entire normal approach and used Canvas API instead, so its super smooth

Attachment
0