Langton's ant: Difference between revisions

m
Grammar, spelling, formatting the description
(add Ruby)
m (Grammar, spelling, formatting the description)
Line 1:
{{draft task|Celluar automaton}}
[[wp:Langton's ant|Langton's ant]] models an ant sitting on a plane of cells, whichall initiallyof which are allwhite whiteinitially, facing in one of four directions. Each cell can either be black or white. The ant moves according to the color of the cell it is currentcurrently sitting in based on the following rules. If the cell is black it turns left, if it is white it turns right. It then moves forward to the next cell and the color of the cell it was in is switched black/white.:
*If the cell is black it turns left
This rather simple ruleset leads some movement appearing like random (or maybe like some kind of edge detecion being run on random images) and after about 10000 a cyle appears that makes the ant move in a diagonal movements with a corridor about 10 pixels wide, which essentially means that the ant will move out of the screen. The program terminates when the ant moves off screen.
*If it is white it turns right
*It then moves forward to the next cell and the color of the cell it was in is switched black/white
*The ant stops when it leaves the plane
This rather simple ruleset leads someto movement appearing like random (or maybe like some kind of edge deteciondetection being run on random images) and after about 10000 acycles cyleit appears that makes the ant movemoves in a diagonal movements with a corridor about 10 pixels wide, which essentially means that the ant will move out of the screen. The program terminates when the ant moves off screen.
 
For this task, start the ant near the center of a 100 by 100 field of cells (coordinates 50, 50 if you use zeroa origin0, indexing0 origin).
 
The problem has recievedreceived some analysis, for more details, please take a look at the Wikipedia article.
 
=={{header|C}}==
Anonymous user