Langton's ant: Difference between revisions

m
(→‎{{header|Perl 6}}: simplify by using the grid to test the loop exit and by including distance in the vector summing)
Line 1,365:
my @plane = [White xx $size] xx $size;
my ($x, $y) = $size/2, $size/2;
my $dir = (^4@vecs).pick;
my $moves = 0;
loop {
Line 1,374:
($x,$y,$moves) »+=« @vecs[$dir %= @vecs];
}
printsay "Out of bounds after $moves moves at ($x, $y)\n";
for 0,2,4 ...^ $size - 2 -> $x {
say join '', gather for 0,2,4 ... $size - 2 -> $y {
1,481

edits