Chaos Game Regular polygon of any size
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
Thhis is using NetLogo to play the Chaos Game. In the Game, using two very simple rules, beautiful fractal pictures are generated. The rules are: In a regula polygon of n number of side, it has n number of apices. Into that space, a random spot is chosen as the starting point. Throw a die, and depending on the result of the throw, the next point chosen will be along the line that leads from that point to the indicated apex. How far along that line is the point going to be placed? In the original Chaos Game with the triangle, the point is midway along that ine, or r = 0.5. But that could be changed.
HOW IT WORKS
This program allows one to experiment with regular polygons of virtually any number of sides up to 360.
HOW TO USE IT
Select the number of sides you want the polygon to be by using the slider number-of-sides.Then choose "r" as mentioned above by using the slider "factor"
THINGS TO NOTICE
The classical Chaos Game was done on a triangle with r = 0,5 and it results in the Sierpenski triangle. Try the other polygons, and vary the "factor"
THINGS TO TRY
Try the other polygons and vary the "factor"
EXTENDING THE MODEL
what if the "factor" itself is a random number during the run. Try changing the code and see.
NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest)
CREDITS AND REFERENCES
Written by Dr. Ronald P. Ng Singapore (e-mail address: ronaldpaul.ng@gmail.com
Comments and Questions
globals [turtleX
         turtleY
         newXcor  ; the new xcor which the turtle will go to
         newYcor  ; the new ycor which the turtle will go to
         turtleDistance ; thd distance the turtle has to travel
         worldLength
        ]
to setup
  ca
  ;; with the worldLength, excessLength and octogonSide length set up, these data will be used
  ;; in defining the points of the octogon
  set worldLength max-pxcor  ;; that being the size of the world
  crt 2 [
          set color white
          set size 10]
  ask turtle 0 [setxy random-xcor random-ycor
                hide-turtle]
  ask turtle 1 [setxy 0 0
                face patch 0 160
                hide-turtle
                ]
  reset-ticks
end 
to go
  find-new-position ;use tutle 1
  set turtlex  [xcor] of  turtle 0
  set turtley [ycor] of turtle 0
  ask patch turtlex turtley [set pcolor green]
  move-new-position
  if ticks > max-ticks [stop]
  tick
end 
to move-new-position
  ask turtle 0 [set turtleDistance distancexy newXcor newYcor
                             face patch newXcor newYcor
                             fd turtleDistance * factor ]
  ask patch newXcor newYcor [set pcolor green]
end 
to find-new-position
  let random-turn random number-of-sides * (360 / number-of-sides)
  ask turtle 1 [rt (random-turn)
                fd 380]
    set newXcor  [xcor] of turtle 1
    set newYcor  [ycor] of turtle 1
  ask turtle 1 [setxy 0 0
                face patch 0 380]
end 
There is only one version of this model, created over 2 years ago by Ronald Paul Ng.
Attached files
| File | Type | Description | Last updated | |
|---|---|---|---|---|
| Chaos Game Regular polygon of any size.png | preview | Preview for 'Chaos Game Regular polygon of any size' | over 2 years ago, by Ronald Paul Ng | Download | 
This model does not have any ancestors.
This model does not have any descendants.
 
  Download this model
Download this model