Langton's ant: Difference between revisions
→{{header|APL}}: Correct coordinate chirality
(→{{header|APL}}: Add implementation) |
(→{{header|APL}}: Correct coordinate chirality) |
||
Line 507:
dir←1+4|dir+2×grid[⊂ant]
grid[⊂ant]←1-grid[⊂ant]
⍝ coordinates are matrix order: row,col. So up is -1 0, right is 0 1, down is 1 0, and left is 0 -1
ant+←(4
grid ant dir
}
Line 514 ⟶ 515:
{{Out}}
The final contents of <tt>pic</tt> (eliding
<pre>.......................⌺⌺.⌺.⌺.........................
......................⌺.⌺⌺⌺.⌺⌺...............
.....................⌺⌺⌺⌺...⌺.⌺.............
.....................⌺⌺⌺⌺⌺.⌺..⌺⌺............
......................⌺...⌺⌺.⌺⌺.⌺...........
.......................⌺⌺⌺...⌺..⌺⌺..............
........................⌺...⌺⌺.⌺⌺.⌺...............
.........................⌺⌺⌺...⌺..⌺⌺.............
..........................⌺..
...........................⌺⌺⌺...⌺..⌺⌺...................
............................⌺...⌺⌺.
...........................
.........................
.........................
.........................
..........................
........................
.......................
......................
......................
.......................
.......................
........................................⌺.
......................
.......................
.......................
.......................
...........................
.........................
.........................
.........................
.........................
.........................
........................
........................
.......................
......................
......................
......................
............................
....................
....................
.....................
......................
.............................
.......................................⌺....⌺⌺⌺⌺...⌺..⌺.⌺⌺⌺⌺⌺⌺.⌺⌺....⌺⌺⌺...........................
..........................................⌺...⌺.⌺⌺.⌺.⌺⌺⌺.⌺..⌺⌺..⌺⌺...⌺⌺⌺............................
.............................................⌺⌺⌺⌺⌺⌺⌺....⌺..⌺⌺.⌺⌺.⌺.....⌺...........................
.....................................⌺⌺⌺⌺..⌺⌺.⌺⌺..⌺⌺⌺⌺.⌺⌺.⌺⌺.⌺⌺..⌺.....⌺...........................
....................................⌺....⌺.⌺...⌺⌺⌺.⌺⌺.⌺⌺⌺....⌺.⌺⌺⌺⌺....⌺..........................
...................................⌺⌺⌺.......⌺⌺⌺.⌺.⌺.⌺⌺⌺⌺⌺....⌺.⌺......⌺............................
...................................⌺.⌺...⌺⌺⌺.⌺⌺⌺⌺.⌺⌺.⌺...⌺⌺.⌺⌺⌺.⌺⌺.....⌺............................
.........................................⌺⌺.⌺⌺..⌺⌺⌺⌺....⌺⌺⌺⌺.⌺.⌺.⌺.....⌺............................
....................................⌺....⌺..⌺⌺...⌺⌺⌺..⌺⌺⌺.....⌺⌺⌺......⌺............................
....................................⌺⌺...⌺⌺.⌺⌺⌺.⌺⌺⌺⌺..⌺......⌺⌺⌺...⌺⌺..⌺............................
....................................⌺⌺.⌺.⌺⌺⌺⌺.....⌺...⌺..⌺.⌺⌺.⌺⌺⌺.⌺⌺...⌺............................
...................................⌺⌺⌺⌺.⌺⌺...⌺⌺.⌺⌺⌺⌺..⌺.⌺..⌺..⌺..⌺⌺⌺...⌺............................
...................................⌺.⌺⌺.⌺⌺⌺..⌺.⌺.⌺⌺.⌺.⌺.....⌺.⌺.....⌺.⌺.............................
.......................................⌺.⌺..⌺....⌺⌺.⌺⌺..⌺.⌺..⌺⌺⌺.⌺⌺.................................
.......................................⌺⌺.⌺....⌺..⌺⌺⌺⌺⌺.⌺....⌺....⌺..⌺.⌺............................
......................................⌺.⌺⌺.⌺..⌺....⌺⌺.⌺⌺.⌺..⌺⌺⌺......⌺⌺⌺............................
....................................⌺.⌺...⌺..⌺..⌺..⌺..⌺⌺⌺...⌺⌺..⌺⌺....⌺.............................
...................................⌺⌺⌺.⌺.⌺⌺⌺⌺⌺.⌺⌺⌺⌺⌺⌺.⌺⌺⌺.⌺⌺⌺⌺⌺⌺⌺.⌺.⌺⌺..............................
...................................⌺.⌺.⌺....⌺⌺⌺⌺⌺...⌺⌺..⌺⌺⌺⌺⌺.⌺⌺⌺⌺⌺.................................
.....................................⌺..⌺⌺...⌺......⌺..⌺.⌺⌺..⌺⌺⌺.⌺⌺⌺................................
..................................⌺⌺⌺⌺...⌺⌺⌺⌺⌺.⌺⌺⌺⌺⌺⌺⌺⌺⌺...⌺.⌺......................................
.............................⌺⌺....⌺..⌺.....⌺⌺⌺.⌺.⌺...⌺.⌺⌺⌺..⌺⌺⌺....................................
............................⌺..⌺..⌺⌺⌺⌺.⌺⌺...⌺⌺⌺.⌺⌺...⌺⌺⌺.⌺⌺.....⌺⌺..................................
...........................⌺⌺⌺....⌺.⌺⌺.⌺.⌺⌺⌺⌺⌺...⌺....⌺..⌺..⌺⌺.⌺⌺⌺..................................
...........................⌺.⌺⌺⌺⌺⌺.⌺.⌺...⌺⌺..⌺⌺.....⌺....⌺...⌺..⌺...................................
...............................⌺⌺⌺⌺⌺⌺.⌺⌺⌺⌺..⌺⌺.⌺...⌺..⌺⌺..⌺.⌺.⌺⌺....................................
.............................⌺⌺......⌺.⌺⌺⌺.⌺⌺..⌺⌺⌺⌺...⌺...⌺⌺⌺.......................................
..............................⌺..⌺.⌺⌺⌺⌺⌺..⌺...⌺.⌺⌺...⌺..⌺..⌺........................................
..............................⌺⌺.⌺⌺⌺.⌺⌺⌺⌺⌺⌺⌺.....⌺.....⌺.⌺⌺.........................................
.............................⌺.⌺..⌺⌺.⌺⌺......⌺...⌺⌺....⌺............................................
............................⌺..⌺.⌺⌺⌺⌺........⌺⌺⌺..⌺⌺..⌺.............................................
............................⌺.⌺⌺.⌺⌺⌺............⌺⌺..⌺⌺..............................................
.............................⌺⌺.....................................................................
..............................⌺⌺....................................................................</pre>
=={{header|AutoHotkey}}==
|