I want to play around with different local rules for discrete and continuous cellular systems on arbitrarily large sparse 2D grids.

Think a 2D simulation of the wave equation, heat equation, electromagnetics (em wave equation and fields, not particles), but also the game of life and other interesting cellular automata rules (wireworld, the Powder Toy/'falling sand' style physics sandbox games...), air/fluid pressure & velocity simulations etc. Simple pixel-graphics editors (think mspaint in Windows 95) would also be possible in this framework when combined with the interactivity.

Each cell needs to store the same amount of data and the grid should be stored sparsely (in a hashmap or so) so that I only pay for the data that is actually doing something interesting. The unallocated data would default to some fixed or merely coordinate-dependent or maybe interpolated value. However, new cells could always be allocated.

I only care about playing around with the rules and animating through the steps, coloring/visualizing and interacting with the results. I would prefer not having to build the whole framework for rendering the result and interacting with it myself.

The grid cells would have uniform size (A: if you know one that can progressively refine cells even better). The visualization and interaction should allow to easily zoom, rotate and pan the canvas in an arbitrary way (similar to https://apps.apple.com/us/app/stretchpaper/id1209617522 ). Each cell would be presented in a single, solid, programmable color (derived from or stored in the per-cell data). One or more pointing devices could be used to manipulate cells in the selected location on the grid. The conversion from screen to grid coordinates should be built-in to the framework.

Here are my other dream specs:

  • the computation rules can be written in C++ (or some shader language, UCDA, OpenCL or so) supporting machine integers and floats and executed on any available processors (GPU, CPU, FPGA, computer cluster) - if everything runs locally that's fine too though... The rules will always be trivially parallelizeable, refering only to a few neighboring cells within a small radius.
  • if the rules could be specified in some declarative/scripting language that would be nice too, but they should definitely be compiled down to machine code to leverage all the FLOPs the machine(s) have
  • millions of pixels can be shown at the same time (A: bonus points if it can merge adjacent cells at high zoom levels for a kind of multigrid/multiscale display)
  • the visualization and interaction framework works on Windows/Unix/Mac/iOS/Android (think Unity...); the computation rules work on basically anything...
  • simulation and visualization are decoupled - the visualization should only access the data that is currently visible and we can skip simulation-frames from visualization
  • Some simple UI widgets based on something like Dear ImGui/AntTweakBar can be used for interactive tweaking of simulation parameters

Here are some examples for the kinds of systems I would like to be able to implement with this:

Did you ever work on something like this? Are there (non-dead...) projects that do something like this out there? What should I combine to get there in a reasonable time? Any input is appreciated.

Should I use Unity? Should I look into some fractal/cellular simulation collection like Visions of Chaos https://softology.com.au/voc.htm ?

I imagine this kind of framework opens up the possibilities for tons of (scaleable) computational fun and exploration/experimentation for students and players alike.


Have a look at ready (reaction-diffusion, continuous cellular automaton) simulator: https://gollygang.github.io/ready/

It does not support an infinite grid with sparsity however, I believe.

You should definitely look into some numerical methods (higher-order integration methods in particular) in order to develop differential-equation integration schemes that are stable with large timesteps and over many generations/iterations. Verlet integration/leapfrog integration (second order) is the minimum for the wave equation. Look at this difference after just 25 iterations (timestep 0.5): Euler/FTCS: enter image description here Verlet/Leapfrog: enter image description here Other improved methods make more evaluations of the target function but do not require multiple past timesteps, e.g. the Lax–Wendroff method. This is a deep rabbit hole... If you don't want to cheat, you can only use "Relaxation"-type local methods for solving the differential equations you are interested in - global optimization is not allowed (domain decomposition and iterated kernels might get you a long way though).

For discrete cellular automata, Golly http://golly.sourceforge.net/ has you covered with the efficient hashlife algorithm supporting an infinite canvas an efficiently storing static/oscillating constellations. See also https://www.conwaylife.com/ .

  • Both of these only have very rudimentary "CAD" tools (formulas, static files & a paint tool) for generating the initial condition and changing the situation when the simulation is stopped, since this is not their focus. In that sense, they are definitely open for expansion. Your mileage may vary. – masterxilo Dec 29 '20 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.