| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Humberto Barreto | You must ENABLE MACROS (see below for details) when you open this file. | 22-Jul-21 | |||||||||||||||||||||||
2 | hbarreto@depauw.edu | |||||||||||||||||||||||||
3 | ||||||||||||||||||||||||||
4 | Langton's ant follows two simple rules to move around, yet remarkably it produces something ordered. | |||||||||||||||||||||||||
5 | ||||||||||||||||||||||||||
6 | As of this writing, it seems that no matter the initial grid, the ant will eventually build a highway (this mysterious term, which you will discover as you learn about Langton's ant, is an open-problem that is the subject of current research). | |||||||||||||||||||||||||
7 | ||||||||||||||||||||||||||
8 | Langton's ant is on a plane with black and white squares. The ant can be facing north, south, east, or west. It follows these two rules, then moves forward: | |||||||||||||||||||||||||
9 | 1) If it is on a white square, it turns right; else (it is on a black square), it turns left. | |||||||||||||||||||||||||
10 | 2) The ant moves forward one square (in the direction it is facing) and the square it was on flips color. | |||||||||||||||||||||||||
11 | ||||||||||||||||||||||||||
12 | A spreadsheet is the perfect place to implement Langton's ant. Enter a greater than sign, > (representing the ant facing east), in cell B13 below. | |||||||||||||||||||||||||
13 | ||||||||||||||||||||||||||
14 | ||||||||||||||||||||||||||
15 | ||||||||||||||||||||||||||
16 | We can easily color a cell black (white is the default background color). Click cell C14 and then click the Fill Color button (the bucket in the Font group) to make it black. | |||||||||||||||||||||||||
17 | ||||||||||||||||||||||||||
18 | Moving the ant is a little trickier. We will do it manually, applying the two rules, to see how it works. | |||||||||||||||||||||||||
19 | At B13, the ant is on a white square so, following the first rule, it will turn right, becoming a v. | |||||||||||||||||||||||||
20 | Following the second rule, it will move forward one square, down to cell B14, and the square it was on (B13) flips to black. | |||||||||||||||||||||||||
21 | The ant is now in cell B14 and facing south so enter the letter v in cell B14. | |||||||||||||||||||||||||
22 | Delete the > character in cell B13 and change the cell color to black to finish applying the second rule. | |||||||||||||||||||||||||
23 | ||||||||||||||||||||||||||
24 | This is what cells B13:D15 should look like (if you followed the instructions above): | |||||||||||||||||||||||||
25 | ||||||||||||||||||||||||||
26 | ||||||||||||||||||||||||||
27 | ||||||||||||||||||||||||||
28 | ||||||||||||||||||||||||||
29 | Can you walk through what the next move will be? | |||||||||||||||||||||||||
30 | It is on a white square, so it turns left to <, then it hops to cell A14 and cell B14 flips to black. | |||||||||||||||||||||||||
31 | ||||||||||||||||||||||||||
32 | Moving the ant manually quickly becomes tedious. We can automate the process with Excel's programming language, Visual Basic. | |||||||||||||||||||||||||
33 | This workbook has macros that will enable Langton's ant to move by following the two simple rules. | |||||||||||||||||||||||||
34 | It is not necessary, but if you want to see the code, press alt+F11 on your keyboard (or right-click the Intro sheet tab at the bottom left of this window and select View Code). | |||||||||||||||||||||||||
35 | ||||||||||||||||||||||||||
36 | Read the instructions below before you play with Langton's ant in the Ant sheet. | |||||||||||||||||||||||||
37 | ||||||||||||||||||||||||||
38 | When you go to the Ant sheet, you will see a controller floating above the screen (see below if you do not see this when you go to the Ant sheet). | |||||||||||||||||||||||||
39 | Use the controller to move the ant around. Your goal is to generate the highway and understand what it means. | |||||||||||||||||||||||||
40 | ||||||||||||||||||||||||||
41 | When you first arrive at the Ant sheet, add an ant (enter <, >, v, or ^ in any cell) and have it follow the two simple rules to move around. | |||||||||||||||||||||||||
42 | Click the Move One Step button a few times to confirm that the ant is moving as expected, following the two rules. | |||||||||||||||||||||||||
43 | To be able to see the direction the ant is facing, we use yellow instead of black as our non-white cell fill color. | |||||||||||||||||||||||||
44 | Try the Many Steps button with a few hundreds steps. | |||||||||||||||||||||||||
45 | If you click the check box, the macro runs much faster because it does not have to show each step. It computes the path and then displays it. | |||||||||||||||||||||||||
46 | ||||||||||||||||||||||||||
47 | Starting from a completely white grid, Langton's ant starts to build the highway mentioned above around 10,000 steps (OK, the 9,978th step, to be exact). | |||||||||||||||||||||||||
48 | To see the highway clearly, you need to run around 11,000 steps (starting from a blank grid). | |||||||||||||||||||||||||
49 | ||||||||||||||||||||||||||
50 | After you confirm that the ant builds a highway, click the Reset button and create other grid patterns by filling some cells with yellow and then adding the ant and using the buttons to move around. | |||||||||||||||||||||||||
51 | You can try typical geometric shapes (for example, a triangle) or a random smattering of yellow cells. | |||||||||||||||||||||||||
52 | Do you find any interesting results? | |||||||||||||||||||||||||
53 | Does the ant ever fail to build the highway? That would be a BIG deal. | |||||||||||||||||||||||||
54 | ||||||||||||||||||||||||||
55 | After you are finished, take a look at the Lesson sheet to make sure you understand a key idea demonstrated by Langton's ant. | |||||||||||||||||||||||||
56 | ||||||||||||||||||||||||||
57 | Proceed to the Ant spreadsheet and explore the properties and patterns of Langton's ant! | |||||||||||||||||||||||||
58 | ||||||||||||||||||||||||||
59 | ||||||||||||||||||||||||||
60 | ||||||||||||||||||||||||||
61 | Software Requirements: | |||||||||||||||||||||||||
62 | You need "desktop" (not online) Microsoft Excel, Windows version 2007 or greater to get full functionality from this file. | |||||||||||||||||||||||||
63 | This file can be opened with Mac Excel, but it uses Visual Basic code that may not be fully supported on a Mac. | |||||||||||||||||||||||||
64 | Online Excel can open this file, but none of the macros will run. You need to have Excel on your computer and open this file with your Excel application. | |||||||||||||||||||||||||
65 | You must be sure to Enable Content or the buttons and code in this macro-enabled workbook will not work. | |||||||||||||||||||||||||
66 | If you opened this workbook and did not enable macros, close it, open it again, and click the Enable Content button --> | |||||||||||||||||||||||||
67 | Search "enable macros" in Excel's Help for more information on how to do this. | |||||||||||||||||||||||||
68 | ||||||||||||||||||||||||||
69 | ||||||||||||||||||||||||||
70 | ||||||||||||||||||||||||||
71 | ||||||||||||||||||||||||||
72 | ||||||||||||||||||||||||||
73 | ||||||||||||||||||||||||||
74 | ||||||||||||||||||||||||||
75 | ||||||||||||||||||||||||||
76 | ||||||||||||||||||||||||||
77 | ||||||||||||||||||||||||||
78 | ||||||||||||||||||||||||||
79 | ||||||||||||||||||||||||||
80 | ||||||||||||||||||||||||||
81 | ||||||||||||||||||||||||||
82 | ||||||||||||||||||||||||||
83 | ||||||||||||||||||||||||||
84 | ||||||||||||||||||||||||||
85 | ||||||||||||||||||||||||||
86 | ||||||||||||||||||||||||||
87 | ||||||||||||||||||||||||||
88 | ||||||||||||||||||||||||||
89 | ||||||||||||||||||||||||||
90 | ||||||||||||||||||||||||||
91 | ||||||||||||||||||||||||||
92 | ||||||||||||||||||||||||||
93 | ||||||||||||||||||||||||||
94 | ||||||||||||||||||||||||||
95 | ||||||||||||||||||||||||||
96 | ||||||||||||||||||||||||||
97 | ||||||||||||||||||||||||||
98 | ||||||||||||||||||||||||||
99 | ||||||||||||||||||||||||||
100 |