Langton's ant: Difference between revisions
Content added Content deleted
(→{{header|APL}}: Add implementation) |
(→{{header|APL}}: Correct coordinate chirality) |
||
Line 507: | Line 507: | ||
dir←1+4|dir+2×grid[⊂ant] |
dir←1+4|dir+2×grid[⊂ant] |
||
grid[⊂ant]←1-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 |
ant+←(4 2⍴¯1 0 0 1 1 0 0 ¯1)[dir;] |
||
grid ant dir |
grid ant dir |
||
} |
} |
||
Line 514: | Line 515: | ||
{{Out}} |
{{Out}} |
||
The final contents of <tt>pic</tt> (eliding |
The final contents of <tt>pic</tt> (eliding trailing blank lines) |
||
<pre>...................................... |
<pre>.......................⌺⌺.⌺.⌺....................................................................... |
||
..................................... |
......................⌺.⌺⌺⌺.⌺⌺...................................................................... |
||
.................................... |
.....................⌺⌺⌺⌺...⌺.⌺..................................................................... |
||
.................................... |
.....................⌺⌺⌺⌺⌺.⌺..⌺⌺.................................................................... |
||
.................................. |
......................⌺...⌺⌺.⌺⌺.⌺................................................................... |
||
.................................. |
.......................⌺⌺⌺...⌺..⌺⌺.................................................................. |
||
.............................. |
........................⌺...⌺⌺.⌺⌺.⌺................................................................. |
||
............................. |
.........................⌺⌺⌺...⌺..⌺⌺................................................................ |
||
............................ |
..........................⌺...⌺⌺.⌺⌺.⌺............................................................... |
||
............................⌺... |
...........................⌺⌺⌺...⌺..⌺⌺.............................................................. |
||
.............................⌺⌺. |
............................⌺...⌺⌺.⌺⌺.⌺............................................................. |
||
........................... |
.............................⌺⌺⌺...⌺..⌺⌺............................................................ |
||
......................... |
..............................⌺...⌺⌺.⌺⌺.⌺........................................................... |
||
......................... |
...............................⌺⌺⌺...⌺..⌺⌺.......................................................... |
||
......................... |
................................⌺...⌺⌺.⌺⌺.⌺......................................................... |
||
.......................... |
.................................⌺⌺⌺...⌺..⌺⌺........................................................ |
||
........................ |
..................................⌺...⌺⌺.⌺⌺.⌺....................................................... |
||
....................... |
...................................⌺⌺⌺...⌺..⌺⌺...................................................... |
||
...................... |
....................................⌺...⌺⌺.⌺⌺.⌺..................................................... |
||
...................... |
.....................................⌺⌺⌺...⌺..⌺⌺.................................................... |
||
....................... |
......................................⌺...⌺⌺.⌺⌺.⌺................................................... |
||
....................... |
.......................................⌺⌺⌺...⌺..⌺⌺.................................................. |
||
......................⌺. |
........................................⌺...⌺⌺.⌺⌺.⌺................................................. |
||
...................... |
.........................................⌺⌺⌺...⌺..⌺⌺................................................ |
||
....................... |
..........................................⌺...⌺⌺.⌺⌺.⌺............................................... |
||
....................... |
...........................................⌺⌺⌺...⌺..⌺⌺.............................................. |
||
....................... |
............................................⌺...⌺⌺.⌺⌺.⌺............................................. |
||
........................... |
.............................................⌺⌺⌺...⌺..⌺⌺............................................ |
||
......................... |
..............................................⌺...⌺⌺.⌺⌺.⌺........................................... |
||
......................... |
...............................................⌺⌺⌺...⌺..⌺⌺.......................................... |
||
......................... |
................................................⌺...⌺⌺.⌺⌺.⌺..⌺⌺..................................... |
||
......................... |
.................................................⌺⌺⌺...⌺..⌺⌺..⌺⌺.................................... |
||
......................... |
..................................................⌺...⌺⌺.⌺⌺..⌺⌺...⌺................................. |
||
........................ |
............................................⌺⌺⌺⌺...⌺⌺⌺...⌺...⌺..⌺⌺⌺................................. |
||
........................ |
...........................................⌺....⌺...⌺...⌺⌺.⌺⌺⌺⌺...⌺................................. |
||
....................... |
..........................................⌺⌺⌺....⌺...⌺.⌺......⌺.⌺⌺.⌺................................ |
||
...................... |
..........................................⌺⌺⌺....⌺.⌺⌺.....⌺.⌺⌺..⌺.⌺⌺................................ |
||
...................... |
...........................................⌺....⌺...⌺⌺.⌺.⌺.....⌺⌺................................... |
||
...................... |
...........................................⌺.⌺......⌺.⌺⌺⌺⌺⌺..⌺...⌺.................................. |
||
............................ |
..........................................⌺...⌺⌺⌺⌺⌺..........⌺⌺.⌺⌺⌺⌺⌺⌺.............................. |
||
.................... |
..........................................⌺⌺⌺..⌺⌺..⌺.⌺⌺.⌺.⌺.⌺...⌺⌺.⌺.⌺⌺............................. |
||
.................... |
........................................⌺⌺..⌺.⌺⌺⌺⌺⌺⌺⌺.⌺...⌺..⌺⌺⌺....⌺⌺.⌺............................ |
||
..................... |
.......................................⌺..⌺..⌺⌺⌺⌺⌺⌺.⌺⌺...⌺..⌺.⌺⌺...⌺...⌺............................ |
||
...................... |
......................................⌺....⌺.⌺.⌺⌺.⌺..⌺⌺⌺⌺⌺⌺.⌺⌺⌺⌺⌺⌺⌺...⌺............................. |
||
............................. |
......................................⌺.⌺⌺⌺⌺.⌺⌺.⌺.⌺⌺⌺⌺....⌺⌺..⌺⌺.⌺.⌺⌺.⌺............................. |
||
................................................................................. |
.......................................⌺....⌺⌺⌺⌺...⌺..⌺.⌺⌺⌺⌺⌺⌺.⌺⌺....⌺⌺⌺............................ |
||
.................................................................................... |
..........................................⌺...⌺.⌺⌺.⌺.⌺⌺⌺.⌺..⌺⌺..⌺⌺...⌺⌺⌺............................ |
||
..................................................................................... |
.............................................⌺⌺⌺⌺⌺⌺⌺....⌺..⌺⌺.⌺⌺.⌺.....⌺............................ |
||
............................................................................... |
.....................................⌺⌺⌺⌺..⌺⌺.⌺⌺..⌺⌺⌺⌺.⌺⌺.⌺⌺.⌺⌺..⌺.....⌺............................ |
||
................................................................................. |
....................................⌺....⌺.⌺...⌺⌺⌺.⌺⌺.⌺⌺⌺....⌺.⌺⌺⌺⌺....⌺............................ |
||
.................................................................................... |
...................................⌺⌺⌺.......⌺⌺⌺.⌺.⌺.⌺⌺⌺⌺⌺....⌺.⌺......⌺............................ |
||
...................................⌺.⌺...⌺⌺⌺.⌺⌺⌺⌺.⌺⌺.⌺...⌺⌺.⌺⌺⌺.⌺⌺.....⌺............................ |
|||
.........................................⌺⌺.⌺⌺..⌺⌺⌺⌺....⌺⌺⌺⌺.⌺.⌺.⌺.....⌺............................ |
|||
....................................⌺....⌺..⌺⌺...⌺⌺⌺..⌺⌺⌺.....⌺⌺⌺......⌺............................ |
|||
....................................⌺⌺...⌺⌺.⌺⌺⌺.⌺⌺⌺⌺..⌺......⌺⌺⌺...⌺⌺..⌺............................ |
|||
....................................⌺⌺.⌺.⌺⌺⌺⌺.....⌺...⌺..⌺.⌺⌺.⌺⌺⌺.⌺⌺...⌺............................ |
|||
...................................⌺⌺⌺⌺.⌺⌺...⌺⌺.⌺⌺⌺⌺..⌺.⌺..⌺..⌺..⌺⌺⌺...⌺............................ |
|||
...................................⌺.⌺⌺.⌺⌺⌺..⌺.⌺.⌺⌺.⌺.⌺.....⌺.⌺.....⌺.⌺............................. |
|||
.......................................⌺.⌺..⌺....⌺⌺.⌺⌺..⌺.⌺..⌺⌺⌺.⌺⌺................................. |
|||
.......................................⌺⌺.⌺....⌺..⌺⌺⌺⌺⌺.⌺....⌺....⌺..⌺.⌺............................ |
|||
......................................⌺.⌺⌺.⌺..⌺....⌺⌺.⌺⌺.⌺..⌺⌺⌺......⌺⌺⌺............................ |
|||
....................................⌺.⌺...⌺..⌺..⌺..⌺..⌺⌺⌺...⌺⌺..⌺⌺....⌺............................. |
|||
...................................⌺⌺⌺.⌺.⌺⌺⌺⌺⌺.⌺⌺⌺⌺⌺⌺.⌺⌺⌺.⌺⌺⌺⌺⌺⌺⌺.⌺.⌺⌺.............................. |
|||
...................................⌺.⌺.⌺....⌺⌺⌺⌺⌺...⌺⌺..⌺⌺⌺⌺⌺.⌺⌺⌺⌺⌺................................. |
|||
.....................................⌺..⌺⌺...⌺......⌺..⌺.⌺⌺..⌺⌺⌺.⌺⌺⌺................................ |
|||
..................................⌺⌺⌺⌺...⌺⌺⌺⌺⌺.⌺⌺⌺⌺⌺⌺⌺⌺⌺...⌺.⌺...................................... |
|||
.............................⌺⌺....⌺..⌺.....⌺⌺⌺.⌺.⌺...⌺.⌺⌺⌺..⌺⌺⌺.................................... |
|||
............................⌺..⌺..⌺⌺⌺⌺.⌺⌺...⌺⌺⌺.⌺⌺...⌺⌺⌺.⌺⌺.....⌺⌺.................................. |
|||
...........................⌺⌺⌺....⌺.⌺⌺.⌺.⌺⌺⌺⌺⌺...⌺....⌺..⌺..⌺⌺.⌺⌺⌺.................................. |
|||
...........................⌺.⌺⌺⌺⌺⌺.⌺.⌺...⌺⌺..⌺⌺.....⌺....⌺...⌺..⌺................................... |
|||
...............................⌺⌺⌺⌺⌺⌺.⌺⌺⌺⌺..⌺⌺.⌺...⌺..⌺⌺..⌺.⌺.⌺⌺.................................... |
|||
.............................⌺⌺......⌺.⌺⌺⌺.⌺⌺..⌺⌺⌺⌺...⌺...⌺⌺⌺....................................... |
|||
..............................⌺..⌺.⌺⌺⌺⌺⌺..⌺...⌺.⌺⌺...⌺..⌺..⌺........................................ |
|||
..............................⌺⌺.⌺⌺⌺.⌺⌺⌺⌺⌺⌺⌺.....⌺.....⌺.⌺⌺......................................... |
|||
.............................⌺.⌺..⌺⌺.⌺⌺......⌺...⌺⌺....⌺............................................ |
|||
............................⌺..⌺.⌺⌺⌺⌺........⌺⌺⌺..⌺⌺..⌺............................................. |
|||
............................⌺.⌺⌺.⌺⌺⌺............⌺⌺..⌺⌺.............................................. |
|||
.............................⌺⌺..................................................................... |
|||
..............................⌺⌺....................................................................</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |