How to resolve the algorithm Chaos game step by step in the Action! programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Chaos game step by step in the Action! 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 Action! programming language

Source code in the action! programming language

PROC Main()
  INT x,w=[220],h=[190]
  BYTE y,i,CH=$02FC,COLOR1=$02C5,COLOR2=$02C6

  Graphics(8+16)
  Color=1
  COLOR1=$0C
  COLOR2=$02

  x=Rand(w)
  y=Rand(h)
  DO
    i=Rand(3)
    IF i=0 THEN
      x==/2
      y==/2
    ELSEIF i=1 THEN
      x=w/2+(w/2-x)/2
      y=h-(h-y)/2
    ELSE
      x=w-(w-x)/2
      y=y/2
    FI
    Plot((320-w)/2+x,191-y)
  UNTIL CH#$FF
  OD
  CH=$FF
RETURN

  

You may also check:How to resolve the algorithm 100 doors step by step in the Julia programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the Zig programming language
You may also check:How to resolve the algorithm Animate a pendulum step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Bulls and cows step by step in the F# programming language
You may also check:How to resolve the algorithm Read a file character by character/UTF8 step by step in the FunL programming language