![]() P A G E |
S O M E I W I T H © |
the Ant 1.2.2IntroductionHow to "play" Movement rules Version history Download INTRODUCTION The Ant is a cellular automata and is based on Langton's Ant. The idea comes from Christopher Langton who first introduced his "virtual ant" in a 1986 paper titled "Studying Artificial Life with Cellular Automata". In the original version the ant follows one simple rule when moving: if the cell it enters is white it turns to the right, if it is a black cell it turns to the left. When an ant leaves a cell, it changes the color. The movement shows no pattern up until a certain number of iterations, then the ants start building "roads"... This application makes it possible for a "generalized" Langton ant. A rule for the ant's movements is defined as a binary string containing n bits. When the ant moves, it examines the state k of the new cell, turning right if the kth bit in the rule is 1, and turning left if the bit is 0. The cell then increments its state using the formula knext = (kprev + 1) mod n. In this model, Langton's original ant have the binary rule string (1 0), or decimal 2. ^ top ^ HOW TO "PLAY" Before adding an ant you have to set the direction it is starting in and the position in the grid. You can click on the grid to get the coordinates. Before you start you have to add at least one ant. When you have started the ant(s) you can add more ants if you like. An ant stops if it gets outside the grid. You can pause ("stop") - if redraw is not checked start resumes the run. With redraw checked the grid is cleared from colored cells, but the ants remain in their positions. "Clear" clears the whole grid and removes all ants. "Iterations" is the number of steps the ants have completed. You can have any number of ants each run, however at some point I guess it slowes down the program too much for it to be practical. You can also change the number of cells in the grid and define any rule between rule no 2 and rule no 65535. If you want to speed up the ants you can jump to any step ahead and watch the result - and continue from there if you like. At any point you can view the frequency for each cell (how many times it has been visited by an ant) by using the heat map. Experiment with different rules, different number of ants, grid sizes and starting positions to see if your ants "build" anything interesting. E.g. rule no 107 (1101011) creates a sort of fan pattern, rule no 43690 is identical to Langton's ant, but in 16 colors, and so on... ^ top ^ MOVEMENT RULES The movement rule is what governs how the ant(s) move. If the binary code has n bits (max 16) each cell can be in n different states each represented by a different color. The state of the cell determines if the ant will turn to the left or to the right. When it leaves the cell it increment the state value by 1 (until n-1, when the state value becomes 0 again and it starts all over). If, for example, a cell the ant enters currently is in state 5, and the movement rule is 011001 the ant will turn to the left because the 5th bit is 1. Next time the ant enters the same cell it will turn to the right because the 6th bit of the rule is 0. You don't really have to understand the above to use it... just marvel at the strange things that happens. Ants moving seemingly random and then after a certain number of steps you have a clear order (at least with some of the movement rules)... ^ top ^ VERSION HISTORY v1.2.2 - added possibility to initialize the "heat map" when jumping, i.e. heat will only display the path from the current step and onwards. - fixed bug that disabled all controls if "start" was clicked when "heat" was active. (thanks to Brin Cooke) - fixed bug that displayed the wrong number of ants when a jump ended because all ants had been removed (outside the grid). v1.2.1 - improved the "jump" function - it is now about 50 times faster!!!! - fixed a couple of minor bugs involving when to update/clear the grid - fixed minor bug: the number of iterations now displays 0 after clear or change grid size v1.2 - added possibility to "jump" a selected number of steps (much faster) - added "heat map" displaying ant frequency in the cells v1.1 - added possibility for a generalized Langton ant, i.e. movement rules are defined by a binary string with up to 16 bits. - displays ant paths in up to 16 colors - added possibility to change the grid size (64x64 to 128x128) v1.0 - could only have one rule (1 0), i.e. the original Langton's ant - displays ant paths in two colors - grey and blue ^ top ^ DOWNLOAD Download the Ant 1.2.2 (400K) 1999-09-16 (requires 800x600 screen) Download the source code for Langton's ant ^ top ^ |
|
If you have any comments, feature requests and/or bug reports, please send me an email: michael.rosander@home.se |