Indexed Totalistic Cellular Automata

Inspiration

This new form of Cellular Automata (at least they are new to me) came from a Tumblr post from Neil Makes Games (@NKnauth on Twitter). His post refers to @LorenSchmidt on Twitter, but I could not find the original post. There is enough info in Neil’s post to let me implement and experiment with these CAs.

Due to lack of a name and because I made some changes to the implementation I called them “Indexed Totalistic Cellular Automata”. The rule is totalistic in that it uses the total counts of neighbor cells to determine the new cell state, and the state counts act as an index into the rule array.

Define the rule

The rule for these CAs are based on a 2D rule table like the following.

Indexed Totalistic Cellular Automaton

The table is mapped to a 9×9 2D rule array of integers. That covers all possible state 1 and state 2 cell counts. There is no “fade out” or “die off” period where cells that “die” go into a semi-dead state before fully dying. All cell updates are based solely on the rule table.

Filling the grid array

The original used values between 1 and 3 to fill the grid. I use between 0 and 3. The different results of including and excluding the 0 are outlined below.

Processing the grid each step

Count the state 1 and state 2 cells in the immediate 8 cell Moore Neighborhood.

Use the state 1 and state 2 counts as an index into the rule array, ie result=rule[state1count,state2count]

If the result is 3 then the cell remains the same. If the result is 1 or 2 then the cell becomes 1 or 2. In the original CA there is no state 0 in the rule array, but I added it in so that if the result is 0 the cell becomes empty.

Results

From an initial experiment with these I have seen some interesting results. Click the following images to see an animated gif of the CAs.

There are many unique gliders.

Indexed Totalistic Cellular Automaton

And this fireworks doily like display

Indexed Totalistic Cellular Automaton

Extending the neighborhood size

I also played with extending the Moore Neighborhood to all cells within 2 grid distances (total of 24 possible neighbors).

Indexed Totalistic Cellular Automaton

The extended neighborhood tends to give more blobbly amoeba results. Although I have only started to experiment with these CAs so more unique outcomes should hopefully pop up in the future.

Indexed Totalistic Cellular Automaton

Indexed Totalistic Cellular Automaton

Availability

These new CAs are now included with Visions of Chaos. If you do find any new interesting rules, let me know.

Jason.

Visions of Chaos now supports Pixar RenderMan

Visions of Chaos can now use Pixar‘s Free Non-Commercial RenderMan to render 3D scenes.

This is the same RenderMan engine used in movies like Finding Dory

Finding Dory Screenshot

and Rogue One

Rogue One Screenshot

I am only using a tiny fraction of RenderMan’s features. Rendering millions of spheres or cubes with nice shading and lighting covers my requirements, but it is good to know that I have the extra power of RenderMan to expand if needed in the future.

All the end user needs to do is download the stand-alone Pixar RenderMan and point Visions of Chaos to the main command line RenderMan prman.exe renderer file. After that Visions of Chaos constructs the RIB format files RenderMan understands and gets prman to render the images.

Currently RenderMan support is added to the following Visions of Chaos modes;

3D Ant Automata

3D Ant Automaton

3D Cyclic Cellular Automata

3D Cyclic Cellular Automaton

3D Cellular Automata

3D Cellular Automaton

3D Hodgepodge Machine

3D Hodgepodge Machine

3D Hodgepodge Machine

3D Voxel Automata Terrain

Voxel Automata Terrain

3D Diffusion-Limited Aggregation

3D Diffusion-Limited Aggregation

3D Cube Divider

Cube Divider

RenderMan seems to be able to handle a massive number of objects so far. This next test 4K image was over 33 million little cubes. RenderMan churned away for over 2 hours on this one image. The main slowdown was my lack of memory and constant hard drive paging. 32 GB of RAM just does not cut it when rendering this sort of data. The RIB scene file alone was 13 GB.

Voxel Automata Terrain

RenderMan is slower than Mitsuba at this stage. But that could be down to any number of reasons including my lack of RenderMan knowledge.

Jason.

Eroding Fractal Terrains with Virtual Raindrops

A long while back I added a very simplistic fractal terrain simulator to Visions of Chaos. I had an idea to try and add erosion simulation into the existing code to get some more realistic terrain shapes.

Generating the inital terrain

There are many ways to generate a terrain height array. For the terrain in this post I am using Perlin noise.

This is the 2D Perlin Noise image…

Fractal Terrain

…that is extruded to the following 3d terrain…

Fractal Terrain

An alternative method is to use 1/f Perlin Noise that creates this type of heightmap…

Fractal Terrain

..and this 3D terrain.

Fractal Terrain

Simulating erosion

Rather than try and replicate some of the much more complex simulators out there for wind and rain erosion (see for example here, here and here) I experimented with the simplest version I could come up with.

1. Take a single virtual rain drop and drop it to a random location on the terrain grid. Keep track of a totalsoil amount which starts at 0 when the drop is first dropped onto the terrain.
2. Look at its immediate 8 neighbors and find the lowest neighbor.
3. If no neighbors are lower deposit the remaining total soil carried and stop. This lead to large spikes as the totalsoil was too much. I since changed the drop rate to the same as the fixed depositrate. Technically this removes soil from the system, but the results are more realistic looking terrain.
4. Pick up a bit of the soil from the current spot (lower the terrain array at this point).

soilamount:=slope*erosionrate;
totalsoil:=totalsoil+soilamount;
heightarray[wx,wy]:=max(heightarray[wx,wy]-soilamount,0);

5. Move to the lowest neighbor point.
6. Deposit a bit of the carried soil at this location.

