Chasing the Dragon
In order to get a computer to Chase the Dragon, we need to find a way to represent it symbolically.
Level 1 begins with a line that goes upward on the display. It makes a left turn and ends. Level 2 begins with a line that goes upward on the display. It makes a left turn, a second left turn and finally a right turn. We can represent these figures as follows:
Level 1: L
Level 2: LLR
Level 3: LLRLLRR
Following the direction of these turns can get a bit confusing since when a segment is going up on the display, a turn to the left side of the display is a left turn, yet when a segment is going down on the display, then a turn to the left side of the display is a right turn.
Before we look at Level 4 and list the series of left and right turns, let us use the observations we have made about the Dragon to predict what the series will be:
The first half of level 4 is identical to all of level 3, therefore:
Level 4: LLRLLRR????????
The second half of level 4 is also an exact copy of all of level 3; however, where the first half began by moving upward on the display, the second half begins by moving downward on the display. Therefore, each right turn in the first half will be a left turn in the second half (and each left in the first will be a right in the second):
Finally, the center fold is a left turn. Can you convince yourself that the center fold will always be a left turn on every level of the Dragon? Can you explain why?
Thus, we have:
Level 4: LLRLLRRLLLRRLRR
This abstract representation of the Dragon has
First, in a computer, it is very easy to represent
a string of L and R character. Second, the string representation made it very easy to generate each
subsequent level of the Dragon.
With the Dragon represented as s string, it becomes easy to see yet another pattern for generating the next Dragon level.
Notice that, we can generate level
n+1 by alternately inserting an L and an R between each turn in level n.
With the Dragon represented as s string, it becomes easy to see yet another pattern for generating the next Dragon level. Notice that, we can generate level n+1 by alternately inserting an L and an R between each turn in level n. For example:
Level 3: L L R L L R R
Personally, I find it utterly fascinating that such a simple and regular process of inserting an L and an R between each turn of the current level can, from the starting point of a single L, create a sequence that is amazingly complex and intricate!
This process is heart of the software that was used to create these pictures. If you already know something about how to write a computer program to draw lines on a screen, then you are now ready to write your own Dragon generating program.