Classic Chaos & Code

chaos.jpg

Today's blog brings back a classic game from back in the day and gives it a new modern twist by adding some coding fun.  The game is the Chaos Game and, if you haven't heard of it before or used it with your students, then you are in for a treat!

Chaos theory is a relatively new field in mathematics and is usually defined as the study of nonlinear dynamics -- in plain English, the study of (seemingly) random events.  It's a fascinating field because humans tend to have difficulty with randomness.  Lots of fun research has shown that we (humans) are really not good at identifying random stuff and that we will make one of two common errors:  we "see" patterns where there are none and we "miss" patterns that are there.  You may have heard of these concepts through examples like "the butterfly effect" and even the "infinite monkeys theorem".  I like to bring up chaos theory with teachers I work with because:

  • It's a nice reminder that mathematics is an ever-evolving field and students like hearing about more recent developments
  • It's a wonderful field of mathematics for visualization and "seeing" pattern or order come from what seems to be chaos
  • After Jurassic park, the whole realm of fractals became very "cool" with students
  • It's a wonderful resource of "where will I ever use this?" examples since chaos theory has real-life applications in many things including weather, engineering, biology, and environment

The specific activity I use to introduce chaos theory and fractals is the Chaos Game because it has such a surprising outcome (a common element in many areas of chaos theory).

In working with teachers who are just getting started with incorporating educational technology, especially programming (more hiply referred to as "coding" today), I have used this as my "go-to" activity.  Here's why:

  1. It's FUN (and quite addictive)
  2. It can be done via "low tech" (indeed, even "no tech") methods initially 
  3. When you DO incorporate the technology, it vividly demonstrates the power of using it over manual methods

There are many mathematics topics that teachers can incorporate into a lesson involving the Chaos Game, these include:

  • Plotting points
  • Calculating distance between two points
  • Calculating the midpoint of a segment given the two endpoints
  • Pattern recognition
  • Perimeter and area calculations
  • Recursion
  • Iteration
  • Probability

How to Play

I like starting no-tech and hands-on with the game and that is the advice I give teachers as well.  Using the triangle template (shown in the graphic at the beginning of the blog), make a set of transparencies (enough so each pair of students will have one).  Each pair will also need a die and a non-permanent marker (fine point).  After you distribute the materials, go over the rules to the game (conveniently printed on the transparency as well), and have each pair plot a minimum number of points.  Most ages I choose 20 as the number, but you may choose higher or lower depending upon how good your students are at plotting points, following directions, estimating midpoints, and staying on task.

As your students are playing, walk around the room and ask them what they see.  I love this part when I play with teachers because it ends up being a fun Rorschach test kind of activity!  I'm always amazed at what people see and notice while playing this game.

After the pairs have plotted their minimum number of points (or after you've called time, whichever comes first), guide the students in exploring the randomness of the points.  First, have the blank triangle template on the overhead and ask students questions about randomness: what IS random? Are the points generated in this game random? etc.  Then, ask them if they saw any pattern or order arising in their triangle as they played the game.  One pair at a time, have them come and carefully place their transparency on top of the blank one.  As each set of points is added to the triangle being displayed to the class, ask open-ended questions about what they notice and what they see.  After the final transparency is added to the pile, get a consensus from your class as to whether they think there really is a pattern "in there" or not.  In my experience, answers have varied from "it's nothing, it's random" to "I see a heart" or  "I see a triangle" or "I see several triangles pointing in different directions".  The goal here is not to get "the right answer" but rather to continue the conversation and explore the ideas of pattern and chaos.  

Bring on the Code!

Depending upon the number of people playing and the total number of points you end up with in your triangle, it is quite possible that you and your students will see no discernible pattern.  That's a good thing!  It gives you the chance to incorporate technology and show your students the power of having a computer plot the points for us!

I usually present the next part of the activity with a comment like, "What if we had more people plotting more points -- do you think that a pattern would emerge then?"  What's wonderful is that, most of the time, everyone looks annoyed at this prospect and may even say things like, "I don't want to plot any more points!"  Then I can deliver the good news:  we don't have to do it, we can use technology to do it for us!

There are many choices for which technology to use in the next part of the activity, but I like to start with the TI graphing calculator.  I like this choice because I enjoy showing teachers and students that you can program the calculator in just the same way you can program any computer.  Here is a screenshot of the Chaos game being played by the TI program after about 2000 points are plotted:

TI triangle.jpg

The pattern which emerges from the Chaos Game is a famous fractal called the Sierpinski Triangle.  It has the usual fractal property of self-similarity plus some wonderful mathy characteristics you can explore about its' area and perimeter.  These explorations can be whole other lessons and activities as well!  For today's blog though, I'm going to focus on the coding aspect.

It depends on the goals of your course whether you want to have the students develop all or part of the program or just show them the results. I like to do a bit of both.  I like to show them the calculator playing the game, then ask, "How do you think we could program the calculator to do this?"  Teachers have reported very good success with using flowcharting to help students get the big picture of what needs to happen in the program, then learning the specific commands for whatever language the program will be written.  The TI program is written in TI-BASIC (similar to BASIC), which is advantageous for beginning programmers because it's easy to understand, learn, and use.  

As you know, I recently learned Python and, because of this, want to include a section on coding the Sierpinski triangle using it as well.  Here's a screenshot of a Python program to create the fab fractal: (I love the addition of color!  You can't do that with a TI!)

sierpinski.png

In the references section, I give you links for many more resources including the TI program, the Python program, and many more places to go for more details on all of this.  I'll leave you will a cool gif animation of the triangle being constructed:

Animated Sierpinski Triangle.gif

As always, I'd love to hear from you.  If you'd like my PDF version of the Chaos game, the Sketchpad file (from which I make my transparencies for class use), the TI program itself (either in PDF or TI program file), please contact me to request them. Happy coding!

References:

Article that I saw on Twitter to remind me of this classic game.

Python program page

Really awesome interactive Python programming page on visualizing recursion (where the Sierpinski color graphic came from)

Practice Python programming here

TI program page for the fun fractal

Fun fractal cutout activity

Another TI page where you can download the .8xp file of the program

TI programming instructable

Wikibook on TI Basic programming

Wiki page where the cool animated .gif came from

Fractal Foundation site

Alternative Sierpinski Triangle activity

Article on the Infinite Monkey Theorem (includes an excellent video of a Canadian art exhibit which shows order coming from chaos)

Fun visualization of the "monkeys" writing Shakespeare (roll over any section to see how long it took them to type that piece of the Bard's work)

RSSRSS

The Solver Blog

Author:  Dr. Diana S. Perdue

© Rimwe Educational Resources LLC 2019