deposit:=soilamount*depositrate/slope;
heightarray[lx,ly]:=heightarray[lx,ly]+deposit;
totalsoil:=max(totalsoil-deposit,0);

7. Goto 1.

Repeat this for millions of drops.

The erosion and deposit steps (4 and 6 above) simulate the water flowing down hill, picking up and depositing soil as it goes.

To add some wind erosion you can smooth the height array every few thousand rain drops. I use a simple convolution blur every 5000 rain drops. This smooths the terrain out a little bit and can be thought of as wind smoothing the jagged edges of the terrain down a bit.

Erosion Movie

Here is a sample movie of the erosion process. This is a 13,500 frame 4K resolution movie. Each frame covers 10,000 virtual raindrops being dropped. This took days to render. 99% of the time is rendering the mesh with OpenGL. Simulating the raindrops is very fast.

and here are screenshots of every 2000th frame to show the erosion details more clearly.

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Fractal Terrain

Future ideas

The above is really just a quick experiment and I would like to spend more time on the more serious simulations of terrain generation and erosion. I have the book Texturing and Modeling, A Procedural Approach on my bookshelf and it contains many other terrain ideas.

Jason.

3 Years Of Softologyblog

3rd year anniversary

Today marks the 3rd anniversary of this blog. Over that time I hope it has been interesting for those who happen to check in and read it from time to time. When I started I wasn’t sure what the contents would be, but once you get blogging it all seems to flow.

I do recommend everyone try blogging. Pick whatever topic(s) you have a passion for and blog away. I tend to use mine as a journal of my ongoing progress with Visions Of Chaos with some interesting info for fellow nerds. It is always great when someone takes some info here, extends it and lets me know about it. That is the true shared knowledge power of the Internet at work.

Jason.

Venus Transit footage from SDO

Here is an awesome movie showing the transit of Venus yesterday.

Watch in highest def possible full screen.

More info about the movie with higher resolution movies and images to download here.

Thanks to The Bad Astronomer for the link. I knew that Phil would find the best example of the transit after it was all over and he didn’t let us down.

Jason.

Shared Knowledge

I have been meaning to post about this for a long time.

In the past I used to keep my latest secrets secret. As a developer writing fractal software (or any other software) you want your application to have those “wow” features that no other app can duplicate.

That was a simple-minded and foolish belief. The entire evolution and progress of the human existance is based on people sharing their knowledge and discoveries.

Fractal Forums (actually there is only the one forum, so maybe it should be Fractal “Forum”) was one of the major things that changed my mind. Seeing people happily sharing ideas and developing them together that lead to incredible discoveries (outside the usual scientific community and peer-reviewed papers) was a welcome breath of fresh air. The original thread covering how the Mandelbulb was discovered shows this process.

Ever since then I have tried my best to share and explain ideas and it has been a very constructive and inspirational experience. Many a time I have shared a snippet of code with another chaos enthusiast who wanted to implement the same thing in their own code. The majority of the time they are very grateful and usually find a new twist to the code or idea I never would have had. This creates the feedback effect of leading to knew ideas that neither of us could have created before.

With this blog I have tried to change from making it an advert for a new release of Visions Of Chaos into a place I can hopefully help others understand the (relatively) simple maths behind chaos theory related ideas so they can enjoy and understand these principals themselves and (most importantly) come up with new ideas and advance the field.

Before the Internet was out there and when I was originally interested in fractals and chaos I only had books from the library to rely on to try and understand and learn how these ideas worked. The first real inspiration was Gleik’s Chaos that really got me into trying to code software to create those simple things like Mandelbrot Sets and Lorenz Attractors. Since the Internet that has all changed. The incredible result of shared knowledge is mind blowing. Whatever obscure topic you are interested in will be covered by someone else out there. You can usually find PDF versions of important papers on any topic. CiteSeer is an excellent resource when researching papers. If that doesn’t work a Google search for “paper name” pdf will usually find a cached copy somewhere. Sites like Open Processing.org are brilliant with source code to explain how an idea works.

All of this does lead to attribution. If you do share an idea then it can (and usually will) lead to someone using that idea and (in the worse case) calling it their own. This can be discouraging, but don’t let it get you down. I try my best to cite the original sources when I develop a new bit of code. Everyone likes to know that their knowledge and ideas were appreciated and repsected.

Another sig at Fractal Forums included “I beg of you to enrich others as you have been enriched” and I think that sums it up. Without the vast pool of knowledge out there I would have never been able to add all the features into Visions Of Chaos that I have so far and will into the future.

Share the knowledge.

Jason.

Dots Maker

The game of Dots and Boxes has been around for many years and no doubt most people played it as a kid.

I was recently having a few games with a mate of mine over some beers and we both realised how tedious the initial setup phase of the game is (initially drawing up the grid of dots and then filling in the random spots until you reach the “end game” of actually using some strategy to fill in the boxes). So after some hacking I wrote a simple app to generate and print game setups.

The first version makes a “perfect” setup in which every move is going to give the oponent a completed box.

That worked OK, but it came down filling in the single boxes, then the doubles, then the triples etc without any chance for a free move to be found.

If the Perfect checkbox is unchecked then after the initial perfect setup is generated there is a 1 in 4 chance of existing walls being removed. This allows a few free moves before the end game begins.

There has been some extensive analysis into the game and many strategies exist for good gameplay.

I had always played the rule that if you can complete a box you have to. Apparently this is the simpler version of the game and the real rules state you do not have to take a box unless you want to. Playing this version opens up many more strategies (see previous strategies link).

If you want to try the app, grab it here. Single exe, just download and run it. It detects the optimal grid size for your current printer when you start it up.

Jason.