``` ----------------

home

Balloting

Simple trig

Logistic map

The Attractor of Henon

Number doubling

Barnsley's Fern

The Sierpinski Triangle

The Sierpinski Triangle  (The Sierpinski Gasket) A simple three part algorithm, which incorporates
randomly selected parts of the algorithm, produces
a triangular lattice of triangles.

I tried doing this with an orderly, alternating
selection of the parts of the algorithm as follows:

cnt = cnt + 1
If cnt = 1 Then GoTo 100
If cnt = 2 Then GoTo 200
If cnt = 3 Then cnt = 0: GoTo 300

and it did nothing but produce a few dots
along the bottom of the screen.

I then preceded the above code with the following section
of code so as to complicate the selection process in a
crazily complex manner:

k4 = k4 + 1: If k4 > 9 Then k4 = 0: k2 = k2 + 1: cnt = cnt + 5: If cnt > 2 Then cnt = 0
k3 = k3 + 1: If k3 > 8 Then k3 = 0: k1 = k1 + 3: cnt = cnt - 2: If cnt > 2 Then cnt = 0
k2 = k2 + 1: If k2 > 2 Then k2 = 0: m7 = m7 + 4: cnt = cnt + 3: If cnt > 2 Then cnt = 0
k1 = k1 + 1: If k1 > 7 Then k1 = 0: m5 = m5 + 2: cnt = cnt + 1: If cnt > 2 Then cnt = 0
m9 = m9 + 1: If m9 > 3 Then m9 = 0: m2 = m2 + 1: cnt = cnt - 1: If cnt > 2 Then cnt = 0
m8 = m8 + 1: If m8 > 4 Then m8 = 0: m1 = m1 + 4: cnt = cnt + 4: If cnt > 2 Then cnt = 0

m7 = m7 + 1: If m7 > 3 Then m7 = 0: m6 = m6 + 2: cnt = cnt + 1: If cnt > 2 Then cnt = 0
m6 = m6 + 1: If m6 > 4 Then m6 = 0: m2 = m2 + 1: cnt = cnt - 1: If cnt > 2 Then cnt = 0
m5 = m5 + 1: If m5 > 9 Then m5 = 0: m1 = m1 + 3: cnt = cnt + 3: If cnt > 2 Then cnt = 0
m4 = m4 + 1: If m4 > 8 Then m4 = 0: m3 = m3 + 1: cnt = cnt + 1: If cnt > 2 Then cnt = 0
m3 = m3 + 1: If m3 > 5 Then m3 = 0: m2 = m2 + 2: cnt = cnt - 2: If cnt > 2 Then cnt = 0
m2 = m2 + 1: If m2 > 6 Then m2 = 0: m1 = m1 + 4: cnt = cnt + 5: If cnt > 2 Then cnt = 0
m1 = m1 + 1: If m1 > 2 Then m1 = 0: cnt = cnt + 1: If cnt > 2 Then cnt = 0

and the result was a ghost of the Sierpinski triangle: When the equations are selected according to a regimen,
even a complicated one, the output eventually goes into
a loop.  The points of the output land on the Sierpinski
grid, but are limited by the loop in which the output
is trapped.

Here are snippets from a couple websites explaining the
algorithm:

http://math.bu.edu/DYSYS/chaos-game/node1.html

One of the most interesting fractals arises from what
Michael Barnsley has dubbed "The Chaos Game".  The chaos
game is played as follows:  First pick three points at
the vertices of a triangle (any triangle works - right,
equilateral, isosceles, whatever). Color one of the
vertices red, the second blue, and the third green.

Next, take a die and color two of the faces red, two
triangle. This point is the  seed for the game.
(Actually, the seed can be anywhere in the plane,
even miles away from the triangle.) Then roll the
die. Depending on what color comes up, move the seed
half the distance to the appropriately colored vertex.
That is, if red comes up, move the point half the
distance to the red vertex. Now begin again, using the
result of the previous roll as the seed for the next.
That is, roll the die again and move the new point
half the distance to the appropriately colored vertex,

https://thatsmaths.com/2014/05/22/the-chaos-game/

Fix three points in the plane, C1, C2 and C3.  For
definiteness, we take the points C1 = (0, 0),
C2 = (1, 0) and C3 = (0.5, v3/2), the corners of an
equilateral triangle.

Pick any point P0 and draw a dot there. This is
our starting point. At each stage, we denote the
current point by Pk and call it the game point.

Roll the dice. If n comes up, draw a point half
way between Pk and Cn. For example, if we roll a 2,
we pick the point half way between the current
point Pk and C2. This is the new game point.

Repeat this procedure many times, drawing a new
point at each step.

===================================================

Here is my VisualBASIC program code:

Private Sub chaosbtn_Click()

ITER = Val(itera.Text)

X1 = 0
Y1 = 0
X2 = 700
Y2 = 0
X3 = 350
Y3 = 606

XS = 280
YS = 490

Randomize Timer

For a = 1 To ITER

RN = Rnd(1)

If RN < 0.3333333 Then GoTo 100
If RN < 0.6666667 Then GoTo 200
GoTo 300

100:
XS = (X1 + XS) / 2
YS = (Y1 + YS) / 2
GoTo 500

200:
XS = (X2 + XS) / 2
YS = (Y2 + YS) / 2
GoTo 500

300:
XS = (X3 + XS) / 2
YS = (Y3 + YS) / 2

500:
TX = XS + 20
TY = -YS + 1050   REM  Transforms the y axis

viewport.PSet (TX, TY), RGB(0, 0, 0)

Next a

End Sub

============================================================

home

Balloting

Simple trig

Logistic map

The Attractor of Henon

Number doubling

Barnsley's Fern

The Sierpinski Triangle

```