Langton's ant: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added more wording in the REXX output section.) |
m (→{{header|Sidef}}: minor code updates) |
||
Line 6,312: | Line 6,312: | ||
var plane = size.of { size.of (White) } |
var plane = size.of { size.of (White) } |
||
var (x, y) = |
var (x, y) = ([size >> 1] * 2)... |
||
var dir = dirs.len.irand |
var dir = dirs.len.irand |
||
Line 6,319: | Line 6,319: | ||
(x >= 0) && (y >= 0) && (x < size) && (y < size) || break |
(x >= 0) && (y >= 0) && (x < size) && (y < size) || break |
||
given(plane[x][y]) { |
given (plane[x][y]) { |
||
when (White) { dir--; plane[x][y] = Black } |
when (White) { dir--; plane[x][y] = Black } |
||
when (Black) { dir++; plane[x][y] = White } |
when (Black) { dir++; plane[x][y] = White } |
||
Line 6,325: | Line 6,325: | ||
++moves |
++moves |
||
[\x, \y] |
[[\x, \y], dirs[dir %= dirs.len]].zip {|a,b| *a += b } |
||
} |
} |
||