Langton's ant: Difference between revisions
Content added Content deleted
(→{{header|Quackery}}: typo) |
|||
Line 2,268: | Line 2,268: | ||
=={{header|EasyLang}}== |
=={{header|EasyLang}}== |
||
[https://easylang.online/apps/_langtons-ant.html Run it] |
|||
[https://easylang.online/ide/#run=len%20f%5B%5D%20100%2A100%0Afunc%20show%20.%20.%0Afor%20y%20range%20100%0Afor%20x%20range%20100%0Aif%20f%5By%2A100%2Bx%5D%3D1%0Amove%20x%20y%0Arect%201%201%0A.%0A.%0A.%0A.%0Afunc%20run%20x%20y%20dir%20.%20.%0Adx%5B%5D%3D%5B%200%201%200%20-1%20%5D%0Ady%5B%5D%3D%5B%20-1%200%201%200%20%5D%0Awhile%20x%20%3E%3D%200%20and%20x%20%3C%20100%20and%20y%20%3E%3D%200%20and%20y%20%3C%20100%0Av%3Df%5By%2A100%2Bx%5D%0Af%5By%2A100%2Bx%5D%3D1%20-%20v%0Adir%3D%28dir%2B1%2B2%2Av%29%20mod%204%0Ax%2B%3Ddx%5Bdir%5D%0Ay%2B%3Ddy%5Bdir%5D%0A.%0A.%0Acall%20run%2070%2040%200%0Acall%20show Run it] |
|||
<syntaxhighlight lang="text"> |
<syntaxhighlight lang="text"> |
||
len f[] 100 * 100 |
|||
func show . . |
func show . . |
||
for y |
for y = 0 to 99 |
||
for x |
for x = 0 to 99 |
||
if f[y * 100 + x] = 1 |
if f[y * 100 + x + 1] = 1 |
||
move x y |
move x y |
||
rect 1 1 |
rect 1 1 |
||
Line 2,285: | Line 2,286: | ||
dy[] = [ -1 0 1 0 ] |
dy[] = [ -1 0 1 0 ] |
||
while x >= 0 and x < 100 and y >= 0 and y < 100 |
while x >= 0 and x < 100 and y >= 0 and y < 100 |
||
v = f[y * 100 + x] |
v = f[y * 100 + x + 1] |
||
f[y * 100 + x] = 1 - v |
f[y * 100 + x + 1] = 1 - v |
||
dir = (dir |
dir = (dir + 2 * v) mod 4 + 1 |
||
x += dx[dir] |
x += dx[dir] |
||
y += dy[dir] |
y += dy[dir] |
||
Line 2,293: | Line 2,294: | ||
. |
. |
||
call run 70 40 0 |
call run 70 40 0 |
||
call show |
call show |
||
</syntaxhighlight> |
|||
=={{header|EchoLisp}}== |
=={{header|EchoLisp}}== |