Langton's ant: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 761:
return 0;
}</lang>
 
=={{header|C sharp|C#}}==
<lang csharp>using System;
 
namespace LangtonAnt
{
public struct Point
{
public int X;
public int Y;
 
public Point(int x, int y)
{
X = x;
Y = y;
}
}
 
enum Direction
{
North, East, West, South
}
 
public class Langton
{
public readonly bool [,] IsBlack;
private Point _origin;
private Point _antPosition = new Point(0, 0);
public bool OutOfBounds { get; set;}
 
// I don't see any mention of what direction the ant is supposed to start out in
private Direction _antDirection = Direction.East;
 
private readonly Direction[] _leftTurn = new[] { Direction.West, Direction.North, Direction.South, Direction.East };
private readonly Direction[] _rightTurn = new[] { Direction.East, Direction.South, Direction.North, Direction.West };
private readonly int[] _xInc = new[] { 0, 1,-1, 0};
private readonly int[] _yInc = new[] {-1, 0, 0, 1};
 
public Langton(int width, int height, Point origin)
{
_origin = origin;
IsBlack = new bool[width, height];
OutOfBounds = false;
}
 
public Langton(int width, int height) : this(width, height, new Point(width / 2, height / 2)) {}
 
private void MoveAnt()
{
_antPosition.X += _xInc[(int)_antDirection];
_antPosition.Y += _yInc[(int)_antDirection];
}
 
public Point Step()
{
if (OutOfBounds)
{
throw new InvalidOperationException("Trying to step after ant is out of bounds");
}
Point ptCur = new Point(_antPosition.X + _origin.X, _antPosition.Y + _origin.Y);
bool leftTurn = IsBlack[ptCur.X, ptCur.Y];
int iDirection = (int) _antDirection;
_antDirection = leftTurn ? _leftTurn[iDirection] : _rightTurn[iDirection];
IsBlack[ptCur.X, ptCur.Y] = !IsBlack[ptCur.X, ptCur.Y];
MoveAnt();
ptCur = new Point(_antPosition.X + _origin.X, _antPosition.Y + _origin.Y);
OutOfBounds =
ptCur.X < 0 ||
ptCur.X >= IsBlack.GetUpperBound(0) ||
ptCur.Y < 0 ||
ptCur.Y >= IsBlack.GetUpperBound(1);
return _antPosition;
}
}
class Program
{
static void Main()
{
Langton ant = new Langton(100, 100);
 
while (!ant.OutOfBounds) ant.Step();
 
for (int iRow = 0; iRow < 100; iRow++)
{
for (int iCol = 0; iCol < 100; iCol++)
{
Console.Write(ant.IsBlack[iCol, iRow] ? "#" : " ");
}
Console.WriteLine();
}
 
Console.ReadKey();
}
}
}
</lang>
Output:
<pre>
<Blank lines eliminated for efficiency> # #
## # #
# ### ##
#### ### #
##### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## # ##
### # ## ##
# ## ## ## #
#### ### # # ###
# # # ## #### #
### # # # # ## #
### # ## # ## # ##
# # ## # # ##
# # # ##### # #
# ##### ## ######
### ## # ## # # # ## # ##
## # ####### # # ### ## #
# # ###### ## # # ## # #
# # # ## # ###### ####### #
# #### ## # #### ## ## # ## #
# #### # # ###### ## ###
# # ## # ### # ## ## ###
####### # ## ## # #
#### ## ## #### ## ## ## # #
# # # ### ## ### # #### #
### ### # # ##### # # #
# # ### #### ## # ## ### ## #
## ## #### #### # # # #
# # ## ### ### ### #
## ## ### #### # ### ## #
## # #### # # # ## ### ## #
#### ## ## #### # # # # ### #
# ## ### # # ## # # # # # #
# # # ## ## # # ### ##
## # # ##### # # # # #
# ## # # ## ## # ### ###
# # # # # # ### ## ## #
### # ##### ###### ### ####### # ##
# # # ##### ## ##### #####
# ## # # # ## ### ###
#### ##### ######### # #
## # # ### # # # ### ###
# # #### ## ### ## ### ## ##
### # ## # ##### # # # ## ###
# ##### # # ## ## # # # #
###### #### ## # # ## # # ##
## # ### ## #### # ###
# # ##### # # ## # # #
## ### ####### # # ##
# # ## ## # ## #
# # #### ### ## #
# ## ### ## ##
##
##
</pre>
 
=={{header|C++}}==
Line 1,066 ⟶ 1,245:
//--------------------------------------------------------------------------------------------------
</lang>
 
=={{header|C sharp|C#}}==
<lang csharp>using System;
 
namespace LangtonAnt
{
public struct Point
{
public int X;
public int Y;
 
public Point(int x, int y)
{
X = x;
Y = y;
}
}
 
enum Direction
{
North, East, West, South
}
 
public class Langton
{
public readonly bool [,] IsBlack;
private Point _origin;
private Point _antPosition = new Point(0, 0);
public bool OutOfBounds { get; set;}
 
// I don't see any mention of what direction the ant is supposed to start out in
private Direction _antDirection = Direction.East;
 
private readonly Direction[] _leftTurn = new[] { Direction.West, Direction.North, Direction.South, Direction.East };
private readonly Direction[] _rightTurn = new[] { Direction.East, Direction.South, Direction.North, Direction.West };
private readonly int[] _xInc = new[] { 0, 1,-1, 0};
private readonly int[] _yInc = new[] {-1, 0, 0, 1};
 
public Langton(int width, int height, Point origin)
{
_origin = origin;
IsBlack = new bool[width, height];
OutOfBounds = false;
}
 
public Langton(int width, int height) : this(width, height, new Point(width / 2, height / 2)) {}
 
private void MoveAnt()
{
_antPosition.X += _xInc[(int)_antDirection];
_antPosition.Y += _yInc[(int)_antDirection];
}
 
public Point Step()
{
if (OutOfBounds)
{
throw new InvalidOperationException("Trying to step after ant is out of bounds");
}
Point ptCur = new Point(_antPosition.X + _origin.X, _antPosition.Y + _origin.Y);
bool leftTurn = IsBlack[ptCur.X, ptCur.Y];
int iDirection = (int) _antDirection;
_antDirection = leftTurn ? _leftTurn[iDirection] : _rightTurn[iDirection];
IsBlack[ptCur.X, ptCur.Y] = !IsBlack[ptCur.X, ptCur.Y];
MoveAnt();
ptCur = new Point(_antPosition.X + _origin.X, _antPosition.Y + _origin.Y);
OutOfBounds =
ptCur.X < 0 ||
ptCur.X >= IsBlack.GetUpperBound(0) ||
ptCur.Y < 0 ||
ptCur.Y >= IsBlack.GetUpperBound(1);
return _antPosition;
}
}
class Program
{
static void Main()
{
Langton ant = new Langton(100, 100);
 
while (!ant.OutOfBounds) ant.Step();
 
for (int iRow = 0; iRow < 100; iRow++)
{
for (int iCol = 0; iCol < 100; iCol++)
{
Console.Write(ant.IsBlack[iCol, iRow] ? "#" : " ");
}
Console.WriteLine();
}
 
Console.ReadKey();
}
}
}
</lang>
Output:
<pre>
<Blank lines eliminated for efficiency> # #
## # #
# ### ##
#### ### #
##### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## #
### # ##
# ## ## # ##
### # ## ##
# ## ## ## #
#### ### # # ###
# # # ## #### #
### # # # # ## #
### # ## # ## # ##
# # ## # # ##
# # # ##### # #
# ##### ## ######
### ## # ## # # # ## # ##
## # ####### # # ### ## #
# # ###### ## # # ## # #
# # # ## # ###### ####### #
# #### ## # #### ## ## # ## #
# #### # # ###### ## ###
# # ## # ### # ## ## ###
####### # ## ## # #
#### ## ## #### ## ## ## # #
# # # ### ## ### # #### #
### ### # # ##### # # #
# # ### #### ## # ## ### ## #
## ## #### #### # # # #
# # ## ### ### ### #
## ## ### #### # ### ## #
## # #### # # # ## ### ## #
#### ## ## #### # # # # ### #
# ## ### # # ## # # # # # #
# # # ## ## # # ### ##
## # # ##### # # # # #
# ## # # ## ## # ### ###
# # # # # # ### ## ## #
### # ##### ###### ### ####### # ##
# # # ##### ## ##### #####
# ## # # # ## ### ###
#### ##### ######### # #
## # # ### # # # ### ###
# # #### ## ### ## ### ## ##
### # ## # ##### # # # ## ###
# ##### # # ## ## # # # #
###### #### ## # # ## # # ##
## # ### ## #### # ###
# # ##### # # ## # # #
## ### ####### # # ##
# # ## ## # ## #
# # #### ### ## #
# ## ### ## ##
##
##
</pre>
 
=={{header|Chapel}}==
Line 1,597:
______##________________________________________
</lang>
 
 
=={{header|Common Lisp}}==
Line 2,253 ⟶ 2,252:
.....................................................................................................
</pre>
 
=={{header|Elm}}==
<lang elm>import Maybe as M
Line 3,794:
</pre>
 
=={{header|Java}}==
This implementation allows for sizes other than 100x100, marks the starting position with a green box (sometimes hard to see at smaller zoom levels and the box is smaller than the "pixels" so it doesn't cover up the color of the "pixel" it's in), and includes a "zoom factor" (<code>ZOOM</code>) in case the individual "pixels" are hard to see on your monitor.
Line 4,598 ⟶ 4,599:
until false
</lang>
 
=={{header|M2000 Interpreter}}==
<lang M2000 Interpreter>
Line 4,743 ⟶ 4,745:
 
</pre >
 
=={{header|Mathematica}}==
[[File:LangtonsAnt.png|right|thumb|Output]]
 
<lang mathematica>direction = 1;
data = SparseArray[{{50, 50} -> -1}, {100, 100}, 1];
NestWhile[
{Re@#, Im@#} &@(direction *= (data[[Sequence @@ #]] *= -1) I) + # &,
{50, 50}, 1 <= Min@# <= Max@# <= 100 &];
Image@data</lang>
 
=={{header|MATLAB}} / {{header|Octave}}==
Line 4,766 ⟶ 4,778:
end;
end</lang>
 
=={{header|Octave}}==
<lang OCTAVE>clear
E=100 % Size of lattice.
N=11200 % Number of iterations.
z(1:1:E^2)=-1; % Init lattice rotations (-1=right, 1=left)
k(1:1:E^2)=0;
k(1)=(E^2+E)/2; % Init the Ant @ 50,50
for t=1:1:N;
k(t+1)=mod(k(t)+real(round((0.5*(E+1)*exp(i*pi/4*(trace(diag(z))-E^2)))-(0.5*(E-1)*exp(-i*pi/4*(trace(diag(z))-E^2)))))+imag(round((0.5*(E+1)*exp(i*pi/4*(trace(diag(z))-E^2)))-(0.5*(E-1)*exp(-i*pi/4*(trace(diag(z))-E^2))))),E^2);
z(k(t+1)+1)=real(exp(2*i*pi/4*(1+z(k(t+1)+1))));
endfor;
imagesc(reshape(z,E,E)) % Draw the Lattice
</lang>
 
=={{header|Mathematica}}==
[[File:LangtonsAnt.png|right|thumb|Output]]
 
<lang mathematica>direction = 1;
data = SparseArray[{{50, 50} -> -1}, {100, 100}, 1];
NestWhile[
{Re@#, Im@#} &@(direction *= (data[[Sequence @@ #]] *= -1) I) + # &,
{50, 50}, 1 <= Min@# <= Max@# <= 100 &];
Image@data</lang>
 
=={{header|Nim}}==
Line 4,865 ⟶ 4,853:
Run with:
$ ocaml graphics.cma langton.ml
 
=={{header|Octave}}==
<lang OCTAVE>clear
E=100 % Size of lattice.
N=11200 % Number of iterations.
z(1:1:E^2)=-1; % Init lattice rotations (-1=right, 1=left)
k(1:1:E^2)=0;
k(1)=(E^2+E)/2; % Init the Ant @ 50,50
for t=1:1:N;
k(t+1)=mod(k(t)+real(round((0.5*(E+1)*exp(i*pi/4*(trace(diag(z))-E^2)))-(0.5*(E-1)*exp(-i*pi/4*(trace(diag(z))-E^2)))))+imag(round((0.5*(E+1)*exp(i*pi/4*(trace(diag(z))-E^2)))-(0.5*(E-1)*exp(-i*pi/4*(trace(diag(z))-E^2))))),E^2);
z(k(t+1)+1)=real(exp(2*i*pi/4*(1+z(k(t+1)+1))));
endfor;
imagesc(reshape(z,E,E)) % Draw the Lattice
</lang>
 
=={{header|Ol}}==
Line 5,126 ⟶ 5,128:
print "\n";
}</lang>
 
=={{header|Perl 6}}==
{{trans|Perl}}
In this version we use 4-bits-per-char graphics to shrink the output to a quarter the area of ASCII graphics.
<lang perl6>constant @vecs = [1,0,1], [0,-1,1], [-1,0,1], [0,1,1];
constant @blocky = ' ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█'.comb;
constant $size = 100;
enum Square <White Black>;
my @plane = [White xx $size] xx $size;
my ($x, $y) = $size/2, $size/2;
my $dir = @vecs.keys.pick;
my $moves = 0;
loop {
given @plane[$x][$y] {
when :!defined { last }
when White { $dir--; $_ = Black; }
when Black { $dir++; $_ = White; }
}
($x,$y,$moves) »+=« @vecs[$dir %= @vecs];
}
say "Out of bounds after $moves moves at ($x, $y)";
for 0,2,4 ... $size - 2 -> $y {
say join '', gather for 0,2,4 ... $size - 2 -> $x {
take @blocky[ 1 * @plane[$x][$y]
+ 2 * @plane[$x][$y+1]
+ 4 * @plane[$x+1][$y]
+ 8 * @plane[$x+1][$y+1] ];
}
}</lang>
{{out}}
<pre>Out of bounds after 11669 moves at (-1, 26)
▄▚▚
▟▟▜▟▚
▜▀▚▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚ ▄
▜▘▗▌▟▘▟▘▗
▞▀▚ ▜▘▗▌▄▙▝▜
▐█ ▌▄▘▘▗▗▞▐▚▌
▌▖▝ ▐▚▙▙ ▖▀▖
▐▄▝█▀▖▄▗▗▗▀▐▛▛▙
▞▚▝▟██▜▞ ▞▗▜▌ ▞▘▌
▐▗▄▌▙▜▐▄▛▀▜▞▜▛▛▄▐
▘▗▝▜▚▖▌▟▞▛▜▌▜▖ █▌
▄▄ ▄▜▛▜▙▖▟▗▛▟▘▌ ▌
▟▖ ▘▘▄▛▌▛▟█▖ ▚▜▀ ▌
▘▘ █▚▛▜▟▌▘▗█▞▛▞▌ ▌
▐▖ ▙▐▙▗█▌▐▀ ▟▛ ▄ ▌
▟▙▚▛▀▄▗▟▖▐▗▘▛▐▀▟▌ ▌
▘▀▞▛▗▘▘█▐▞▗▗▝▟▖▄▝▝
▗▜▞▖▗▘▝█▜▞▖▗▙ ▝ ▙▌
▟▞▖▟▄▌▟▄▙▐█▗▟▙▟▚▗▞
▘▌▚▖▝▛▀ ▐▘▞█▀▟▛█▖
▄ ▝▛▚ ▀▜▙▜▜▀▜▚▄▘▙▖
▟▖▘▐▜▌▛▄▟▛▝▌ ▜▘▛▗▖▟▌
▘▀█▙▙▚▄▛▗▛▖ ▞▗▖▚▗▚▞
▜ ▖▄▙▛▚▀▗▜▛ ▞▗▝▛
▞▌▜▌█▀▀▘▖ ▙ ▌▀
▐▗▌█▛ ▀▚▞▚▞
▜▖
</pre>
 
=={{header|Phix}}==
Line 5,860 ⟶ 5,789:
####
##
</pre>
 
=={{header|Raku}}==
(formerly Perl 6)
{{trans|Perl}}
In this version we use 4-bits-per-char graphics to shrink the output to a quarter the area of ASCII graphics.
<lang perl6>constant @vecs = [1,0,1], [0,-1,1], [-1,0,1], [0,1,1];
constant @blocky = ' ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█'.comb;
constant $size = 100;
enum Square <White Black>;
my @plane = [White xx $size] xx $size;
my ($x, $y) = $size/2, $size/2;
my $dir = @vecs.keys.pick;
my $moves = 0;
loop {
given @plane[$x][$y] {
when :!defined { last }
when White { $dir--; $_ = Black; }
when Black { $dir++; $_ = White; }
}
($x,$y,$moves) »+=« @vecs[$dir %= @vecs];
}
say "Out of bounds after $moves moves at ($x, $y)";
for 0,2,4 ... $size - 2 -> $y {
say join '', gather for 0,2,4 ... $size - 2 -> $x {
take @blocky[ 1 * @plane[$x][$y]
+ 2 * @plane[$x][$y+1]
+ 4 * @plane[$x+1][$y]
+ 8 * @plane[$x+1][$y+1] ];
}
}</lang>
{{out}}
<pre>Out of bounds after 11669 moves at (-1, 26)
▄▚▚
▟▟▜▟▚
▜▀▚▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚
▜▘▗▌▟▚ ▄
▜▘▗▌▟▘▟▘▗
▞▀▚ ▜▘▗▌▄▙▝▜
▐█ ▌▄▘▘▗▗▞▐▚▌
▌▖▝ ▐▚▙▙ ▖▀▖
▐▄▝█▀▖▄▗▗▗▀▐▛▛▙
▞▚▝▟██▜▞ ▞▗▜▌ ▞▘▌
▐▗▄▌▙▜▐▄▛▀▜▞▜▛▛▄▐
▘▗▝▜▚▖▌▟▞▛▜▌▜▖ █▌
▄▄ ▄▜▛▜▙▖▟▗▛▟▘▌ ▌
▟▖ ▘▘▄▛▌▛▟█▖ ▚▜▀ ▌
▘▘ █▚▛▜▟▌▘▗█▞▛▞▌ ▌
▐▖ ▙▐▙▗█▌▐▀ ▟▛ ▄ ▌
▟▙▚▛▀▄▗▟▖▐▗▘▛▐▀▟▌ ▌
▘▀▞▛▗▘▘█▐▞▗▗▝▟▖▄▝▝
▗▜▞▖▗▘▝█▜▞▖▗▙ ▝ ▙▌
▟▞▖▟▄▌▟▄▙▐█▗▟▙▟▚▗▞
▘▌▚▖▝▛▀ ▐▘▞█▀▟▛█▖
▄ ▝▛▚ ▀▜▙▜▜▀▜▚▄▘▙▖
▟▖▘▐▜▌▛▄▟▛▝▌ ▜▘▛▗▖▟▌
▘▀█▙▙▚▄▛▗▛▖ ▞▗▖▚▗▚▞
▜ ▖▄▙▛▚▀▗▜▛ ▞▗▝▛
▞▌▜▌█▀▀▘▖ ▙ ▌▀
▐▗▌█▛ ▀▚▞▚▞
▜▖
</pre>
 
Line 6,624 ⟶ 6,627:
....................................................................................................
....................................................................................................</pre>
 
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
 
const type: direction is new enum UP, RIGHT, DOWN, LEFT end enum;
const proc: main is func
local
const integer: width is 75;
const integer: height is 52;
var array array boolean: m is height times width times FALSE;
var direction: dir is UP;
var integer: x is width div 2;
var integer: y is height div 2;
begin
while x in {1 .. width} and y in {1 .. height} do
dir := direction conv ((ord(dir) + 2 * ord(m[y][x]) - 1) mod 4);
m[y][x] := not m[y][x];
case dir of
when {UP}: decr(y);
when {RIGHT}: decr(x);
when {DOWN}: incr(y);
when {LEFT}: incr(x);
end case;
end while;
for key x range m do
for y range 1 to width do
write(".#"[succ(ord(m[x][y]))]);
end for;
writeln;
end for;
end func;</lang>
 
{{out}}
<pre>
...........................................................................
...........................................................................
...........................................................................
............................##..############..##...........................
...........................#..####..........#..##..........................
..........................###...##............##.#.........................
..........................#.#..#.........#..#....#.........................
......................##..##.#.#.........###.......#.......................
...................###.#..#...#.....#.....##.##..###.......................
....................#.#..###..##.####.##...#.#..#.##..##...................
....................#.###.##..#.##..###.#.#.....###...###..................
..................#.....#...#####.#.#..####..#...###.#.#.#.................
.................###.##...#.####..##.##.######.#.###.#...#.................
.................#.###.#.##.#.#.##.##.##.#...#####.###.##..................
.....................#.#...#.##.###...#...#.#..####....#.##................
..................#..#.........##.##...#..##.....##.#.....##...............
.................###...#.#.##.###..#..##.....#...###.##..##.#..............
................#..###..##...##.##...###..#....#..##.####...#..............
...............###...#...#.#..#.#.####.##..#.##.###..#.....#...............
..............#..###..#.##....#..#.###..#......###.##.#..#..##.............
.............###...#.....#.##.#.##..##..#####.####..####.##...#............
............#..###..#.#.#..#.###.#.#.##......##...#.#.#....#...#...........
...........###...#..##.###..##.#...##.......####.####...#......#...........
..........#..###..#.#..#...##..###########.#..####..#....#....#............
.........###...#..##......#.####..##..#########..#..##....#..##............
........#..###..#.#...##..#.##...##.##.###.###...#..#.##..####.#...........
.......###...#..##...#..#.######.##.#.##.#.#....###.###...##...#...........
......#..###..#.#...#.....#####.#.#####.....#.#..##.#....##...#............
.....###...#..##....#.....#.##.#####.##..#.#...#..#..##.#..#..#............
....#..###..#.#.....#....#...####.#..#####.##...##########...##............
...###...#..##......#.##...##...#..#...####..#...##.####.##................
..#..###..#.#........#####.#..##...##.#...#....#.#..#..#..#.#..............
.###...#..##..........##..##.#.#.#....##.##.#.#.##..#..##..##..............
#..###..#.#.................#..#....#.########.#.#.##..####.#..............
.###.#..##..................#..#...#.......##.##...#..#..##.#..............
#.#.#.#.#....................#..#..#......#..##..##...##.####..............
.####.##......................##...#.......##..##....#...#.###.............
.#.##.#............................#.##..####....####.###.####.............
..####..............................##..####....##..#.##.#.#..#............
...##................................##....##....##.###.##.#####...........
....................................................#.##.#..####...........
........................................................##.##.##...........
........................................................##.................
......................................................#.##..####.#.........
.....................................................#..#.###..###.........
.....................................................#.##.#..#..#..........
......................................................##......##...........
.......................................................##..................
...........................................................................
...........................................................................
...........................................................................
...........................................................................
</pre>
 
=={{header|Scilab}}==
Line 6,989 ⟶ 6,904:
! !
! # # !</pre>
 
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
 
const type: direction is new enum UP, RIGHT, DOWN, LEFT end enum;
const proc: main is func
local
const integer: width is 75;
const integer: height is 52;
var array array boolean: m is height times width times FALSE;
var direction: dir is UP;
var integer: x is width div 2;
var integer: y is height div 2;
begin
while x in {1 .. width} and y in {1 .. height} do
dir := direction conv ((ord(dir) + 2 * ord(m[y][x]) - 1) mod 4);
m[y][x] := not m[y][x];
case dir of
when {UP}: decr(y);
when {RIGHT}: decr(x);
when {DOWN}: incr(y);
when {LEFT}: incr(x);
end case;
end while;
for key x range m do
for y range 1 to width do
write(".#"[succ(ord(m[x][y]))]);
end for;
writeln;
end for;
end func;</lang>
 
{{out}}
<pre>
...........................................................................
...........................................................................
...........................................................................
............................##..############..##...........................
...........................#..####..........#..##..........................
..........................###...##............##.#.........................
..........................#.#..#.........#..#....#.........................
......................##..##.#.#.........###.......#.......................
...................###.#..#...#.....#.....##.##..###.......................
....................#.#..###..##.####.##...#.#..#.##..##...................
....................#.###.##..#.##..###.#.#.....###...###..................
..................#.....#...#####.#.#..####..#...###.#.#.#.................
.................###.##...#.####..##.##.######.#.###.#...#.................
.................#.###.#.##.#.#.##.##.##.#...#####.###.##..................
.....................#.#...#.##.###...#...#.#..####....#.##................
..................#..#.........##.##...#..##.....##.#.....##...............
.................###...#.#.##.###..#..##.....#...###.##..##.#..............
................#..###..##...##.##...###..#....#..##.####...#..............
...............###...#...#.#..#.#.####.##..#.##.###..#.....#...............
..............#..###..#.##....#..#.###..#......###.##.#..#..##.............
.............###...#.....#.##.#.##..##..#####.####..####.##...#............
............#..###..#.#.#..#.###.#.#.##......##...#.#.#....#...#...........
...........###...#..##.###..##.#...##.......####.####...#......#...........
..........#..###..#.#..#...##..###########.#..####..#....#....#............
.........###...#..##......#.####..##..#########..#..##....#..##............
........#..###..#.#...##..#.##...##.##.###.###...#..#.##..####.#...........
.......###...#..##...#..#.######.##.#.##.#.#....###.###...##...#...........
......#..###..#.#...#.....#####.#.#####.....#.#..##.#....##...#............
.....###...#..##....#.....#.##.#####.##..#.#...#..#..##.#..#..#............
....#..###..#.#.....#....#...####.#..#####.##...##########...##............
...###...#..##......#.##...##...#..#...####..#...##.####.##................
..#..###..#.#........#####.#..##...##.#...#....#.#..#..#..#.#..............
.###...#..##..........##..##.#.#.#....##.##.#.#.##..#..##..##..............
#..###..#.#.................#..#....#.########.#.#.##..####.#..............
.###.#..##..................#..#...#.......##.##...#..#..##.#..............
#.#.#.#.#....................#..#..#......#..##..##...##.####..............
.####.##......................##...#.......##..##....#...#.###.............
.#.##.#............................#.##..####....####.###.####.............
..####..............................##..####....##..#.##.#.#..#............
...##................................##....##....##.###.##.#####...........
....................................................#.##.#..####...........
........................................................##.##.##...........
........................................................##.................
......................................................#.##..####.#.........
.....................................................#..#.###..###.........
.....................................................#.##.#..#..#..........
......................................................##......##...........
.......................................................##..................
...........................................................................
...........................................................................
...........................................................................
...........................................................................
</pre>
 
=={{header|Sidef}}==
Line 7,550 ⟶ 7,553:
5: ; Print a newline and jump back to the counter check.
push 10 ochr jump 4</lang>
 
 
=={{header|XPL0}}==
10,333

edits