56 lines
941 B
Text
56 lines
941 B
Text
Module Ant {
|
|
Form 120,102
|
|
N=100
|
|
Enum CellColor {black=0,white=#FFFFFF}
|
|
Enum Direction{North=90, West=180, South=270, East=0}
|
|
Function Rotate(cd as Direction, clockwise=true) {
|
|
cd=(cd+if(clockwise->270,90)) mod 360
|
|
=cd ' return a Direction Enum type
|
|
}
|
|
|
|
dim rect(1 to N, 1 to N)=white
|
|
cx=N div 2
|
|
cy=N div 2
|
|
cd=North
|
|
rect(cx,cy)=black
|
|
endmove=False
|
|
while not endmove
|
|
movecell()
|
|
|
|
end while
|
|
Disp()
|
|
|
|
sub movecell()
|
|
select case rect(cx,cy)
|
|
case black
|
|
cd=Rotate(cd, false) : rect(cx, cy)=white
|
|
case white
|
|
cd=Rotate(cd) : rect(cx, cy)=black
|
|
end select
|
|
select case cd
|
|
case North
|
|
cy--
|
|
case West
|
|
cx--
|
|
case South
|
|
cy++
|
|
case East
|
|
cx++
|
|
end select
|
|
endmove= cx<1 or cx>N or cy<1 or cy>N
|
|
end sub
|
|
sub disp()
|
|
Local Doc$, i, j
|
|
Document Doc$
|
|
for i=1 to N:for j=1 to N
|
|
Doc$=if$(rect(j,i)=White->"_","#")
|
|
next
|
|
Doc$={
|
|
}
|
|
next
|
|
cls
|
|
Print #-2,Doc$
|
|
clipboard Doc$
|
|
end sub
|
|
}
|
|
Ant
|