Adding a Little More Chaos to the Chaos Game

The Chaos Game defines a set of attractors and an iterative process that moves a point towards a random attractor by a specified magnitude.

This image is generated by having five attactors, the points of a pentagon. At each iteration the current point moves towards a point on the pentagon by PHI (0.618) times the distance to the attractor.
Chaotic Pentagonal Fractal (PHI)

I wanted to see what would happen if the magnitude of attraction was also chaotic. At each stage of the algorithm a random attraction magnitude is chosen between [0.5,1.5].
Moving Target Chaotic Pentagonal Fractal

More Resources:
Mathworld Chaos Game Page
Wikipedia Chaos Game Page

[Update] Processing code to generate the shapes above:

var attractors = [];
var current = [random(800),random(800)]

for(var i = 0; i < 6; i++){
attractors.push([cos(i * 2 * PI/5) * 300, sin(i * 2 * PI/5) * 300]);
}

var attraction = 0.5;

void draw(){

translate(width/2, height/2);
rotate(PI/2);
stroke(0);

for(var i = 0; i < attractors.length; i++){
rect(attractors[0], attractors[1], 5,5);
}

for(var i = 0; i < 100; i++){
point(current[0],current[1]);
var target = attractors[Math.floor(Math.random() * (attractors.length-1))]
current[0] = current[0] - (current[0] - target[0]) * attraction;
current[1] = current[1] - (current[1] - target[1]) * attraction;
}

attraction = Math.random()+.5;

}

Advertisements
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

7 Responses to Adding a Little More Chaos to the Chaos Game

  1. Matt says:

    Cool pictures! Can you tell me what language you’re using here? Also, what’s the point of:

    attraction = Math.random()+.5;

    Isn’t that occurring after all your points have already been calculated?

    I’m having a some trouble recreating your random magnitude pictures, but I’m not sure what’s going wrong.

    How many points are you generating for each of those pictures? Perhaps I’m just not creating enough – I’ve been sticking to around 100,000, which is taking my computer about a minute to process each time I run it.

    —–

    By the way, I’m incredibly excited to see this work! I worked on the Chaos Game for my senior seminar in college, and come back to my code every once in a while to throw in a few new additions. Tried randomizing magnitudes a couple months ago, but I didn’t manage to get anything this cool. Can’t wait to see where you go with this!

    • Dimitri Tishchenko says:

      I am using processing.js in my web browser (chrome). I just checked over the source I posted here and it is not the code I used to generate the image. This code generates another image I posted here https://koozdra.wordpress.com/2011/11/07/1-5-magnitude-pentagon-chaos-game/. I am currently developing some code to make the chaos game interactive and will publish all the source then.

      I am plotting 100 points per frame. The html canvas component redraws already plotted points. I only have to plot new points.

      The image you see above is generated by creating chaos games starting from magnitude 0.5 to 1.5. Start at 0.5, wait till an image emerges, then slowly increment the magnitude till you hit 1.5. This carves out the paths that the configurations take. There is a bit of interference on the inside of the pentagon because magnitudes above 1 paint into the interior. If you take a look at my latest post you will see them broken down by inner and outer.

      What language are you using?

  2. Matt says:

    I’m using C++ and openGL currently, but could really use a complete overhaul of the program – it’s looking pretty messy at the moment.

    For my Senior Sem I was using the program mostly for DNA representations. You should check out that use if you haven’t already (though I bet you have):

    http://www.ncbi.nlm.nih.gov/pubmed/11331237

    Basically you can take the game with 4 vertices, and make the vertices A, T, C, and G, center the initial point at (.5, .5), and feed in DNA rather than using a random sequence.

    So you’re saying you have yours set up so that the user lets the program plot points at magnitude = 0.5 until they’re satisfied, then the program increments the magnitude slightly and they can let it plot more at that new level?

    • Dimitri Tishchenko says:

      Bioinformatics has always intrigued me. Really interesting stuff.

      That’s how I discovered these patterns. Now I just start at 0.5 and increment to one. When I get to one I start back at 0.5 and repeat the process until the image emerges. If you choose the magnitude change to be sufficiently small, you can paint the paths.

  3. Matt says:

    Ahhh, okay, that makes more sense. Yeah, I was just choosing a random magnitude with each new point I plotted – wasn’t getting anything particularly interesting. I’ll give this a try instead. What size increment in magnitude did you find to work the best?

    Also, where’d this idea for slowly incrementing come from in the first place?

    • Dimitri Tishchenko says:

      I was programming the chaos game and I made it so that I could change the magnitude when I pressed the up and down keys. I made a mistake and didn’t put in the code to clear the screen when I changed the magnitude. These interesting patterns emerged.

      I chose my magnitude change to be 0.001.

      When you were choosing a random magnitude what range were you using?

      • Matt says:

        Isn’t it amazing how often mistakes drive innovation? I’d originally been using 0.0 to 1.0 for my range before I saw your work here. Last night I was trying to recreate what I thought you were doing and was setting up a range from 0.5 to 1.0, then one from 1.0 to 1.5. Got a couple interesting pictures. Here’s one from when I was choosing random magnitudes between 0.5 and 1.0 for each point plotted:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s