Langton's ant: Difference between revisions
Content added Content deleted
Line 1,665: | Line 1,665: | ||
[[File:LangtonsAnt.png|right|thumb|Output]] |
[[File:LangtonsAnt.png|right|thumb|Output]] |
||
<lang mathematica>position = {50, 50} |
<lang mathematica>position = {50, 50}; |
||
direction = 1; |
|||
data = SparseArray[{position -> -1}, {100, 100}, 1]; |
data = SparseArray[{position -> -1}, {100, 100}, 1]; |
||
While[1 <= Min@position <= Max@position <= 100, |
While[1 <= Min@position <= Max@position <= 100, |
||
position += {Re@#, |
|||
Im@#} &@(direction *= (data[[Sequence @@ position]] *= -1) I)]; |
Im@#} &@(direction *= (data[[Sequence @@ position]] *= -1) I)]; |
||
Image[data]</lang> |
Image[data]</lang> |
||