8 ms·
Show HN: Create your own cellular automata
- Aperocky 6y agoExpress your own cellular automata without writing 100s of lines of boiler plate. The famous conway game of life can be expressed as: ``` { "InitialCondition": "1 0.2", "0": [ "CountAdjacent eq 1 3 1" ], "1": [ "CountAdjacent lt 1 2 0", "CountAdjacent gt 1 3 0" ] } ``` Entirely browser based.
- deleted 6y ago[deleted]
- UncleOxidant 6y agoCan you explain this language?
- bradrn 6y agoI found an explanation here: https://github.com/Aperocky/cellular-automata https://github.com/Aperocky/cellular-automata
- SamBam 6y agoNice. It's fun the be able to play with the initial "forest fire" model and try to model different conditions -- a wet forest which takes more adjacent sparks to create a fire, a fire that stays burning longer, etc. A couple small suggestions from someone who makes a lot of these kinds of models: A "Step" button would be really nice, to be able to advance the model a single step at a time; it would be helpful for "Start" to change to "Reset" or "Restart" after the initial press, so you're not surprised when it blows away your model; "Continue" could be disabled until you Stop, as it doesn't do anything.
- Aperocky 6y agoThanks for the feedback! The continue was actually a bug as it allowed multiple settimeout loops to speed up the process. Hammered out a fix and added the step button over lunch break, pretty easy change & fix (just 10 lines!). thanks for suggestion.
- deleted 6y ago[deleted]
- derg 6y agoCellular Automata are so cool. I did a project for a distributed computing course on them and it was real fun throwing different rules in and seeing what emerged.
- dash2 6y agoQuestion: what proportion of cellular automata generate "interesting" patterns in the way Conway's Game of Life does? For instance, in the GOL, you can create gliders, which keep their pattern over time, and even build logic gates. Perhaps you could even have "life forms" in some sense? Presumably many automata aren't like this and just generate uninteresting patterns, or always collapse into some determinate after enough time. What do we know about this?
- mysterydip 6y agoThe wikipedia page actually has a lot of depth on this topic, with other rulesets as well (see "specific rules" at the bottom): https://en.m.wikipedia.org/wiki/Cellular_automaton https://en.m.wikipedia.org/wiki/Cellular_automaton
- Aperocky 6y agoIt doesn't even necessarily need to be dynamic, for instance, use this to generate a maze: { "0": [ "SpontaneousChange 1 0.1" ], "1": [ "CountAdjacent gt 1 5 2" ], "2": [], "colorMap": { "0": "tintblack", "1": "cyan", "2": "gray" } }
- UncleOxidant 6y agoIs there a path through the maze it generates? If so, are there multiple paths?
- Aperocky 6y agomaybe it's provable mathematically, but I don't think it follow any strict bounds.
- UncleOxidant 6y agoI've got a CA that can run a maze. Can I generate a maze using your maze-generating code and then use that as the starting point for my maze-runner? It doesn't seem to be possible - when I enter my maze running code and start the whole thing resets.
- sequoia 6y agoReminds me of this one https://ncase.me/sim/ https://ncase.me/sim/
- nynx 6y agoWolfram has produced a number of interesting articles, as well as a book, that explore the meta-landscape of cellular automata.
- webmaven 6y agoMore recently, he's been exploring the application of cellular-automata-like rules to more general graphs (ie. nodes and edges) rather than the classic grids of cells: https://www.wolframphysics.org/technical-introduction/ https://www.wolframphysics.org/technical-introduction/
- User23 6y agoDijkstra did something along those lines with his “diffusing computations.”[1] [1] https://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD687a.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/E...
- beforeolives 6y agoCan anyone share some insight into why cellular automata are a big deal? I've built the original Game of Life and some variations (in 3D, 4D and on a hexagonal grid) during last year's Advent of Code but I still don't get the usefulness or where they fit in the larger picture of computer science.
- macintux 6y agoI've struggled with this question as well, although Wolfram's tribute to Solomon Golomb (recently reposted here) helped me start to see why they're interesting. https://writings.stephenwolfram.com/2016/05/solomon-golomb-19322016/ https://writings.stephenwolfram.com/2016/05/solomon-golomb-1...
- A12-B 6y agoI'm sure there's a better reason, but I honestly think a major factor for why people think this stuff is important is because Conway called it 'the game of life', and it was a pretty early discovery in computer science. It was basically a recipe for sci-fi imagination and headlines, leading some people to believe this is literally a program about generating cellular life.
- yiyus 6y agoCellular automata models are widely used in different science and engineering disciplines. For example, I use them for the simulation of heat treatments of steel. I guess that the fascination of the CS community comes from: 1) Conway; 2) They raise different interesting programming questions and exercises (writing GOL is a nice exercise to learn a new language, a parallel CA is a nice way to learn about parallelization, huge models pose interesting memory management questions,...); and 3) They are cool (isn't the video about GOL in APL by John Scholes one of the coolest programming videos you've ever seen?)
- UncleOxidant 6y agoWhat kind of CA model do you use to simulate heat treatments in steel?
- ninly 6y agoA couple years ago I threw together some MATLAB functions to take a wolfram number and a seed row, along with some cosmetic parameters, to generate elementary cellular automata. Nothing very big or elaborate, but fun and handy for exploring the ECAs themselves. https://github.com/ninly/ecafun https://github.com/ninly/ecafun
- thedanbob 6y agoWhen I was in college I had a job working for a physics professor who was studying cellular computation. The hope was that by studying examples in nature of cellular systems that solved particular problems (e.g. a leaf trying to maximize sunlight absorption while minimizing water loss) we would be able to solve similar problems in the artificial realm. Using his equations I created a cellular automata simulation in Excel with VBA, my first real programming outside of CS classes. Good times.
- Aperocky 6y agoNow that's dedication, I can't imagine doing the same with Excel (though it's definitely possible). I've never tried this but what does coding in excel feels like? Does it feel like an ancient version of scratch?
- thedanbob 6y agoI’ve never tried scratch but I can see the similarity to writing cell functions. VBA is a different beast entirely, it’s more like using a dumbed-down version of JavaScript to manipulate a simpler version of the DOM.
- mikkom 6y agoI created something a little more complicated some time ago.. http://kirkas.com/genesys/ http://kirkas.com/genesys/ Some more information https://www.reddit.com/r/alife/comments/giyjaa/show_ralife_genesys_alpha_version_arficial_life/ https://www.reddit.com/r/alife/comments/giyjaa/show_ralife_g... https://www.reddit.com/r/alife/comments/ger9r4/show_ralife_something_im_going_to_release_soon_to/ https://www.reddit.com/r/alife/comments/ger9r4/show_ralife_s...
- bradrn 6y agoI find it interesting that so many people have made their own CA simulator — I’ve made one as well! [0] Mine uses a very different design to yours: it’s distributed as a library allowing people to define their own CAs, which they can then compile and run in a GUI. Compared to yours and OP’s, this is admittedly a bit hard to use, and you do need to know Haskell to use it. Additionally, I’ve only just rewritten it to use this approach, so some of the documentation and samples are out of date. (Also, it crashes a lot, I don’t know why.) Still, I have successfully used it ‘in anger’ at least once, to simulate the Beleusov-Zhabotinsky reaction for a chemistry assignment [1], so it at least seems to work. (The categorically inclined may also be interested to know that this uses a variant of comonads [2] to define CAs, an approach I’ve found to be surprisingly flexible.) [0] https://github.com/bradrn/cabasa https://github.com/bradrn/cabasa [1] http://www.jstor.org/stable/2874179 http://www.jstor.org/stable/2874179 and http://www.sciencedirect.com/science/article/pii/016727899090101T http://www.sciencedirect.com/science/article/pii/01672789909... [2] https://www.reddit.com/r/haskell/comments/a2vnni/a_better_comonad_for_cellular_automata/ https://www.reddit.com/r/haskell/comments/a2vnni/a_better_co...
- mikkom 6y agoI have always been fascinated with alife, the first one I created was something like 20+ years ago after I read an article about Tierra in a magazine. For anyone not familiar with tierra, peek into the rabbit hole :-) https://web.stanford.edu/class/sts129/Alife/html/Tierra.htm https://web.stanford.edu/class/sts129/Alife/html/Tierra.htm http://life.ou.edu/pubs/doc/index.html http://life.ou.edu/pubs/doc/index.html https://ai2020.org/tom-rays-tierra https://ai2020.org/tom-rays-tierra So... Genesys I linked is more than just basic CA, it consists of independent agents with each "creature" using a lisp-like instruction set.
- mvolfik 6y agoI've been fine-tuning my forest for way too long and here's what I came up with: { "0": [ "CountAdjacentChance eq 1 1 1 0.01", "CountAdjacentChance ge 1 2 1 0.03" ], "1": [ "SpontaneousChange 2 0.00001", "ChangeByBlockAge gt 200 3 0.1", "CountAdjacentChance eq 2 1 2 0.4", "CountAdjacentChance eq 2 2 2 0.8", "CountAdjacentChance ge 2 3 2 1.0" ], "2": [ "SpontaneousChange 3 1" ], "3": [ "SpontaneousChange 0 0.25" ], "InitialCondition": "1 0.0005", "colorMap": { "0": "black", "1": "green", "2": "red", "3": "brown" }, "timeStep": 30 }
- Aperocky 6y agoThis is amazing, I think this is why cellular automata are so interesting - there are so many possibility (and conway's game of life is just a beginning!). Feel free to pull request into ./sample/, alternatively I can add this in a commit later. The one I found the most fun is actually semi-dynamic in maze runner, there's a small trick in that you can reuse color for colormap: { "0": [ "SpontaneousChange 1 0.15" ], "1": [ "CountAdjacent gt 1 5 2", "SpontaneousChange 3 0.00001", "CountDirectlyAdjacent gt 3 0 3" ], "2": [], "3": [ "ChangeByBlockAge gt 1 4 1" ], "4": [ "ChangeByBlockAge gt 2 1 1" ], "colorMap": { "0": "tintblack", "1": "cyan", "2": "gray", "3": "yellow", "4": "cyan" }, "timeStep": 100 }
- kevinwang 6y agoabsolutely sick. one of the coolest things I've seen all year.