if dir==0 then dir=4 /*ant should be facing "west". */
if dir==5 then dir=1 /*and should be facing "north". */
select select /*ant walks direction it's facing*/
when dir==1 then y=y+1 /*walking north? Then go "up". */
when dir==2 then x=x+1 /*walking east? Then go "right"*/
when dir==3 then y=y-1 /*walking south? Then go "down".*/
when dir==4 then x=x-1 /*walking west? Then go "left".*/
end
end
end /*above code crops left of array*/
do y=tb to bb by -1; r_='' /*display thea plane (row) of cells. */
do x=minx to rb /*process a "row" of cells. */
r_=r_||@.x.y /*build a cell row for display. */
end
r_=translate(r_,' █#',0110) /*color the cells: black | white*/
if r_\='' then say strip(r_,'T') /*crop completely white rowslines. */
end
</lang>
Output
<pre style="height:50ex60ex;overflow:scroll">
──────── Langton's ant walked 11759 steps. ────────
██##
████####
█# ██## █#
██## ████####
█# █# █# █#
██## █# ██##
█# █# ██##
██## █# ███###
██## █# █# ███### █#
██## ██## ██## █# ███###
█# █# █# ██## █# █# █# ███### █#
███### ███### █# █# ██## █# ███###
█# ████#### ██## █# █# █# ███### █#
██## ██## █# ███###
██## ██## ██## █# █# ███### █#
████#### █# ██## █# ██## █# ███###
█████##### ██## ███### ██## ██## ██## █# █# ███### █#
█# █# █# ██## █# ██## ████#### ██## ██## █# ███###
████#### ███### ████#### ████#### ██## █# █# █# ███### █#
███### █# █# ██## ██## █# ██## ██## █# ███###
████#### ██## ██## ██## █# █# █# █# █# █# ███### █#
█# ██## █# █# ██## ██## █# █# █# ██## █# ███###
█# ████#### ██## █# █# ████████######## █# █# █# █# █# ███### █#
██## ██## █# ██## █# █# ██## ██## █# █# █# ██## ██## ██## █# ███###
█# █# █# █# █# █# █# █# ██## ██## █# █████##### █# █# ███### █#
██## ████#### ██## █# ████#### █# █# ██## ██## █# ██## █# ███###
██## ██████████########## ██## █████##### █# ████#### █# █# █# █# ███### █#
█# █# █# ██## █# █# █# █# ██## █████##### ██## █# █# ██## █# ███###
█# ██## █# ██## █# █# █████##### █# █████##### █# █# █# ███### █#
█# ██## ███### ███### █# █# ██## █# ██## ██████###### █# █# ██## █# ███###
█# ████#### ██## █# █# ███### ███### ██## ██## ██## █# ██## █# █# ███### █#
██## █# ██## █# █████████######### ██## ████#### █# ██## █# ███###
█# █# █# ████#### █# ███████████########### ██## █# █# █# ███### █#
█# █# ████#### ████#### ██## █# ██## ███### ██## █# ███###
█# █# █# █# █# ██## ██## █# █# ███### █# █# █# █# ███### █#
█# ██## ████#### ████#### █████##### ██## ██## █# ██## █# █# ███###
██## █# █# ██## ███### █# ███### █# █# ██## █# ███### █#
█# █# ███### ██## █# ██## ████#### █# █# █# █# █# ███###
█# ████#### ██## █# █# ███### ██## ██## ██## ███### █#
█# ██## ██## ███### █# ██## █# ███### ██## █# █# ███###
██## █# ██## ██## █# ██## ██## █# █#
██## █# ████#### █# █# █# ███### ██## █# █# █#
██## ███### █████##### █# ██## ██## ██## █# █# ██## █# ███### █#
█# █# ███### █# ██████###### ██## ██## ████#### █# ██## ███###
█# █# █# ███### █# ████#### █# █# █████##### █# █#
███### ███### █# █# ███### ██## █# ██## ███### █#
██## ██## █# █# █# ██## ████#### ██## ███### █# █#
███### ██## ██## █# █# █# █# ███###
█# ███### █# █# ██## ██##
█# █# █# █# █# █#
█# ██## ██## ███###
██## █# ████#### █#
██## ████████████############ ██##
</pre>
|