RosettaCodeData/Task/Langtons-ant/Run-BASIC/langtons-ant.basic

30 lines
716 B
Plaintext

dim plane(100,100)
x = 50: y = 50: minY = 100
while (x>0) and (x<100) and (y>0) and (y<100)
if plane(x,y) then
nxt = nxt - 1
if nxt < 1 then nxt = 4
else
nxt = nxt + 1
if nxt > 4 then nxt = 1
end if
x = x + (nxt = 2) - (nxt = 4)
y = y + (nxt = 3) - (nxt = 1)
plane(x,y) = (plane(x,y) <> 1)
minY = min(y,minY) ' find lowest and
maxY = max(y,maxY) ' highest y to prevent printing blank lines
wend
graphic #g, 100,100
for y = minY to maxY
for x = 1 to 100
print chr$((plane(x,y)*3) + 32);
if plane(x,y) = 1 then #g "color green ; set "; x; " "; y else #g "color blue ; set "; x; " "; y
next x
print y
next y
render #g
#g "flush""