RosettaCodeData/Task/Langtons-ant/00DESCRIPTION

30 lines
1.5 KiB
Text
Raw Permalink Normal View History

2018-06-22 20:57:24 +00:00
[[wp:Langton's ant|Langton's ant]] is a cellular automaton that models an [https://en.wikipedia.org/wiki/Ant ant] sitting on a plane of cells, all of which are white initially, the ant facing in one of four directions.
2015-02-20 00:35:01 -05:00
Each cell can either be black or white.
2018-06-22 20:57:24 +00:00
2015-02-20 00:35:01 -05:00
The ant moves according to the color of the cell it is currently sitting in, with the following rules:
2016-12-05 22:15:40 +01:00
::#   If the cell is black, it changes to white and the ant turns left;
::#   If the cell is white, it changes to black and the ant turns right;
::#   The ant then moves forward to the next cell, and repeat from step 1.
2013-04-10 21:29:02 -07:00
2018-06-22 20:57:24 +00:00
<br>This rather simple ruleset leads to an initially chaotic movement pattern, and after about 10000 steps, a cycle appears where the ant moves steadily away from the starting location in a diagonal corridor about 10 cells wide.
Conceptually the ant can then walk infinitely far away.
2013-04-10 21:29:02 -07:00
2016-12-05 22:15:40 +01:00
;Task:
2018-06-22 20:57:24 +00:00
Start the ant near the center of a 100<small>x</small>100 field of cells, which is about big enough to contain the initial chaotic part of the movement.
2016-12-05 22:15:40 +01:00
2015-02-20 00:35:01 -05:00
Follow the movement rules for the ant, terminate when it moves out of the region, and show the cell colors it leaves behind.
2013-04-10 21:29:02 -07:00
2015-02-20 00:35:01 -05:00
2016-12-05 22:15:40 +01:00
The problem has received some analysis; for more details, please take a look at the Wikipedia article &nbsp; (a link is below)..
;See also:
* &nbsp; Wikipedia: &nbsp; [https://en.wikipedia.org/wiki/Langton%27s_ant Langton's ant].
;Related task:
* &nbsp; Rosetta Code: &nbsp; [[Conway's Game of Life]].
<br><br>