Four-Fold Symmetric Doodle¶
By the end of this lab you'll be able to:
- Record turtle commands as data in a list and replay them
- Apply a 90° rotation to a list of recorded moves to create four-fold symmetry
- Understand the difference between recording commands and executing them immediately
One quadrant of a geometric doodle is recorded, then replayed three more times at 90°, 180°, and 270° rotations — automatically producing perfect four-fold rotational symmetry.
Welcome to the Four-Fold Doodle!
This lab teaches a powerful programming idea: recording actions as data.
Draw once, replay four times with different rotations — instant symmetry!
Let's code it together!
How It Works¶
We store moves as a list of tuples: ('forward', 40), ('left', 60), etc. After building the list, we replay it four times, rotating 90° between each replay. This guarantees perfect four-fold symmetry regardless of what moves are in the list.
Sample Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
What Do You Think Will Happen?
Each of the 4 replays starts facing a different direction: 0°, 90°, 180°, 270°.
Will the four colored replays look like four independent doodles, or will they form one symmetric pattern?
Make your guess — then click Run to find out!
Try It Now¶
One symmetric pattern — the four colored arms are rotations of each other, meeting at the center to form a cohesive design. Were you right?
How It Works¶
monty.setheading(rotation * 90) is the key. Before each replay, the turtle is sent to the origin facing a new direction. From the turtle's perspective, every replay feels identical — but because the starting heading rotates, the result rotates too.
Explanation Table¶
| Line | What it does |
|---|---|
moves = [...] |
Record commands as a list of (command, value) tuples |
monty.setheading(rotation * 90) |
Rotate starting direction for each replay |
for cmd, val in moves |
Unpack each recorded move |
colors[rotation] |
Different color per rotation |
Learning Check¶
Your Turn — Add More Moves
Add 3 more moves to the moves list — any combination of forward/left/right.
Predict how the symmetry will change (it will stay four-fold!), then run it.
No matter what you put in moves, the result is always four-fold symmetric — the rotation mechanism guarantees it.
Experiments¶
-
Six-fold symmetry. Change
range(4)torange(6)androtation * 90torotation * 60. You'll know it worked when 6 arms appear. -
Monochrome. Use
'black'for all colors. You'll know it worked when all arms are the same color, making the symmetry even more obvious. -
Draw with pen up partway. Add
('penup', 0)and('pendown', 0)entries and handle them in the replay loop. You'll know it worked when some moves create dashes. -
Random moves. Generate moves with
random.choiceandrandom.randint. You'll know it worked when a different symmetric pattern appears each run.
Commands as Data!
You learned a powerful idea: storing actions as data so you can replay them
with transformations. This technique is used in undo/redo systems and animation!
Up next: Six-Fold Mandala — extending to 6-fold symmetry.