Wolfram Function Repository
Instantuse addon functions for the Wolfram Language
Function Repository Resource:
Create fractals by random partial jumps toward reference points
ResourceFunction["GeneralizedChaosGame"][reg,n] plots a fractal by iteratively jumping n times toward a random point inside the reference geometry reg by jumping halfway. 

ResourceFunction["GeneralizedChaosGame"][reg,n,jspec] uses the jumping specification jspec. 

ResourceFunction["GeneralizedChaosGame"][reg,n,jspec,format] formats the result according to the output specification format. 
n  n points equally spaced around the unit circle 
{p_{1},p_{2},…}  uses the points p_{i} as the reference geometry 
reg  uses the region reg as the reference geometry 
n  performs n iterations 
Automatic  performs 10^{4} iterations 
α  jumps a distance α toward the next reference point 
Scaled[α]  jumps a fraction α toward the next reference point 
Automatic  jumps halfway toward the next reference point 
{s_{1},s_{2},…}  cycle through the jumping specifications s_{i} 
{"OriginIndexed", {s_{1},s_{2},…s_{n}}}  jump using jump specification s_{i}, where i is the index of the last visited reference point 
{“DestinationIndexed”, {s_{1},s_{2},…s_{n}}}  jump using jump specification s_{i}, where i is the index of the next reference point 
func  uses the function func to calculate the next position 
"Graphics"  outputs a graphical representation of the results 
"List"  outputs the list of coordinates visited 
"DensityPlot"  outputs a graphical representation of the density of points 
"PointStyle"  Automatic  style to use for the points 
"ReferenceGeometryStyle"  Automatic  style to use for the reference geometry 
"Probabilities"  Automatic  list of probabilities representing the chance to jump to each reference point 
"ExclusionRegionFunction"  None  jumps that land on positions for which the function yields true are not allowed 
"Choices"  All  restrict the possible points to jump to based on the current position or history 
"ColorFunction"  Automatic  will use the color function ColorFunction as defined in ArrayPlot 
"BinningSpecification"  Automatic  a list of binning specifications to use for the output format 
"Absolute"→{b_{1},b_{2},…,b_{n}}  restrict the jump to the reference points p_{i} for which b_{i} is True 
"Relative"→{b_{1},b_{2},…,b_{n}}  restrict the jump to the reference points p_{i} (counted relative to the last position) for which b_{i} is True 
{{x_{min},x_{min},dx}, {y_{min},y_{max},dy}}  bins using the xspecification and yspecification 
{ dx , dy }  bins the data in bins of size dx by dy 
Create the classic Sierpinski triangle using 30,000 iterations:
In[1]:= 

Out[1]= 

Jump only 40% of the way toward the reference points:
In[2]:= 

Out[2]= 

Jump between 4 corners of a trapezoid:
In[3]:= 

Out[3]= 

Jump between random points on a circle:
In[4]:= 

Out[4]= 

Give the geometry as a list of points:
In[5]:= 

Out[5]= 

The reference geometry can be any region, e.g. a Line:
In[6]:= 

Out[6]= 

Perform the chaos game in higher dimensions:
In[7]:= 

Out[8]= 

Combine different regions using RegionUnion:
In[9]:= 

Out[9]= 

The default jump specification is Scaled[0.5]:
In[10]:= 

Out[10]= 

In[11]:= 

Out[11]= 

Perform the chaos game using a 40% jump:
In[12]:= 

Out[12]= 

Perform the chaos game using a jump with a distance of 0.7:
In[13]:= 

Out[13]= 

Alternating between a fractional and a distance jump to create a blurry Sierpinski triangle:
In[14]:= 

Out[14]= 

Alternating between a fractional and a distance jump creates a different result compared to the individual specifications:
In[15]:= 

Out[15]= 

Jump 50%, 60% or 40% if the last reference point was point 1, 2 or 3, respectively:
In[16]:= 

Out[16]= 

Jump 50%, 60% or 40% if the next reference point is point 1, 2 or 3, respectively:
In[17]:= 

Out[17]= 

Jump halfway toward each point, except for the top one; jump distance 1.75 then:
In[18]:= 

Out[18]= 

Use a pure function to get a combination of fractional and distance jumping:
In[19]:= 

Out[19]= 

Use more complicated functions:
In[20]:= 

Out[20]= 

In[21]:= 

Out[21]= 

The default is a graphical output:
In[22]:= 

Out[22]= 

Obtain the results as a list and perform an operation on it:
In[23]:= 

Out[24]= 

Output a density plot instead:
In[25]:= 

Out[25]= 

Change the style of the points:
In[26]:= 

Out[26]= 

Change the style of the reference geometry:
In[27]:= 

Out[27]= 

In[28]:= 

Out[28]= 

Change the probability to jump to each reference point:
In[29]:= 

Out[29]= 

Restrict certain landing locations:
In[30]:= 

Out[30]= 

Restrict the point to fall in a circle at the top:
In[31]:= 

Out[31]= 

Allow to only jump 1, 3 or 4 reference points ahead as compared to the last reference point:
In[32]:= 

Out[32]= 

Allow to only jump to points 2, 3 or 4:
In[33]:= 

Out[33]= 

Make the choices depend on its history. Do not allow to jump 1 ahead from the last reference point and 3 ahead from the penultimate reference point:
In[34]:= 

Out[34]= 

Make the choices depend on the last visited reference point:
In[35]:= 

Out[35]= 

For a density plot we can specify the color function used:
In[36]:= 

Out[36]= 

The default is the rainbow color function:
In[37]:= 

Out[37]= 

For a density plot we can specify the binning specification:
In[38]:= 

Out[38]= 

Or specify just the size of the bins:
In[39]:= 

Out[39]= 

Explore jumping in different dimensions. Calculate the jumping in (hyper)spheres in 2D–8D, and then plot the histogram of the distance from the center:
In[40]:= 

Out[40]= 

In[41]:= 

Out[44]= 

Produce the Sierpinski triangle as in a rule 90 cellular automaton:
In[45]:= 

Out[45]= 

In[46]:= 

Out[46]= 

The reference geometry might occlude all the points:
In[47]:= 

Out[47]= 

Use the option ReferenceGeometryStyle to make the points visible:
In[48]:= 

Out[48]= 

For a onedimensional chaos game, explicit braces are needed:
In[49]:= 

Out[49]= 

In[50]:= 

Out[50]= 

For each possible choice, there should be at least one element of True:
In[51]:= 

Out[51]= 

The "Choices" option cannot be used when the region is not points:
In[52]:= 

Out[52]= 

The "Probabilities" option cannot be used when the region is not points:
In[53]:= 

Out[53]= 

Recreate the Barnsley fern:
In[54]:= 

Out[61]= 

Jump halfway and jump a distance of 0.2 in the perpendicular direction:
In[62]:= 

Out[62]= 

Excluding a wolfshaped portion of the domain results in a fractal of wolves:
In[63]:= 

Out[65]= 

Perform a halfway step and a perpendicular step of 0.1:
In[66]:= 

Out[66]= 

Perform a halfway step and a scaled perpendicular step:
In[67]:= 

Out[67]= 

Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License