How to resolve the algorithm Chaos game step by step in the Run BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Chaos game step by step in the Run BASIC programming language

Table of Contents

Problem Statement

The Chaos Game is a method of generating the attractor of an iterated function system (IFS). One of the best-known and simplest examples creates a fractal, using a polygon and an initial point selected at random.

Play the Chaos Game using the corners of an equilateral triangle as the reference points.   Add a starting point at random (preferably inside the triangle).   Then add the next point halfway between the starting point and one of the reference points.   This reference point is chosen at random. After a sufficient number of iterations, the image of a Sierpinski Triangle should emerge.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Chaos game step by step in the Run BASIC programming language

Source code in the run programming language

x	= int(rnd(0) * 200)
y	= int(rnd(0) * 173)
graphic #g, 200,200
#g color("green")
for i =1 TO 20000
	v = int(rnd(0) * 3) + 1
	if v = 1 then
		x = x/2
		y = y/2
	end if
	if v = 2 then
		x = 100 + (100-x)/2
		y = 173 - (173-y)/2
	end if
	if v = 3 then
		x = 200 - (200-x)/2
		y = y/2
	end if
	#g set(x,y)
next
render #g

  

You may also check:How to resolve the algorithm Loops/For with a specified step step by step in the 11l programming language
You may also check:How to resolve the algorithm Riordan numbers step by step in the Sidef programming language
You may also check:How to resolve the algorithm Tokenize a string step by step in the Mercury programming language
You may also check:How to resolve the algorithm Greyscale bars/Display step by step in the Wren programming language
You may also check:How to resolve the algorithm String comparison step by step in the Java programming language