GameMaker: Studio

GameMaker: Studio

Not enough ratings
Langton's Ant Simulation
   
Award
Favorite
Favorited
Unfavorite
genre: Simulation
Description: Educational
File Size
Posted
Updated
5.998 KB
Nov 19, 2015 @ 9:11am
Nov 19, 2015 @ 12:24pm
2 Change Notes ( view )

Subscribe to download
Langton's Ant Simulation

Description
This is a "math game," more so than a "video game." A simulation of Langton's Ant, "a two-dimensional Turing machine with a very simple set of rules but complex emergent behavior" (Wikipedia; more: https://en.wikipedia.org/wiki/Langton%27s_ant ).

When you start the simulation, there are only two rules: if the ant is on a red square it turns left; if it lands on a white square it turns right. Then it moves forward to the next square, ad infinitum. The main attraction is that no matter what the starting conditions are, eventually the ant will start running off in a straight line away from the origin point about 10,000 frames into the simulation; this is usually referred to as the "highway pattern." (The first person to make a phallus joke is going to be bonked on the head with a math book.)

You can have it run with a completely blank grid and watch what happens, or set the starting conditions yourself and see what happens.

Controls (for setting up):
- Left click a cell to turn it on or off
- Right click a cell to make it the starting position of the ant.
- Backspace changes the grid size. A bigger grid is more exciting but takes way more RAM. Changing the size resets the grid.
- Mouse wheel on its own scrolls up and down; hold the Control key to make it scroll left and right; hold the Shift key to make it go faster (not unlike Photoshop or some other canvas-oriented applications).
- Tab key moves the view back to the ant, in case you manage to lose it.
- Arrow keys change the ant's starting orientation, although this doesn't make much of a difference since the game has rotational symmetry (basically you'll just end with the highway running bottom-left instead of top-right).
- Enter starts the simulation.
- Escape clears the grid.

Controls while the simulation is running:
- P key pauses/unpauses it, in case you want to get a closer look.
- Space bar lets you set the speed. If you want to see what's going on use a lower speed; if you want to see the end result, use a higher speed.
- Escape stops the simulation and resets the grid.

Notes:
- On an infinite grid the highway pattern would go on forever, but since this grid isn't infinite it'll eventually hit one of the boundaries, at which point it'll just start running along the border forever. It's rather amusing to watch, though most of the excitement's gone by that point.
- There's no upper limit on the speed you can set, but how fast it actually goes depends on your computer. Unless you're running this on a Game Boy or you have something massive running in the background you should be able to go up to at least 300-400 movements per second.
- There's also no limit on how big you can make the grid, but the amount of RAM it uses goes up with the area. The default grid is 400x400 units and runs on peanuts, but scaling up to 4000x4000 causes it to balloon up to 260 MB. Going much higher than that will probably crash your computer. If you decide to make a planet-sized grid and your computer catches fire, that's your problem, not mine.
- This is a rather simple program and SHOULD be bug-free, but if anyone manages to crash it tell me what you did and I'll try to fix it.
- More on the ant: (Numberphile) https://www.youtube.com/watch?v=NWBToaXK5T0

The ant sprite came from here, be careful that you don't click on something that you don't intend to: http://all-free-download.com/free-vector/download/ant_clip_art_9053.html