Langton's ant: Difference between revisions

m
→‎{{header|Sidef}}: modified code to work with Sidef 2.10
m (removed "started")
m (→‎{{header|Sidef}}: modified code to work with Sidef 2.10)
Line 5,302:
=={{header|Sidef}}==
{{trans|Perl 6}}
<lang ruby>constdefine dirs = [[1,0], [0,-1], [-1,0], [0,1]];
constdefine size = 100;
 
enum |White, Black|;
var plane = size.of { size.of (White) };
 
var plane(x, y) = @([size/2 -> int]*2);
{|i| plane[i-1] = [White]*size} * size;
 
var (x, y) = ([size/2 int] * 2 ...);
var dir = dirs.len.rand.int;
 
Line 5,317 ⟶ 5,315:
(x >= 0) && (y >= 0) && (x < size) && (y < size) || break;
 
given(plane[x][y]) {
when (White) { dir--; plane[x][y] = Black }
when (Black) { dir++; plane[x][y] = White };
}
 
moves++moves;
[\x, \y]:dirs[dir %= dirs.len] -> each {|a,b| *a += b };
}
 
2,747

edits