# Searching for pleasing looking Flame Fractals

Flame Fractals were originally developed by Scott Draves as an extended version of Iterated Function Systems.

See this PDF for a more thorough explanation.

Visions of Chaos has supported flames for years now, but something I recently revisited was detecting interesting looking flame fractals.

The flame fractals appearance are controlled by the coefficients, probabilities, transformations and multiplier values (the lower table floating point values in the above dialog), but 99% of the time if you just set random values it will lead to boring images. Boring here means an image that is just a few straight lines, a circle, or only a few pixels.

Searching for an interesting flame fractal means repeatedly randomizing the controlling parameters and testing the resulting plotted points. Here is a snippet of code I use to test each random set of parameters.

``````
xp:=0.05;
yp:=0.05;
//skip first 1000 iterations to allow it to settle down
for loop:=1 to 1000 do iterate_point;

repeat
thisxp:=xp;
thisyp:=yp;

//iterate the next point
iterate_point;

//test if tending to a point
if (abs(thisxp-xp)<1e-10) and (abs(thisyp-yp)<1e-10) then
begin
TestFlameParameters:=false;
exit;
end;

//check if unbounded, ie values are getting too large
if (abs(xp)>10000) or (abs(yp)>10000) then
begin
TestFlameParameters:=false;
exit;
end;

//check for NAN
if (isnan(xp)) or (isnan(yp)) then
begin
TestFlameParameters:=false;
exit;
end;

//check for INF
if (isinfinite(xp)) or (isinfinite(yp)) then
begin
TestFlameParameters:=false;
exit;
end;

//count pixels that fall within the image area
if (xp<xmax) then
if (xp>xmin) then
if (yp<ymax) then
if (yp>ymin) then
begin
xplot:=trunc((xp-xmin)/abs(xmin-xmax)*width);
yplot:=trunc((yp-ymin)/abs(ymin-ymax)*height);
hitpixelscount[xplot,yplot]:=hitpixelscount[xplot,yplot]+1;
end;

inc(pointcount);

until (pointcount=250000);

//count pixels hit
hits:=0;
for y:=0 to height-1 do
for x:=0 to width-1 do
if hitpixelscount[x,y]>5 then inc(hits);
if hits<trunc(width*1.5+height*1.5) then
begin
TestFlameParameters:=false;
exit;
end;
//if it got to here then the tests all passed
```
```

The tests included in the code and the ones I found most useful are;

1. Detect tending to a single point. A lot of flames result in the iterations being attracted to a single point/pixel.
2. Unbounded. Points continue to grow outwards to infinity.
3. NAN and INF. If the floating point math returns a NAN or INF.
4. Count pixels hit. If the resulting image has too few pixels the flame picture will be boring. Counting the pixels helps detect and avoid these flames.

Using those 4 checks will skip hundreds (at least in my case) of parameters that fail one or more of the above tests. The result is when looking for new random flame fractals you skip the boring point-like and line-like displays.

The following screen shot of the flame mutator in Visions of Chaos shows a series of flames that all passed the tests. They may not all be interesting aesthetically, but there are no minimal results with just a small number of pixels.

I did also experiment with lyapunov values, ie
http://technocosm.org/chaos/attr-part2.html
http://sprott.physics.wisc.edu/software.htm
but in my tests they are too unreliable to detect good vs boring flames.

If you know of any other reliable ways to detect good vs bad/boring flame fractals, let me know by email or reply to this post.

Jason.

# Stochastic Cellular Automata

Stochastic Cellular Automata (also referred to as Probabalistic Cellular Automata or Random Cellular Automata) are cellular automata that introduce some form of randomness.

For example, the usual Game Of Life CA uses the rule 23/3. If a live cell has 2 or 3 neighboring live cells it survives. If a dead cell has exactly 3 live neighbors a new cell is born at that location. This sort of rule is called deterministic as there is no random chance involved. To make the rule stochastic we can introduce a probability for the rules. The 3 for a cell to be born could have a 90% probability applied. Now if an empty cell has 3 living neighbors it will only be born if a random value is less than the 90% probability.

When implementing the interface for stochastic CA, rather than the usual 3D Cellular Automata settings;