Showing posts with label Langton's ant. Show all posts
Showing posts with label Langton's ant. Show all posts

Saturday, January 3, 2015

Langton's Ant Random Black Squares Experiment

I have one more Langton's Ant in Scratch project to share.
With the exception of experiments involving probability, one doesn’t usually associate the word experiment with mathematics. Although the behavior of Langton's Ant is clearly determined by its rules, its behavior is unpredictable! For that reason, the ant is a mathematical system that lends itself to experimentation. This project lets you explore for yourself what happens if random square are distributed on the coordinate plane.
To start the project, click on the green flag. The ant shrinks to the size of one of the squares that make up the grid, ten additional black squares are randomly placed within a 100-step square centered on the origin (0, 0). Langton's Ant, starting at the origin and facing to the right, starts moving as shown in the following diagram.
The diagram below shows the normal behavior of Langton's Ant when no black squares are randomly added to the plane. This is the control pattern for experiments.
This diagram shows the path of the ant when ten black squares have been randomly added to the plane. Note its differences from the control pattern.
http://scratch.mit.edu/projects/41285348/
I have written a detailed description of the Scratch code and ideas for experiments you can do with the ant. To request your free PDF, send an email to grandadscience@gmail.com.
For a deeper description of Langton's Ant and why it's an important mathematical system, download and read the following article by Ian Stewart.

Monday, December 29, 2014

Updates to My Langton's Ant in Scratch Project

This is an update to my original Langton's Ant project. This update now allows you to experiment with Langton's Ant by placing the ant in a circle, square, triangle, or near a line segment.
As you can see in this screen shot, a circle, triangle, square, and line segment are on the home screen. Click on the green flag and then click on one of the shapes and drag it so that it traps the center of the ant (the small red circle). Or, click on and drag the line segment near to the red dot. Then click on the head of the ant. You will see the ant shrink to size of the grid it will be moving on and then start moving.
How the ant will interact with figures in the plane is any ones guess because there is no way to predict the pattern the ant will create when it interacts with another figure. Changing the Direction the ant starts in is another variable.
Over the years I have collected several interesting and surprising figures created when the ant interacted with one or more figures.

Thursday, April 18, 2013

Tur-mites and the XOR Gate

I have just returned from a long vacation where I did not have Internet access for two weeks. Thanks for checking this blog in the interim.
The type of programming Scratchers do reflects their personal interests. That’s why the Scratch community, as an educational community, is so large. I get excited about certain math topics and I tend to focus on those topics until I’m enticed away by a new interest.  Brian Hayes calls this inquisitive programming.
Lately, I’ve been exploring cellular automatons. My Langton’s Ant Scratch project is an example of a cellular automaton. Langton’s ant moves on a square grid according to a simple rule and is a two-dimensional, two-color, cellular automaton (CA).
A. K. Dewdney is a computer science professor that wrote the Computer Recreations column in Scientific American magazine and has authored several books about the joys of computer programming.
In his column, Two-dimensional Turing machines and tur-mites make tracks on a plane, found in the September 1989 issue of Scientific American, he discusses a multi-colored tur-mite I call Dewdney’s tur-mite.
To view my scratch project that codes Dewdney’s tur-mite, click on this link.
http://scratch.mit.edu/projects/40908756/

I am also working on a Scratch project that implements Wolfram’s (of Mathematica fame) rule L90, one-dimensional cellular automaton. When the one-dimensional iterations of rule L90 are successively stacked, the Sierpinski triangle pattern is produced. The single operator in the code is an XOR logic gate. Scratch has AND, OR, and NOT logic operators but not an XOR operator. The XOR operator eXcludes the case when the two inputs to the OR operator are 1 (true). In other words, XOR (1,1) = 0.

I’ve gotten as far on this project as creating the XOR operator in Scratch. To view the XOR gate, click on this link.

http://scratch.mit.edu/projects/popswilson/3270654

I will soon have a PDF file that describes the math and programming techniques for both Langton’s Ant and Dewdney’s Tur-mite ready for distribution upon request.
I will post the complete rule L90 project when it has been completed.

Tuesday, March 12, 2013

Langton's Ant Trapped In a Circle, Triangle, or Near a Line Segment

This Scratch project is a series of experiments using Langton’s Ant as the ‘lab rat’.
Langton’s ant is a cellular automaton invented by researcher Chris Langton in the early 1980s. The ant, once set in motion, crates an iconic picture of order emerging from chaos and is often a student’s first exposure to the study of deterministic chaos and nonlinear dynamics (chaos theory).
When we observe complex behavior we tend to believe its behavior is the result of a complex set of rules. In the picture above, the path of a single Langton ant is shown. The ant started in the center of the screen and has worked its way to near the lower right corner of the screen. Out of the mess seen in the center, after over 10,000 applications of the rules governing its behavior, the ant starts building the diagonal ‘highway’!
I purposely stopped the ant before it built the highway to the boundary. What happen after the ant hits the side? Even though the rules that actually governs the behavior (movement) of the ant are quite simple, there is no way to predict what happens when the ant strikes the side of the rectangle. The actual path created by the ant has to be computed, step by step, in order to be seen.
Here are the rules:
The ant is sitting on an infinitely large checkerboard made up of only white squares. The ant moves one square forward and, if the square is white, it paints it black, turns left 90º and moves one square forward. If the square is black, the ant paints it white, turns right 90º and moves one square forward. In either case, after painting the square white or black, the ant applies the same rule again. That’s it!. That simple rule creates the ant’s complex behavior.
The following screen shot displays the ant wandering around the center of the screen and then building the highway.

If you would like to find out what happen when Langton’s ant is placed inside a circle, square, or triangle go to the following link, download the project, and find out!
http://scratch.mit.edu/projects/40908674/
The line segment at the bottom of the screen can also be picked up and placed closer to the ant's starting point. Below is a screen shot showing the ant building a highway after interacting with the line segment.

Remember, there is no known method for predicting the behavior of the ant. Have fun experimenting with Langton's Ant!