This is non-commercial site, its content is based on Atari 8-bit home computer contents and references.
If you feel your rights are violated by showing/using any part of contents of your product represented on this page,
please contact me immediatelly so I can remove it!
|
-
Entry name:Langton's Ant
-
Category:Graphics
-
Publisher/Developer:Rosetta Code
-
Year:2021
Listing 1
DEFINE DIRN="0" DEFINE DIRE="1" DEFINE DIRS="2" DEFINE DIRW="3" DEFINE BLACK="1" DEFINE WHITE="2" DEFINE MAXX="159" DEFINE MAXY="95" BYTE FUNC TurnLeft(BYTE dir) IF dir=DIRN THEN RETURN (DIRW) FI RETURN (dir-1) BYTE FUNC TurnRight(BYTE dir) IF dir=DIRW THEN RETURN (DIRN) FI RETURN (dir+1) PROC DrawAnt(INT x,y) BYTE c,dir dir=DIRN DO c=Locate(x,y) IF c=BLACK THEN Color=WHITE Plot(x,y) dir=TurnLeft(dir) ELSE Color=BLACK Plot(x,y) dir=TurnRight(dir) FI IF dir=DIRN THEN y==-1 IF y<0 THEN EXIT FI ELSEIF dir=DIRE THEN x==+1 IF X>MAXX THEN EXIT FI ELSEIF dir=DIRS THEN y==+1 IF Y>MAXY THEN EXIT FI ELSE x==-1 IF x<0 THEN EXIT FI FI OD RETURN PROC Main() BYTE CH=$02FC BYTE y Graphics(7+16) SetColor(0,0,2) SetColor(1,0,12) Color=2 FOR y=0 TO MAXY DO Plot(0,y) DrawTo(MAXX,y) OD DrawAnt(80,48) DO UNTIL CH#$FF OD CH=$FF RETURN
References
Listing downloads
Copyright holder