Learn to Code
John F. Dumas
contact me | resume | how it works | example programs | testimonials | main page

C++ - Chaos Game


► Problem: In the chaos game, we begin with a square and place a point at one of the corners chosen at random. We then repeatedly choose a corner and plot the average of the previous point and the chosen corner.

Write a c++ program to implement the chaos game, use svg for output.


► Example Output:

Here is an example of the program's output when the current vertex cannot be chosen as the next iteration.

Here an example showing the results that occur when the current vertex cannot be the next vertex (counter-clockwise) from the previously chosen vertex.

Lastly, here's the picture that results when the next vertex cannot be two places away from the most recently chosen vertex.


Source code

All source files (zip file)


Back to Example Program Index


© John F. Dumas | johnfdumas@gmail.com | main page | top of page