Home » Personal collection » Acorn ADFS disks » Archimedes » Files.ADF » BioBot/BBMotor3

BioBot/BBMotor3

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Personal collection » Acorn ADFS disks » Archimedes » Files.ADF
Filename: BioBot/BBMotor3
Read OK:
File size: 2621 bytes
Load address: FFFFFB45
Exec address: 70FD124F
Duplicates

There are 2 duplicate copies of this file in the archive:

File contents
   10 REM BallBot V4.0
   20 REM Real-Time Version with Continuous Testing Option
   30 REM New mechanical robot design changes (two motor drive)
   40 REM (C) Dominic Ford 1997
   50 :
   60 REM Welcome screen
   70 MODE6:@%=&905:PRINT" BallBot Artificial Intelligence Module"'"Simulation Tester V4.0 Real Time Version"''"Programmed and Designed by Dominic Ford"''SPC(16);"(C) 1997"
   80 PRINT'''"1. Real-Time Simulation"''"2. Logged Continuous Runs"''"3. Do specific run"
   90 REPEAT type$=GET$:UNTIL type$="1" OR type$="2" OR type$="3"
  100 :
  110 REM Setup variables
  120 ON ERROR OSCLI"CLOSE":REPORT:PRINT" at line ";ERL:END
  130 VOICE 1,"StringLib-Soft":*STEREO 1 0
  140 VOICE 2,"StringLib-Soft":*STEREO 2 -127
  150 VOICE 3,"StringLib-Soft":*STEREO 3 127
  160 current=0:DIMball(4,1):bbx=640:bby=950:dir=270:PROCsetupbb
  170 MODE12:IF type$="1" THEN MOUSE ON:PROCdrawfull
  180 IF type$="2" THEN start=TIME:stage=0:idle=FALSE:INPUT"Filename";f$:OSCLI"SPOOL "+f$
  190 IF type$="3" THEN PRINT"Enter Data:"':FORb=0TO4:PRINT"Ball ";b+1;:INPUTball(b,0),ball(b,1):NEXT:type$="1":MOUSE ON:PROCdrawfull
  200 :
  210 REM Start main loop
  220 REPEAT:T=TIME
  230 IF type$="1" THEN PROCuser ELSE PROCcompmon
  240 IF idle THEN UNTIL FALSE
  250 PROCsense
  260 mov=FNai(freqa,freqb,freqc,freqd)
  270 left=(mov AND 1)<>0
  280 right=(mov AND 2)<>0
  290 turbo=(mov AND 4)<>0
  300 on=(mov AND 8)<>0
  310 reverse=(mov AND 16)<>0
  320 PROCmoveit
  330 IF type$="1" THEN PRINTTAB(0,2)TIME-T
  340 REPEAT UNTIL TIME>(T+15)
  350 UNTIL FALSE
  360 :
  370 REM Graphic interface
  380 DEFPROCdrawfull
  390 REM Set up constants
  400 LOCALsx,sy,width
  410 sx=1:sy=2:width=10
  420 REM Setup Colours
  430 COLOUR0,0,64,0:COLOUR1,255,0,0:COLOUR2,255,255,255:COLOUR3,255,0,0:COLOUR4,255,255,0:COLOUR5,0,0,0:COLOUR6,255,255,0
  440 :
  450 REM Draw green court area
  460 CLS:GCOL0,0:RECTANGLE FILL 0,0,1279,1023
  470 REM Mark out white lines onto court
  480 GCOL0,2:RECTANGLE FILL sx/(23.77+2*sx)*1280,sy/(10.97+2*sy)*1024,23.77/(23.77+2*sx)*1280,width:RECTANGLE FILL sx/(23.77+2*sx)*1280,(1.37+sy)/(10.97+2*sy)*1024,23.77/(23.77+2*sx)*1280,width
  490 RECTANGLE FILL sx/(23.77+2*sx)*1280,(9.6+sy)/(10.97+2*sy)*1024,23.77/(23.77+2*sx)*1280,width:RECTANGLE FILL sx/(23.77+2*sx)*1280,(10.97+sy)/(10.97+2*sy)*1024,23.77/(23.77+2*sx)*1280,width
  500 RECTANGLE FILL (sx+5.47)/(23.77+2*sx)*1280,(sy+5.49)/(10.97+2*sy)*1024,12.8/(23.77+2*sx)*1280,width
  510 RECTANGLE FILL sx/(23.77+2*sx)*1280,sy/(10.97+2*sy)*1024,width,10.97/(10.97+2*sy)*1024:RECTANGLE FILL (sx+23.77)/(23.77+2*sx)*1280,sy/(10.97+2*sy)*1024,width,10.97/(10.97+2*sy)*1024+width
  520 RECTANGLE FILL (sx+5.47)/(23.77+2*sx)*1280,(sy+1.37)/(10.97+2*sy)*1024,width,8.23/(10.97+2*sy)*1024:RECTANGLE FILL (sx+18.3)/(23.77+2*sx)*1280,(sy+1.37)/(10.97+2*sy)*1024,width,8.23/(10.97+2*sy)*1024
  530 :
  540 REM Draw net
  550 GCOL0,5:FORl=100TO924STEP10:MOVE 640,l:DRAW 680,l+50:NEXT:FORl=0TO40STEP10:MOVE 640+l,100+l:DRAW640+l,924+l:NEXT:FORl=0TO5:MOVE637+l,100:DRAW677+l,150:MOVE637+l,924:DRAW677+l,974:NEXT
  560 GCOL0,2:MOVE 682,142:DRAW682,966
  570 PROCdrawmini
  580 ENDPROC
  590 :
  600 REM Draw ballbot and balls
  610 DEFPROCdrawmini
  620 IF type$="2" THEN ENDPROC
  630 GCOL3,4:FORb=0TO4
  640 IF ball(b,0)<>0 OR ball(b,1)<>0 THEN RECTANGLE FILL ball(b,0),ball(b,1),5,5
  650 NEXT
  660 GCOL3,3:RECTANGLE FILL bbx,bby,5,5
  670 ENDPROC
  680 :
  690 REM User interface (putting balls down)
  700 DEFPROCuser
  710 MOUSE x,y,c
  720 IF c=0 THEN ENDPROC
  730 IF (c AND 4)<>0 THEN PROCdrawmini:ball(current,0)=x:ball(current,1)=y:current=(current+1)MOD5:PROCdrawmini
  740 IF (c AND 2)<>0 THEN idle=FALSE:stage=0:start=TIME
  750 REPEAT
  760 MOUSE x,y,c
  770 UNTIL c=0
  780 ENDPROC
  790 :
  800 REM Calculate ballbot's new position
  810 DEFPROCmoveit
  820 LOCAL speed
  830 IF NOT on THEN ENDPROC
  840 IF ((NOT reverse) AND left AND (NOT right)) OR (reverse AND right AND (NOT left)) THEN dir=dir-2.5*(1-3*turbo):speed=0.1+0.2*reverse
  850 IF ((NOT reverse) AND right AND (NOT left)) OR (reverse AND left AND (NOT right)) THEN dir=dir+2.5*(1-3*turbo):speed=0.1+0.2*reverse
  860 IF left AND right THEN speed=1+2*reverse
  870 :
  880 REM Get direction in range 0<theta<360
  890 REPEAT IF dir<0 THEN dir=dir+360
  900 IF dir>=360 THEN dir=dir-360
  910 UNTIL dir>=0 AND dir<360
  920 :
  930 PROCdrawmini:bbx=bbx+15*SIN(PI*dir/180)*speed*(.75*-turbo+.25)
  940 bby=bby+20*COS(PI*dir/180)*speed*(.75*-turbo+.25)
  950 FORball=0TO4:IF ABS(bbx-ball(ball,0))<10 AND ABS(bby-ball(ball,1))<10 THEN ball(ball,0)=0
  960 NEXT:PROCdrawmini
  970 ENDPROC
  980 :
  990 REM Calculate ballbot's background echo reading (-balls)
 1000 DEFFNback(freq,min,max)
 1010 REM Get angular range in form 0<theta<360
 1020 REM Set up initial outside range settings
 1030 hit=0:dist=9999:dista=9999:hita=0:REM LOCAL hit,dist,hita,dista
 1040 REM If straight at net is in range, will be shortest.
 1050 IF((bbx<640ANDmin<=90ANDmax>=90)OR(bbx>640ANDmin<=270ANDmax>=270)) AND (bby>100 AND bby<923) THEN hit=bby:dist=ABS(bbx-640):min=0:max=0
 1060 REM Otherwise find shortest extreme of range
 1070 IF SIN(PI*min/180)<>0 THEN dist=(640-bbx)/SIN(PI*min/180):hit=bby+(640-bbx)/TAN(PI*min/180)
 1080 IF SIN(PI*max/180)<>0 THEN dista=(640-bbx)/SIN(PI*max/180):hita=bby+(640-bbx)/TAN(PI*max/180)
 1090 REM Just check if post in middle of range
 1100 IF bbx<640 AND hit>100 AND (hita<100 OR dista<0) AND dist>0 THEN hita=100:dista=SQR((bbx-640)^2+(bby-100)^2)
 1110 IF bbx<640 AND hita<923 AND (hit>923 OR dist<0) AND dista>0 THEN hit=923:dist=SQR((bbx-640)^2+(bby-923)^2)
 1120 IF bbx>640 AND hita>100 AND (hit<100 OR dist<0) AND dista>0 THEN hit=100:dist=SQR((bbx-640)^2+(bby-100)^2)
 1130 IF bbx>640 AND hit<923 AND (hita>923 OR dista<0) AND dist>0 THEN hita=923:dista=SQR((bbx-640)^2+(bby-923)^2)
 1140 REM Pick best to send off!
 1150 IF dist<0 OR (dista<dist AND hita>100 AND hita<923) THEN dist=dista:hit=hita
 1160 IF hit>923 OR hit<100 OR dist<0 THEN ftype$="U":=freq+RND(6)-3
 1170 IF hit>900 OR hit<123 THEN ftype$="P":=dist
 1180 ftype$="N"
 1190 =dist
 1200 :
 1210 REM Calculate Ballbot's readings (MAIN ROUTINE)
 1220 :
 1230 DEFPROCsense
 1240 REM Get background readings from FNback
 1250 freq=RND(250)+1500
 1260 freqa=FNback(freq,dir-15,dir+15):fa$=ftype$
 1270 freqb=FNback(freq,dir-45,dir-15):fb$=ftype$
 1280 freqc=FNback(freq,dir+15,dir+45):fc$=ftype$
 1290 freqd=FNback(freq,dir-75,dir-45):fd$=ftype$
 1300 :
 1310 REM Add any relevant balls to readings (using hairy trigonometry)
 1320 :
 1330 FORball=0TO4
 1340 d%=SQR((ball(ball,0)-bbx)^2+(ball(ball,1)-bby)^2)
 1350 IF ball(ball,0)=0 THEN d%=9999
 1360 a=FNangle(ball(ball,0),ball(ball,1),bbx,bby)-dir
 1370 IFa>180 THEN a=a-360
 1380 IFa<=-179 THEN a=a+360
 1390 IF ABS(a)<15 AND freqa>d% THEN freqa=d%:fa$="B"
 1400 IF a>-46 AND a<=-15 AND freqb>d% THEN freqb=d%:fb$="B"
 1410 IF a>=15 AND a<46 AND freqc>d% THEN freqc=d%:fc$="B"
 1420 IF a>-75 AND a<=-46 AND freqd>d% THEN freqd=d%:fd$="B"
 1430 NEXT
 1440 :
 1450 REM Update user displays
 1460 :
 1470 IF type$="2" THEN ENDPROC
 1480 PRINTTAB(0,0)INT((TIME-start)/6000);":";(INT((TIME-start)/100)MOD60);" "
 1490 PRINTTAB(0,31)fd$,fb$,fa$,fc$,stage,INT(searching),left,right," ",dir," ",near;
 1500 SOUND 1,-1,freqa/4,5:SOUND 2,-1,freqb/4,5:SOUND 3,-1,freqc/4,5
 1510 ENDPROC
 1520:
 1530 REM Calculate bearing of B from A
 1540 DEFFNangle(x1,y1,x2,y2)
 1550 IF y2=y1 THEN ang=90 ELSE ang=180*ATN((x2-x1)/(y2-y1))/PI
 1560 IF (y2>y1) THEN ang=ang+180
 1570 IF ang<0 THEN ang=ang+360
 1580 =ang MOD 360
 1590 :
 1600 REM Computer Monitor of BallBot's progress
 1610 DEFPROCcompmon
 1620 IF idle AND (ball(0,0)<>0 OR ball(1,0)<>0 OR ball(2,0)<>0 OR ball(3,0)<>0 OR ball(4,0)<>0) THEN st$="Fail" ELSE st$="Pass"
 1630 IF idle THEN PRINTst$,INT((TIME-start)/6000);":";(INT((TIME-start)/100)MOD60)
 1640 IF TIME>start+36000 THEN idle=TRUE:PRINT"Time","****"
 1650 IFbbx>635ANDbbx<645ANDbby>105ANDbby<920THENidle=TRUE:PRINT"Crash","****"
 1660 IF idle THEN bbx=640:bby=950:dir=270:stage=0:PROCsetupbb:start=TIME:FORb=0TO4:ball(b,0)=RND(1180):ball(b,1)=RND(1024):ball(b,0)=ball(b,0)-100*((ball(b,0) DIV 100)=6):NEXT
 1670 IF idle THEN PRINT"[";ball(0,0);",";ball(0,1);"] [";ball(1,0);",";ball(1,1);"] [";ball(2,0);",";ball(2,1);"] [";ball(3,0);",";ball(3,1);"] [";ball(4,0);",";ball(4,1);"]",;:idle=FALSE
 1680 ENDPROC
 1690 :
 1700 REM BALLBOT ROBOTIC INTELLIGENCE MODULE
 1710 :
 1720 DEFFNai(freqa,freqb,freqc,freqd)
 1730 REM Artificial intelligence routines (ie. What Next??)
 1740 LOCALleft,right,turbo,reverse
 1750 left=FALSE:right=FALSE:turbo=FALSE:reverse=FALSE
 1760 :
 1770 REM What stage are we in? Hunt for balls or move to new area?
 1780 IF near<>0 AND stage<4 THEN PROCdonearstuff
 1790 IF near=0 AND (stage=0 OR stage=2) THEN PROChunt
 1800 IF near=0 AND (stage=1 OR stage=3) THEN PROCmoveout
 1810 IF stage=4 THEN PROCreleaseb
 1820 :
 1830 REM Prepare output into binary for transmission
 1840 feed=0:IF left THEN feed=feed+1
 1850 IF right THEN feed=feed+2
 1860 IF turbo THEN feed=feed+4
 1870 IF NOT idle THEN feed=feed+8
 1880 IF reverse THEN feed=feed+16
 1890 =feed
 1900 :
 1910 REM Perform a sweep to find any balls
 1920 DEFPROChunt
 1930 REM Watch out if too near to net
 1940 IF (fa$<>"B" AND freqa<30)OR(fb$<>"B" AND freqb<10)OR(fc$<>"B" AND freqc<10) THEN reving=5:turbo=TRUE:reverse=TRUE:right=TRUE:left=TRUE:ENDPROC
 1950 IF reving>0 AND (freqa<150 OR freqb<150 OR freqc<150) THEN reving=reving-1:turbo=TRUE:reverse=TRUE:right=FALSE:left=TRUE:ENDPROC
 1960 reving=0
 1970 :
 1980 REM Rotate to face ball
 1990 REM Where search after this ball?
 2000 IF (fb$="B" AND freqb>150) THEN tending=0
 2010 IF fc$="B" AND freqc>150 THEN tending=1
 2020 REM Pick best ball to aim at
 2030 dist=freqa*0.75:IF dist>freqb AND fb$="B" AND (freqb<freqc OR fc$<>"B") THEN steer=-1:left=TRUE:ENDPROC
 2040 IF dist>freqc AND fc$="B" THEN steer=1:right=TRUE:ENDPROC
 2050 IF fa$="B" THEN left=(steer<>1):right=(steer<>-1):steer=0:searching=searching/2:turbo=freqa>100:ENDPROC
 2060 IF fb$="B" THEN steer=-1:left=TRUE:ENDPROC
 2070 IF fc$="B" THEN steer=1:right=TRUE:ENDPROC
 2080 :
 2090 REM If no ball in sight, continue rotation...
 2100 searching=searching+1:turbo=(searching>5):steer=0
 2110 IF (tending AND 1)<>0 THEN right=TRUE ELSE left=TRUE
 2120 IF searching=5 THEN tending=(tending EOR 1)
 2130 IF searching>50 THEN stage=stage+1
 2140 ENDPROC
 2150 :
 2160 REM Find edge of net and aim for it to move to other side
 2170 DEFPROCmoveout
 2180 REM Watch out if too near to net
 2190 IF (freqa<30 OR freqb<30 OR freqc<30) OR (reving AND (freqa<75 OR freqb<75 OR freqc<75)) THEN reving=TRUE:reverse=TRUE:right=TRUE:left=TRUE:ENDPROC
 2200 reving=FALSE
 2210 REM If ball in sight, go get it!
 2220 IF fa$="B" OR fb$="B" OR fc$="B" THEN stage=stage-1:searching=44:ENDPROC
 2230 REM Align ballbot to face the net post...
 2240 IF fa$="N" OR fa$="P" THEN right=TRUE:ENDPROC
 2250 IF fb$<>"N" AND fb$<>"P" THEN left=TRUE:ENDPROC
 2260 IF fb$="P" AND freqb<150 THEN right=TRUE:near=1:ENDPROC
 2270 turbo=TRUE:left=TRUE:right=TRUE
 2280 ENDPROC
 2290 :
 2300 REM Nearly there... Just need a little nudge in the right direction.
 2310 DEFPROCdonearstuff
 2320 IF freqa<30 AND fa$<>"B" THEN right=TRUE:ENDPROC
 2330 IF near=1 AND fd$<>"U" THEN left=TRUE:right=TRUE:ENDPROC
 2340 near=near+1:left=TRUE:right=(near MOD 2)=1:turbo=TRUE
 2350 IF near>18 THEN near=0:stage=stage+1:searching=0:tending=1
 2360 ENDPROC
 2370 :
 2380 REM Initialise BallBot variables at the beginning of a run
 2390 DEFPROCsetupbb
 2400 reving=FALSE:left=FALSE:right=FALSE:searching=0:idle=TRUE
 2410 near=FALSE:tending=1:steer=0
 2420 ENDPROC
 2430 :
 2440 DEFPROCreleaseb
 2450 REM Got all the balls, now just dump them!
 2460 near=near+1
 2470 IF near>9 THEN idle=TRUE:near=FALSE
 2480 ENDPROC

 � BallBot V4.0
7 � Real-Time Version with Continuous Testing Option
< � New mechanical robot design changes (two motor drive)
( � (C) Dominic Ford 1997
2 :
< � Welcome screen
F� �6:@%=&905:�" BallBot Artificial Intelligence Module"'"Simulation Tester V4.0 Real Time Version"''"Programmed and Designed by Dominic Ford"''�(16);"(C) 1997"
PU �'''"1. Real-Time Simulation"''"2. Logged Continuous Runs"''"3. Do specific run"
Z2 � type$=�:� type$="1" � type$="2" � type$="3"
d :
n � Setup variables
x$ � � �"CLOSE":�:�" at line ";�:�
�& ȡ 1,"StringLib-Soft":*STEREO 1 0
�) ȡ 2,"StringLib-Soft":*STEREO 2 -127
�( ȡ 3,"StringLib-Soft":*STEREO 3 127
�: current=0:�ball(4,1):bbx=640:bby=950:dir=270:�setupbb
�% �12:� type$="1" � ȗ �:�drawfull
�E � type$="2" � start=�:stage=0:idle=�:�"Filename";f$:�"SPOOL "+f$
�g � type$="3" � �"Enter Data:"':�b=0�4:�"Ball ";b+1;:�ball(b,0),ball(b,1):�:type$="1":ȗ �:�drawfull
� :
� � Start main loop
�
 �:T=�
�# � type$="1" � �user � �compmon
� � idle � � �
� �sense
% mov=�ai(freqa,freqb,freqc,freqd)
 left=(mov � 1)<>0
 right=(mov � 2)<>0
" turbo=(mov � 4)<>0
, on=(mov � 8)<>0
6 reverse=(mov � 16)<>0
@ �moveit
J � type$="1" � �0,2)�-T
T � � �>(T+15)
^ � �
h :
r � Graphic interface
| ��drawfull
� � Set up constants
� �sx,sy,width
� sx=1:sy=2:width=10
� � Setup Colours
�V �0,0,64,0:�1,255,0,0:�2,255,255,255:�3,255,0,0:�4,255,255,0:�5,0,0,0:�6,255,255,0
� :
� � Draw green court area
� �:�0,0:ȓ Ȑ 0,0,1279,1023
�& � Mark out white lines onto court
� �0,2:ȓ Ȑ sx/(23.77+2*sx)*1280,sy/(10.97+2*sy)*1024,23.77/(23.77+2*sx)*1280,width:ȓ Ȑ sx/(23.77+2*sx)*1280,(1.37+sy)/(10.97+2*sy)*1024,23.77/(23.77+2*sx)*1280,width
� ȓ Ȑ sx/(23.77+2*sx)*1280,(9.6+sy)/(10.97+2*sy)*1024,23.77/(23.77+2*sx)*1280,width:ȓ Ȑ sx/(23.77+2*sx)*1280,(10.97+sy)/(10.97+2*sy)*1024,23.77/(23.77+2*sx)*1280,width
�_ ȓ Ȑ (sx+5.47)/(23.77+2*sx)*1280,(sy+5.49)/(10.97+2*sy)*1024,12.8/(23.77+2*sx)*1280,width
�� ȓ Ȑ sx/(23.77+2*sx)*1280,sy/(10.97+2*sy)*1024,width,10.97/(10.97+2*sy)*1024:ȓ Ȑ (sx+23.77)/(23.77+2*sx)*1280,sy/(10.97+2*sy)*1024,width,10.97/(10.97+2*sy)*1024+width
� ȓ Ȑ (sx+5.47)/(23.77+2*sx)*1280,(sy+1.37)/(10.97+2*sy)*1024,width,8.23/(10.97+2*sy)*1024:ȓ Ȑ (sx+18.3)/(23.77+2*sx)*1280,(sy+1.37)/(10.97+2*sy)*1024,width,8.23/(10.97+2*sy)*1024
 :
 � Draw net
&� �0,5:�l=100�924�10:� 640,l:� 680,l+50:�:�l=0�40�10:� 640+l,100+l:�640+l,924+l:�:�l=0�5:�637+l,100:�677+l,150:�637+l,924:�677+l,974:�
0 �0,2:� 682,142:�682,966
: �drawmini
D �
N :
X � Draw ballbot and balls
b ��drawmini
l � type$="2" � �
v �3,4:�b=0�4
�B � ball(b,0)<>0 � ball(b,1)<>0 � ȓ Ȑ ball(b,0),ball(b,1),5,5
� �
� �3,3:ȓ Ȑ bbx,bby,5,5
� �
� :
�* � User interface (putting balls down)
� ��user
�
 ȗ x,y,c
� � c=0 � �
�a � (c � 4)<>0 � �drawmini:ball(current,0)=x:ball(current,1)=y:current=(current+1)�5:�drawmini
�* � (c � 2)<>0 � idle=�:stage=0:start=�
� �
�
 ȗ x,y,c

 � c=0
 �
 :
 ' � Calculate ballbot's new position
*
 ��moveit
4 � speed
> � � on � �
Hv � ((� reverse) � left � (� right)) � (reverse � right � (� left)) � dir=dir-2.5*(1-3*turbo):speed=0.1+0.2*reverse
Rv � ((� reverse) � right � (� left)) � (reverse � left � (� right)) � dir=dir+2.5*(1-3*turbo):speed=0.1+0.2*reverse
\' � left � right � speed=1+2*reverse
f :
p) � Get direction in range 0<theta<360
z � � dir<0 � dir=dir+360
� � dir>=360 � dir=dir-360
� � dir>=0 � dir<360
� :
�= �drawmini:bbx=bbx+15*�(�*dir/180)*speed*(.75*-turbo+.25)
�3 bby=bby+20*�(�*dir/180)*speed*(.75*-turbo+.25)
�Q �ball=0�4:� �(bbx-ball(ball,0))<10 � �(bby-ball(ball,1))<10 � ball(ball,0)=0
� �:�drawmini
� �
� :
�; � Calculate ballbot's background echo reading (-balls)
� ݤback(freq,min,max)
�, � Get angular range in form 0<theta<360
�, � Set up initial outside range settings
B hit=0:dist=9999:dista=9999:hita=0:� LOCAL hit,dist,hita,dista
8 � If straight at net is in range, will be shortest.
y �((bbx<640�min<=90�max>=90)�(bbx>640�min<=270�max>=270)) � (bby>100 � bby<923) � hit=bby:dist=�(bbx-640):min=0:max=0
$/ � Otherwise find shortest extreme of range
.S � �(�*min/180)<>0 � dist=(640-bbx)/�(�*min/180):hit=bby+(640-bbx)/�(�*min/180)
8U � �(�*max/180)<>0 � dista=(640-bbx)/�(�*max/180):hita=bby+(640-bbx)/�(�*max/180)
B, � Just check if post in middle of range
Ld � bbx<640 � hit>100 � (hita<100 � dista<0) � dist>0 � hita=100:dista=�((bbx-640)^2+(bby-100)^2)
Vb � bbx<640 � hita<923 � (hit>923 � dist<0) � dista>0 � hit=923:dist=�((bbx-640)^2+(bby-923)^2)
`b � bbx>640 � hita>100 � (hit<100 � dist<0) � dista>0 � hit=100:dist=�((bbx-640)^2+(bby-100)^2)
jd � bbx>640 � hit<923 � (hita>923 � dista<0) � dist>0 � hita=923:dista=�((bbx-640)^2+(bby-923)^2)
t � Pick best to send off!
~H � dist<0 � (dista<dist � hita>100 � hita<923) � dist=dista:hit=hita
�; � hit>923 � hit<100 � dist<0 � ftype$="U":=freq+�(6)-3
�+ � hit>900 � hit<123 � ftype$="P":=dist
� ftype$="N"
�
 =dist
� :
�2 � Calculate Ballbot's readings (MAIN ROUTINE)
� :
� ��sense
�* � Get background readings from FNback
� freq=�(250)+1500
�/ freqa=�back(freq,dir-15,dir+15):fa$=ftype$
�/ freqb=�back(freq,dir-45,dir-15):fb$=ftype$
/ freqc=�back(freq,dir+15,dir+45):fc$=ftype$

/ freqd=�back(freq,dir-75,dir-45):fd$=ftype$
 :
D � Add any relevant balls to readings (using hairy trigonometry)
( :
2 �ball=0�4
<4 d%=�((ball(ball,0)-bbx)^2+(ball(ball,1)-bby)^2)
F � ball(ball,0)=0 � d%=9999
P4 a=�angle(ball(ball,0),ball(ball,1),bbx,bby)-dir
Z �a>180 � a=a-360
d �a<=-179 � a=a+360
n, � �(a)<15 � freqa>d% � freqa=d%:fa$="B"
x3 � a>-46 � a<=-15 � freqb>d% � freqb=d%:fb$="B"
�1 � a>=15 � a<46 � freqc>d% � freqc=d%:fc$="B"
�3 � a>-75 � a<=-46 � freqd>d% � freqd=d%:fd$="B"
� �
� :
� � Update user displays
� :
� � type$="2" � �
�: �0,0)�((�-start)/6000);":";(�((�-start)/100)�60);" "
�K �0,31)fd$,fb$,fa$,fc$,stage,�(searching),left,right," ",dir," ",near;
�7 � 1,-1,freqa/4,5:� 2,-1,freqb/4,5:� 3,-1,freqc/4,5
� �
�:
�$ � Calculate bearing of B from A
 ݤangle(x1,y1,x2,y2)
4 � y2=y1 � ang=90 � ang=180*�((x2-x1)/(y2-y1))/�
 � (y2>y1) � ang=ang+180
" � ang<0 � ang=ang+360
, =ang � 360
6 :
@- � Computer Monitor of BallBot's progress
J ��compmon
Tr � idle � (ball(0,0)<>0 � ball(1,0)<>0 � ball(2,0)<>0 � ball(3,0)<>0 � ball(4,0)<>0) � st$="Fail" � st$="Pass"
^> � idle � �st$,�((�-start)/6000);":";(�((�-start)/100)�60)
h, � �>start+36000 � idle=�:�"Time","****"
r< �bbx>635�bbx<645�bby>105�bby<920�idle=�:�"Crash","****"
|� � idle � bbx=640:bby=950:dir=270:stage=0:�setupbb:start=�:�b=0�4:ball(b,0)=�(1180):ball(b,1)=�(1024):ball(b,0)=ball(b,0)-100*((ball(b,0) � 100)=6):�
�� � idle � �"[";ball(0,0);",";ball(0,1);"] [";ball(1,0);",";ball(1,1);"] [";ball(2,0);",";ball(2,1);"] [";ball(3,0);",";ball(3,1);"] [";ball(4,0);",";ball(4,1);"]",;:idle=�
� �
� :
�* � BALLBOT ROBOTIC INTELLIGENCE MODULE
� :
�" ݤai(freqa,freqb,freqc,freqd)
�9 � Artificial intelligence routines (ie. What Next??)
� �left,right,turbo,reverse
�% left=�:right=�:turbo=�:reverse=�
� :
�@ � What stage are we in? Hunt for balls or move to new area?
�' � near<>0 � stage<4 � �donearstuff
�+ � near=0 � (stage=0 � stage=2) � �hunt
. � near=0 � (stage=1 � stage=3) � �moveout
 � stage=4 � �releaseb
 :
&2 � Prepare output into binary for transmission
0  feed=0:� left � feed=feed+1
: � right � feed=feed+2
D � turbo � feed=feed+4
N � � idle � feed=feed+8
X � reverse � feed=feed+16
b
 =feed
l :
v( � Perform a sweep to find any balls
� ��hunt
�# � Watch out if too near to net
�v � (fa$<>"B" � freqa<30)�(fb$<>"B" � freqb<10)�(fc$<>"B" � freqc<10) � reving=5:turbo=�:reverse=�:right=�:left=�:�
�j � reving>0 � (freqa<150 � freqb<150 � freqc<150) � reving=reving-1:turbo=�:reverse=�:right=�:left=�:�
�
 reving=0
� :
� � Rotate to face ball
�$ � Where search after this ball?
�( � (fb$="B" � freqb>150) � tending=0
�& � fc$="B" � freqc>150 � tending=1
� � Pick best ball to aim at
�Z dist=freqa*0.75:� dist>freqb � fb$="B" � (freqb<freqc � fc$<>"B") � steer=-1:left=�:�
�/ � dist>freqc � fc$="B" � steer=1:right=�:�
b � fa$="B" � left=(steer<>1):right=(steer<>-1):steer=0:searching=searching/2:turbo=freqa>100:�
" � fb$="B" � steer=-1:left=�:�
" � fc$="B" � steer=1:right=�:�
  :
*0 � If no ball in sight, continue rotation...
46 searching=searching+1:turbo=(searching>5):steer=0
>* � (tending � 1)<>0 � right=� � left=�
H* � searching=5 � tending=(tending � 1)
R# � searching>50 � stage=stage+1
\ �
f :
p< � Find edge of net and aim for it to move to other side
z ��moveout
�# � Watch out if too near to net
�{ � (freqa<30 � freqb<30 � freqc<30) � (reving � (freqa<75 � freqb<75 � freqc<75)) � reving=�:reverse=�:right=�:left=�:�
�
 reving=�
�# � If ball in sight, go get it!
�A � fa$="B" � fb$="B" � fc$="B" � stage=stage-1:searching=44:�
�, � Align ballbot to face the net post...
�$ � fa$="N" � fa$="P" � right=�:�
�% � fb$<>"N" � fb$<>"P" � left=�:�
�- � fb$="P" � freqb<150 � right=�:near=1:�
� turbo=�:left=�:right=�
� �
� :
�G � Nearly there... Just need a little nudge in the right direction.
	 ��donearstuff
	& � freqa<30 � fa$<>"B" � right=�:�
	+ � near=1 � fd$<>"U" � left=�:right=�:�
	$2 near=near+1:left=�:right=(near � 2)=1:turbo=�
	.; � near>18 � near=0:stage=stage+1:searching=0:tending=1
	8 �
	B :
	L= � Initialise BallBot variables at the beginning of a run
	V ��setupbb
	`/ reving=�:left=�:right=�:searching=0:idle=�
	j near=�:tending=1:steer=0
	t �
	~ :
	� ��releaseb
	�- � Got all the balls, now just dump them!
	� near=near+1
	� � near>9 � idle=�:near=�
	� �
�
00000000  0d 00 0a 13 20 f4 20 42  61 6c 6c 42 6f 74 20 56  |.... . BallBot V|
00000010  34 2e 30 0d 00 14 37 20  f4 20 52 65 61 6c 2d 54  |4.0...7 . Real-T|
00000020  69 6d 65 20 56 65 72 73  69 6f 6e 20 77 69 74 68  |ime Version with|
00000030  20 43 6f 6e 74 69 6e 75  6f 75 73 20 54 65 73 74  | Continuous Test|
00000040  69 6e 67 20 4f 70 74 69  6f 6e 0d 00 1e 3c 20 f4  |ing Option...< .|
00000050  20 4e 65 77 20 6d 65 63  68 61 6e 69 63 61 6c 20  | New mechanical |
00000060  72 6f 62 6f 74 20 64 65  73 69 67 6e 20 63 68 61  |robot design cha|
00000070  6e 67 65 73 20 28 74 77  6f 20 6d 6f 74 6f 72 20  |nges (two motor |
00000080  64 72 69 76 65 29 0d 00  28 1c 20 f4 20 28 43 29  |drive)..(. . (C)|
00000090  20 44 6f 6d 69 6e 69 63  20 46 6f 72 64 20 31 39  | Dominic Ford 19|
000000a0  39 37 0d 00 32 06 20 3a  0d 00 3c 15 20 f4 20 57  |97..2. :..<. . W|
000000b0  65 6c 63 6f 6d 65 20 73  63 72 65 65 6e 0d 00 46  |elcome screen..F|
000000c0  a2 20 eb 36 3a 40 25 3d  26 39 30 35 3a f1 22 20  |. .6:@%=&905:." |
000000d0  42 61 6c 6c 42 6f 74 20  41 72 74 69 66 69 63 69  |BallBot Artifici|
000000e0  61 6c 20 49 6e 74 65 6c  6c 69 67 65 6e 63 65 20  |al Intelligence |
000000f0  4d 6f 64 75 6c 65 22 27  22 53 69 6d 75 6c 61 74  |Module"'"Simulat|
00000100  69 6f 6e 20 54 65 73 74  65 72 20 56 34 2e 30 20  |ion Tester V4.0 |
00000110  52 65 61 6c 20 54 69 6d  65 20 56 65 72 73 69 6f  |Real Time Versio|
00000120  6e 22 27 27 22 50 72 6f  67 72 61 6d 6d 65 64 20  |n"''"Programmed |
00000130  61 6e 64 20 44 65 73 69  67 6e 65 64 20 62 79 20  |and Designed by |
00000140  44 6f 6d 69 6e 69 63 20  46 6f 72 64 22 27 27 89  |Dominic Ford"''.|
00000150  28 31 36 29 3b 22 28 43  29 20 31 39 39 37 22 0d  |(16);"(C) 1997".|
00000160  00 50 55 20 f1 27 27 27  22 31 2e 20 52 65 61 6c  |.PU .'''"1. Real|
00000170  2d 54 69 6d 65 20 53 69  6d 75 6c 61 74 69 6f 6e  |-Time Simulation|
00000180  22 27 27 22 32 2e 20 4c  6f 67 67 65 64 20 43 6f  |"''"2. Logged Co|
00000190  6e 74 69 6e 75 6f 75 73  20 52 75 6e 73 22 27 27  |ntinuous Runs"''|
000001a0  22 33 2e 20 44 6f 20 73  70 65 63 69 66 69 63 20  |"3. Do specific |
000001b0  72 75 6e 22 0d 00 5a 32  20 f5 20 74 79 70 65 24  |run"..Z2 . type$|
000001c0  3d be 3a fd 20 74 79 70  65 24 3d 22 31 22 20 84  |=.:. type$="1" .|
000001d0  20 74 79 70 65 24 3d 22  32 22 20 84 20 74 79 70  | type$="2" . typ|
000001e0  65 24 3d 22 33 22 0d 00  64 06 20 3a 0d 00 6e 16  |e$="3"..d. :..n.|
000001f0  20 f4 20 53 65 74 75 70  20 76 61 72 69 61 62 6c  | . Setup variabl|
00000200  65 73 0d 00 78 24 20 ee  20 85 20 ff 22 43 4c 4f  |es..x$ . . ."CLO|
00000210  53 45 22 3a f6 3a f1 22  20 61 74 20 6c 69 6e 65  |SE":.:." at line|
00000220  20 22 3b 9e 3a e0 0d 00  82 26 20 c8 a1 20 31 2c  | ";.:....& .. 1,|
00000230  22 53 74 72 69 6e 67 4c  69 62 2d 53 6f 66 74 22  |"StringLib-Soft"|
00000240  3a 2a 53 54 45 52 45 4f  20 31 20 30 0d 00 8c 29  |:*STEREO 1 0...)|
00000250  20 c8 a1 20 32 2c 22 53  74 72 69 6e 67 4c 69 62  | .. 2,"StringLib|
00000260  2d 53 6f 66 74 22 3a 2a  53 54 45 52 45 4f 20 32  |-Soft":*STEREO 2|
00000270  20 2d 31 32 37 0d 00 96  28 20 c8 a1 20 33 2c 22  | -127...( .. 3,"|
00000280  53 74 72 69 6e 67 4c 69  62 2d 53 6f 66 74 22 3a  |StringLib-Soft":|
00000290  2a 53 54 45 52 45 4f 20  33 20 31 32 37 0d 00 a0  |*STEREO 3 127...|
000002a0  3a 20 63 75 72 72 65 6e  74 3d 30 3a de 62 61 6c  |: current=0:.bal|
000002b0  6c 28 34 2c 31 29 3a 62  62 78 3d 36 34 30 3a 62  |l(4,1):bbx=640:b|
000002c0  62 79 3d 39 35 30 3a 64  69 72 3d 32 37 30 3a f2  |by=950:dir=270:.|
000002d0  73 65 74 75 70 62 62 0d  00 aa 25 20 eb 31 32 3a  |setupbb...% .12:|
000002e0  e7 20 74 79 70 65 24 3d  22 31 22 20 8c 20 c8 97  |. type$="1" . ..|
000002f0  20 ee 3a f2 64 72 61 77  66 75 6c 6c 0d 00 b4 45  | .:.drawfull...E|
00000300  20 e7 20 74 79 70 65 24  3d 22 32 22 20 8c 20 73  | . type$="2" . s|
00000310  74 61 72 74 3d 91 3a 73  74 61 67 65 3d 30 3a 69  |tart=.:stage=0:i|
00000320  64 6c 65 3d a3 3a e8 22  46 69 6c 65 6e 61 6d 65  |dle=.:."Filename|
00000330  22 3b 66 24 3a ff 22 53  50 4f 4f 4c 20 22 2b 66  |";f$:."SPOOL "+f|
00000340  24 0d 00 be 67 20 e7 20  74 79 70 65 24 3d 22 33  |$...g . type$="3|
00000350  22 20 8c 20 f1 22 45 6e  74 65 72 20 44 61 74 61  |" . ."Enter Data|
00000360  3a 22 27 3a e3 62 3d 30  b8 34 3a f1 22 42 61 6c  |:"':.b=0.4:."Bal|
00000370  6c 20 22 3b 62 2b 31 3b  3a e8 62 61 6c 6c 28 62  |l ";b+1;:.ball(b|
00000380  2c 30 29 2c 62 61 6c 6c  28 62 2c 31 29 3a ed 3a  |,0),ball(b,1):.:|
00000390  74 79 70 65 24 3d 22 31  22 3a c8 97 20 ee 3a f2  |type$="1":.. .:.|
000003a0  64 72 61 77 66 75 6c 6c  0d 00 c8 06 20 3a 0d 00  |drawfull.... :..|
000003b0  d2 16 20 f4 20 53 74 61  72 74 20 6d 61 69 6e 20  |.. . Start main |
000003c0  6c 6f 6f 70 0d 00 dc 0a  20 f5 3a 54 3d 91 0d 00  |loop.... .:T=...|
000003d0  e6 23 20 e7 20 74 79 70  65 24 3d 22 31 22 20 8c  |.# . type$="1" .|
000003e0  20 f2 75 73 65 72 20 8b  20 f2 63 6f 6d 70 6d 6f  | .user . .compmo|
000003f0  6e 0d 00 f0 11 20 e7 20  69 64 6c 65 20 8c 20 fd  |n.... . idle . .|
00000400  20 a3 0d 00 fa 0b 20 f2  73 65 6e 73 65 0d 01 04  | ..... .sense...|
00000410  25 20 6d 6f 76 3d a4 61  69 28 66 72 65 71 61 2c  |% mov=.ai(freqa,|
00000420  66 72 65 71 62 2c 66 72  65 71 63 2c 66 72 65 71  |freqb,freqc,freq|
00000430  64 29 0d 01 0e 16 20 6c  65 66 74 3d 28 6d 6f 76  |d).... left=(mov|
00000440  20 80 20 31 29 3c 3e 30  0d 01 18 17 20 72 69 67  | . 1)<>0.... rig|
00000450  68 74 3d 28 6d 6f 76 20  80 20 32 29 3c 3e 30 0d  |ht=(mov . 2)<>0.|
00000460  01 22 17 20 74 75 72 62  6f 3d 28 6d 6f 76 20 80  |.". turbo=(mov .|
00000470  20 34 29 3c 3e 30 0d 01  2c 14 20 6f 6e 3d 28 6d  | 4)<>0..,. on=(m|
00000480  6f 76 20 80 20 38 29 3c  3e 30 0d 01 36 1a 20 72  |ov . 8)<>0..6. r|
00000490  65 76 65 72 73 65 3d 28  6d 6f 76 20 80 20 31 36  |everse=(mov . 16|
000004a0  29 3c 3e 30 0d 01 40 0c  20 f2 6d 6f 76 65 69 74  |)<>0..@. .moveit|
000004b0  0d 01 4a 1c 20 e7 20 74  79 70 65 24 3d 22 31 22  |..J. . type$="1"|
000004c0  20 8c 20 f1 8a 30 2c 32  29 91 2d 54 0d 01 54 11  | . ..0,2).-T..T.|
000004d0  20 f5 20 fd 20 91 3e 28  54 2b 31 35 29 0d 01 5e  | . . .>(T+15)..^|
000004e0  08 20 fd 20 a3 0d 01 68  06 20 3a 0d 01 72 18 20  |. . ...h. :..r. |
000004f0  f4 20 47 72 61 70 68 69  63 20 69 6e 74 65 72 66  |. Graphic interf|
00000500  61 63 65 0d 01 7c 0f 20  dd f2 64 72 61 77 66 75  |ace..|. ..drawfu|
00000510  6c 6c 0d 01 86 17 20 f4  20 53 65 74 20 75 70 20  |ll.... . Set up |
00000520  63 6f 6e 73 74 61 6e 74  73 0d 01 90 11 20 ea 73  |constants.... .s|
00000530  78 2c 73 79 2c 77 69 64  74 68 0d 01 9a 17 20 73  |x,sy,width.... s|
00000540  78 3d 31 3a 73 79 3d 32  3a 77 69 64 74 68 3d 31  |x=1:sy=2:width=1|
00000550  30 0d 01 a4 14 20 f4 20  53 65 74 75 70 20 43 6f  |0.... . Setup Co|
00000560  6c 6f 75 72 73 0d 01 ae  56 20 fb 30 2c 30 2c 36  |lours...V .0,0,6|
00000570  34 2c 30 3a fb 31 2c 32  35 35 2c 30 2c 30 3a fb  |4,0:.1,255,0,0:.|
00000580  32 2c 32 35 35 2c 32 35  35 2c 32 35 35 3a fb 33  |2,255,255,255:.3|
00000590  2c 32 35 35 2c 30 2c 30  3a fb 34 2c 32 35 35 2c  |,255,0,0:.4,255,|
000005a0  32 35 35 2c 30 3a fb 35  2c 30 2c 30 2c 30 3a fb  |255,0:.5,0,0,0:.|
000005b0  36 2c 32 35 35 2c 32 35  35 2c 30 0d 01 b8 06 20  |6,255,255,0.... |
000005c0  3a 0d 01 c2 1c 20 f4 20  44 72 61 77 20 67 72 65  |:.... . Draw gre|
000005d0  65 6e 20 63 6f 75 72 74  20 61 72 65 61 0d 01 cc  |en court area...|
000005e0  1f 20 db 3a e6 30 2c 30  3a c8 93 20 c8 90 20 30  |. .:.0,0:.. .. 0|
000005f0  2c 30 2c 31 32 37 39 2c  31 30 32 33 0d 01 d6 26  |,0,1279,1023...&|
00000600  20 f4 20 4d 61 72 6b 20  6f 75 74 20 77 68 69 74  | . Mark out whit|
00000610  65 20 6c 69 6e 65 73 20  6f 6e 74 6f 20 63 6f 75  |e lines onto cou|
00000620  72 74 0d 01 e0 ac 20 e6  30 2c 32 3a c8 93 20 c8  |rt.... .0,2:.. .|
00000630  90 20 73 78 2f 28 32 33  2e 37 37 2b 32 2a 73 78  |. sx/(23.77+2*sx|
00000640  29 2a 31 32 38 30 2c 73  79 2f 28 31 30 2e 39 37  |)*1280,sy/(10.97|
00000650  2b 32 2a 73 79 29 2a 31  30 32 34 2c 32 33 2e 37  |+2*sy)*1024,23.7|
00000660  37 2f 28 32 33 2e 37 37  2b 32 2a 73 78 29 2a 31  |7/(23.77+2*sx)*1|
00000670  32 38 30 2c 77 69 64 74  68 3a c8 93 20 c8 90 20  |280,width:.. .. |
00000680  73 78 2f 28 32 33 2e 37  37 2b 32 2a 73 78 29 2a  |sx/(23.77+2*sx)*|
00000690  31 32 38 30 2c 28 31 2e  33 37 2b 73 79 29 2f 28  |1280,(1.37+sy)/(|
000006a0  31 30 2e 39 37 2b 32 2a  73 79 29 2a 31 30 32 34  |10.97+2*sy)*1024|
000006b0  2c 32 33 2e 37 37 2f 28  32 33 2e 37 37 2b 32 2a  |,23.77/(23.77+2*|
000006c0  73 78 29 2a 31 32 38 30  2c 77 69 64 74 68 0d 01  |sx)*1280,width..|
000006d0  ea ae 20 c8 93 20 c8 90  20 73 78 2f 28 32 33 2e  |.. .. .. sx/(23.|
000006e0  37 37 2b 32 2a 73 78 29  2a 31 32 38 30 2c 28 39  |77+2*sx)*1280,(9|
000006f0  2e 36 2b 73 79 29 2f 28  31 30 2e 39 37 2b 32 2a  |.6+sy)/(10.97+2*|
00000700  73 79 29 2a 31 30 32 34  2c 32 33 2e 37 37 2f 28  |sy)*1024,23.77/(|
00000710  32 33 2e 37 37 2b 32 2a  73 78 29 2a 31 32 38 30  |23.77+2*sx)*1280|
00000720  2c 77 69 64 74 68 3a c8  93 20 c8 90 20 73 78 2f  |,width:.. .. sx/|
00000730  28 32 33 2e 37 37 2b 32  2a 73 78 29 2a 31 32 38  |(23.77+2*sx)*128|
00000740  30 2c 28 31 30 2e 39 37  2b 73 79 29 2f 28 31 30  |0,(10.97+sy)/(10|
00000750  2e 39 37 2b 32 2a 73 79  29 2a 31 30 32 34 2c 32  |.97+2*sy)*1024,2|
00000760  33 2e 37 37 2f 28 32 33  2e 37 37 2b 32 2a 73 78  |3.77/(23.77+2*sx|
00000770  29 2a 31 32 38 30 2c 77  69 64 74 68 0d 01 f4 5f  |)*1280,width..._|
00000780  20 c8 93 20 c8 90 20 28  73 78 2b 35 2e 34 37 29  | .. .. (sx+5.47)|
00000790  2f 28 32 33 2e 37 37 2b  32 2a 73 78 29 2a 31 32  |/(23.77+2*sx)*12|
000007a0  38 30 2c 28 73 79 2b 35  2e 34 39 29 2f 28 31 30  |80,(sy+5.49)/(10|
000007b0  2e 39 37 2b 32 2a 73 79  29 2a 31 30 32 34 2c 31  |.97+2*sy)*1024,1|
000007c0  32 2e 38 2f 28 32 33 2e  37 37 2b 32 2a 73 78 29  |2.8/(23.77+2*sx)|
000007d0  2a 31 32 38 30 2c 77 69  64 74 68 0d 01 fe ae 20  |*1280,width.... |
000007e0  c8 93 20 c8 90 20 73 78  2f 28 32 33 2e 37 37 2b  |.. .. sx/(23.77+|
000007f0  32 2a 73 78 29 2a 31 32  38 30 2c 73 79 2f 28 31  |2*sx)*1280,sy/(1|
00000800  30 2e 39 37 2b 32 2a 73  79 29 2a 31 30 32 34 2c  |0.97+2*sy)*1024,|
00000810  77 69 64 74 68 2c 31 30  2e 39 37 2f 28 31 30 2e  |width,10.97/(10.|
00000820  39 37 2b 32 2a 73 79 29  2a 31 30 32 34 3a c8 93  |97+2*sy)*1024:..|
00000830  20 c8 90 20 28 73 78 2b  32 33 2e 37 37 29 2f 28  | .. (sx+23.77)/(|
00000840  32 33 2e 37 37 2b 32 2a  73 78 29 2a 31 32 38 30  |23.77+2*sx)*1280|
00000850  2c 73 79 2f 28 31 30 2e  39 37 2b 32 2a 73 79 29  |,sy/(10.97+2*sy)|
00000860  2a 31 30 32 34 2c 77 69  64 74 68 2c 31 30 2e 39  |*1024,width,10.9|
00000870  37 2f 28 31 30 2e 39 37  2b 32 2a 73 79 29 2a 31  |7/(10.97+2*sy)*1|
00000880  30 32 34 2b 77 69 64 74  68 0d 02 08 ba 20 c8 93  |024+width.... ..|
00000890  20 c8 90 20 28 73 78 2b  35 2e 34 37 29 2f 28 32  | .. (sx+5.47)/(2|
000008a0  33 2e 37 37 2b 32 2a 73  78 29 2a 31 32 38 30 2c  |3.77+2*sx)*1280,|
000008b0  28 73 79 2b 31 2e 33 37  29 2f 28 31 30 2e 39 37  |(sy+1.37)/(10.97|
000008c0  2b 32 2a 73 79 29 2a 31  30 32 34 2c 77 69 64 74  |+2*sy)*1024,widt|
000008d0  68 2c 38 2e 32 33 2f 28  31 30 2e 39 37 2b 32 2a  |h,8.23/(10.97+2*|
000008e0  73 79 29 2a 31 30 32 34  3a c8 93 20 c8 90 20 28  |sy)*1024:.. .. (|
000008f0  73 78 2b 31 38 2e 33 29  2f 28 32 33 2e 37 37 2b  |sx+18.3)/(23.77+|
00000900  32 2a 73 78 29 2a 31 32  38 30 2c 28 73 79 2b 31  |2*sx)*1280,(sy+1|
00000910  2e 33 37 29 2f 28 31 30  2e 39 37 2b 32 2a 73 79  |.37)/(10.97+2*sy|
00000920  29 2a 31 30 32 34 2c 77  69 64 74 68 2c 38 2e 32  |)*1024,width,8.2|
00000930  33 2f 28 31 30 2e 39 37  2b 32 2a 73 79 29 2a 31  |3/(10.97+2*sy)*1|
00000940  30 32 34 0d 02 12 06 20  3a 0d 02 1c 0f 20 f4 20  |024.... :.... . |
00000950  44 72 61 77 20 6e 65 74  0d 02 26 89 20 e6 30 2c  |Draw net..&. .0,|
00000960  35 3a e3 6c 3d 31 30 30  b8 39 32 34 88 31 30 3a  |5:.l=100.924.10:|
00000970  ec 20 36 34 30 2c 6c 3a  df 20 36 38 30 2c 6c 2b  |. 640,l:. 680,l+|
00000980  35 30 3a ed 3a e3 6c 3d  30 b8 34 30 88 31 30 3a  |50:.:.l=0.40.10:|
00000990  ec 20 36 34 30 2b 6c 2c  31 30 30 2b 6c 3a df 36  |. 640+l,100+l:.6|
000009a0  34 30 2b 6c 2c 39 32 34  2b 6c 3a ed 3a e3 6c 3d  |40+l,924+l:.:.l=|
000009b0  30 b8 35 3a ec 36 33 37  2b 6c 2c 31 30 30 3a df  |0.5:.637+l,100:.|
000009c0  36 37 37 2b 6c 2c 31 35  30 3a ec 36 33 37 2b 6c  |677+l,150:.637+l|
000009d0  2c 39 32 34 3a df 36 37  37 2b 6c 2c 39 37 34 3a  |,924:.677+l,974:|
000009e0  ed 0d 02 30 1c 20 e6 30  2c 32 3a ec 20 36 38 32  |...0. .0,2:. 682|
000009f0  2c 31 34 32 3a df 36 38  32 2c 39 36 36 0d 02 3a  |,142:.682,966..:|
00000a00  0e 20 f2 64 72 61 77 6d  69 6e 69 0d 02 44 06 20  |. .drawmini..D. |
00000a10  e1 0d 02 4e 06 20 3a 0d  02 58 1d 20 f4 20 44 72  |...N. :..X. . Dr|
00000a20  61 77 20 62 61 6c 6c 62  6f 74 20 61 6e 64 20 62  |aw ballbot and b|
00000a30  61 6c 6c 73 0d 02 62 0f  20 dd f2 64 72 61 77 6d  |alls..b. ..drawm|
00000a40  69 6e 69 0d 02 6c 14 20  e7 20 74 79 70 65 24 3d  |ini..l. . type$=|
00000a50  22 32 22 20 8c 20 e1 0d  02 76 10 20 e6 33 2c 34  |"2" . ...v. .3,4|
00000a60  3a e3 62 3d 30 b8 34 0d  02 80 42 20 e7 20 62 61  |:.b=0.4...B . ba|
00000a70  6c 6c 28 62 2c 30 29 3c  3e 30 20 84 20 62 61 6c  |ll(b,0)<>0 . bal|
00000a80  6c 28 62 2c 31 29 3c 3e  30 20 8c 20 c8 93 20 c8  |l(b,1)<>0 . .. .|
00000a90  90 20 62 61 6c 6c 28 62  2c 30 29 2c 62 61 6c 6c  |. ball(b,0),ball|
00000aa0  28 62 2c 31 29 2c 35 2c  35 0d 02 8a 06 20 ed 0d  |(b,1),5,5.... ..|
00000ab0  02 94 1b 20 e6 33 2c 33  3a c8 93 20 c8 90 20 62  |... .3,3:.. .. b|
00000ac0  62 78 2c 62 62 79 2c 35  2c 35 0d 02 9e 06 20 e1  |bx,bby,5,5.... .|
00000ad0  0d 02 a8 06 20 3a 0d 02  b2 2a 20 f4 20 55 73 65  |.... :...* . Use|
00000ae0  72 20 69 6e 74 65 72 66  61 63 65 20 28 70 75 74  |r interface (put|
00000af0  74 69 6e 67 20 62 61 6c  6c 73 20 64 6f 77 6e 29  |ting balls down)|
00000b00  0d 02 bc 0b 20 dd f2 75  73 65 72 0d 02 c6 0d 20  |.... ..user.... |
00000b10  c8 97 20 78 2c 79 2c 63  0d 02 d0 0e 20 e7 20 63  |.. x,y,c.... . c|
00000b20  3d 30 20 8c 20 e1 0d 02  da 61 20 e7 20 28 63 20  |=0 . ....a . (c |
00000b30  80 20 34 29 3c 3e 30 20  8c 20 f2 64 72 61 77 6d  |. 4)<>0 . .drawm|
00000b40  69 6e 69 3a 62 61 6c 6c  28 63 75 72 72 65 6e 74  |ini:ball(current|
00000b50  2c 30 29 3d 78 3a 62 61  6c 6c 28 63 75 72 72 65  |,0)=x:ball(curre|
00000b60  6e 74 2c 31 29 3d 79 3a  63 75 72 72 65 6e 74 3d  |nt,1)=y:current=|
00000b70  28 63 75 72 72 65 6e 74  2b 31 29 83 35 3a f2 64  |(current+1).5:.d|
00000b80  72 61 77 6d 69 6e 69 0d  02 e4 2a 20 e7 20 28 63  |rawmini...* . (c|
00000b90  20 80 20 32 29 3c 3e 30  20 8c 20 69 64 6c 65 3d  | . 2)<>0 . idle=|
00000ba0  a3 3a 73 74 61 67 65 3d  30 3a 73 74 61 72 74 3d  |.:stage=0:start=|
00000bb0  91 0d 02 ee 06 20 f5 0d  02 f8 0d 20 c8 97 20 78  |..... ..... .. x|
00000bc0  2c 79 2c 63 0d 03 02 0a  20 fd 20 63 3d 30 0d 03  |,y,c.... . c=0..|
00000bd0  0c 06 20 e1 0d 03 16 06  20 3a 0d 03 20 27 20 f4  |.. ..... :.. ' .|
00000be0  20 43 61 6c 63 75 6c 61  74 65 20 62 61 6c 6c 62  | Calculate ballb|
00000bf0  6f 74 27 73 20 6e 65 77  20 70 6f 73 69 74 69 6f  |ot's new positio|
00000c00  6e 0d 03 2a 0d 20 dd f2  6d 6f 76 65 69 74 0d 03  |n..*. ..moveit..|
00000c10  34 0c 20 ea 20 73 70 65  65 64 0d 03 3e 0f 20 e7  |4. . speed..>. .|
00000c20  20 ac 20 6f 6e 20 8c 20  e1 0d 03 48 76 20 e7 20  | . on . ...Hv . |
00000c30  28 28 ac 20 72 65 76 65  72 73 65 29 20 80 20 6c  |((. reverse) . l|
00000c40  65 66 74 20 80 20 28 ac  20 72 69 67 68 74 29 29  |eft . (. right))|
00000c50  20 84 20 28 72 65 76 65  72 73 65 20 80 20 72 69  | . (reverse . ri|
00000c60  67 68 74 20 80 20 28 ac  20 6c 65 66 74 29 29 20  |ght . (. left)) |
00000c70  8c 20 64 69 72 3d 64 69  72 2d 32 2e 35 2a 28 31  |. dir=dir-2.5*(1|
00000c80  2d 33 2a 74 75 72 62 6f  29 3a 73 70 65 65 64 3d  |-3*turbo):speed=|
00000c90  30 2e 31 2b 30 2e 32 2a  72 65 76 65 72 73 65 0d  |0.1+0.2*reverse.|
00000ca0  03 52 76 20 e7 20 28 28  ac 20 72 65 76 65 72 73  |.Rv . ((. revers|
00000cb0  65 29 20 80 20 72 69 67  68 74 20 80 20 28 ac 20  |e) . right . (. |
00000cc0  6c 65 66 74 29 29 20 84  20 28 72 65 76 65 72 73  |left)) . (revers|
00000cd0  65 20 80 20 6c 65 66 74  20 80 20 28 ac 20 72 69  |e . left . (. ri|
00000ce0  67 68 74 29 29 20 8c 20  64 69 72 3d 64 69 72 2b  |ght)) . dir=dir+|
00000cf0  32 2e 35 2a 28 31 2d 33  2a 74 75 72 62 6f 29 3a  |2.5*(1-3*turbo):|
00000d00  73 70 65 65 64 3d 30 2e  31 2b 30 2e 32 2a 72 65  |speed=0.1+0.2*re|
00000d10  76 65 72 73 65 0d 03 5c  27 20 e7 20 6c 65 66 74  |verse..\' . left|
00000d20  20 80 20 72 69 67 68 74  20 8c 20 73 70 65 65 64  | . right . speed|
00000d30  3d 31 2b 32 2a 72 65 76  65 72 73 65 0d 03 66 06  |=1+2*reverse..f.|
00000d40  20 3a 0d 03 70 29 20 f4  20 47 65 74 20 64 69 72  | :..p) . Get dir|
00000d50  65 63 74 69 6f 6e 20 69  6e 20 72 61 6e 67 65 20  |ection in range |
00000d60  30 3c 74 68 65 74 61 3c  33 36 30 0d 03 7a 1c 20  |0<theta<360..z. |
00000d70  f5 20 e7 20 64 69 72 3c  30 20 8c 20 64 69 72 3d  |. . dir<0 . dir=|
00000d80  64 69 72 2b 33 36 30 0d  03 84 1d 20 e7 20 64 69  |dir+360.... . di|
00000d90  72 3e 3d 33 36 30 20 8c  20 64 69 72 3d 64 69 72  |r>=360 . dir=dir|
00000da0  2d 33 36 30 0d 03 8e 17  20 fd 20 64 69 72 3e 3d  |-360.... . dir>=|
00000db0  30 20 80 20 64 69 72 3c  33 36 30 0d 03 98 06 20  |0 . dir<360.... |
00000dc0  3a 0d 03 a2 3d 20 f2 64  72 61 77 6d 69 6e 69 3a  |:...= .drawmini:|
00000dd0  62 62 78 3d 62 62 78 2b  31 35 2a b5 28 af 2a 64  |bbx=bbx+15*.(.*d|
00000de0  69 72 2f 31 38 30 29 2a  73 70 65 65 64 2a 28 2e  |ir/180)*speed*(.|
00000df0  37 35 2a 2d 74 75 72 62  6f 2b 2e 32 35 29 0d 03  |75*-turbo+.25)..|
00000e00  ac 33 20 62 62 79 3d 62  62 79 2b 32 30 2a 9b 28  |.3 bby=bby+20*.(|
00000e10  af 2a 64 69 72 2f 31 38  30 29 2a 73 70 65 65 64  |.*dir/180)*speed|
00000e20  2a 28 2e 37 35 2a 2d 74  75 72 62 6f 2b 2e 32 35  |*(.75*-turbo+.25|
00000e30  29 0d 03 b6 51 20 e3 62  61 6c 6c 3d 30 b8 34 3a  |)...Q .ball=0.4:|
00000e40  e7 20 94 28 62 62 78 2d  62 61 6c 6c 28 62 61 6c  |. .(bbx-ball(bal|
00000e50  6c 2c 30 29 29 3c 31 30  20 80 20 94 28 62 62 79  |l,0))<10 . .(bby|
00000e60  2d 62 61 6c 6c 28 62 61  6c 6c 2c 31 29 29 3c 31  |-ball(ball,1))<1|
00000e70  30 20 8c 20 62 61 6c 6c  28 62 61 6c 6c 2c 30 29  |0 . ball(ball,0)|
00000e80  3d 30 0d 03 c0 10 20 ed  3a f2 64 72 61 77 6d 69  |=0.... .:.drawmi|
00000e90  6e 69 0d 03 ca 06 20 e1  0d 03 d4 06 20 3a 0d 03  |ni.... ..... :..|
00000ea0  de 3b 20 f4 20 43 61 6c  63 75 6c 61 74 65 20 62  |.; . Calculate b|
00000eb0  61 6c 6c 62 6f 74 27 73  20 62 61 63 6b 67 72 6f  |allbot's backgro|
00000ec0  75 6e 64 20 65 63 68 6f  20 72 65 61 64 69 6e 67  |und echo reading|
00000ed0  20 28 2d 62 61 6c 6c 73  29 0d 03 e8 19 20 dd a4  | (-balls).... ..|
00000ee0  62 61 63 6b 28 66 72 65  71 2c 6d 69 6e 2c 6d 61  |back(freq,min,ma|
00000ef0  78 29 0d 03 f2 2c 20 f4  20 47 65 74 20 61 6e 67  |x)..., . Get ang|
00000f00  75 6c 61 72 20 72 61 6e  67 65 20 69 6e 20 66 6f  |ular range in fo|
00000f10  72 6d 20 30 3c 74 68 65  74 61 3c 33 36 30 0d 03  |rm 0<theta<360..|
00000f20  fc 2c 20 f4 20 53 65 74  20 75 70 20 69 6e 69 74  |., . Set up init|
00000f30  69 61 6c 20 6f 75 74 73  69 64 65 20 72 61 6e 67  |ial outside rang|
00000f40  65 20 73 65 74 74 69 6e  67 73 0d 04 06 42 20 68  |e settings...B h|
00000f50  69 74 3d 30 3a 64 69 73  74 3d 39 39 39 39 3a 64  |it=0:dist=9999:d|
00000f60  69 73 74 61 3d 39 39 39  39 3a 68 69 74 61 3d 30  |ista=9999:hita=0|
00000f70  3a f4 20 4c 4f 43 41 4c  20 68 69 74 2c 64 69 73  |:. LOCAL hit,dis|
00000f80  74 2c 68 69 74 61 2c 64  69 73 74 61 0d 04 10 38  |t,hita,dista...8|
00000f90  20 f4 20 49 66 20 73 74  72 61 69 67 68 74 20 61  | . If straight a|
00000fa0  74 20 6e 65 74 20 69 73  20 69 6e 20 72 61 6e 67  |t net is in rang|
00000fb0  65 2c 20 77 69 6c 6c 20  62 65 20 73 68 6f 72 74  |e, will be short|
00000fc0  65 73 74 2e 0d 04 1a 79  20 e7 28 28 62 62 78 3c  |est....y .((bbx<|
00000fd0  36 34 30 80 6d 69 6e 3c  3d 39 30 80 6d 61 78 3e  |640.min<=90.max>|
00000fe0  3d 39 30 29 84 28 62 62  78 3e 36 34 30 80 6d 69  |=90).(bbx>640.mi|
00000ff0  6e 3c 3d 32 37 30 80 6d  61 78 3e 3d 32 37 30 29  |n<=270.max>=270)|
00001000  29 20 80 20 28 62 62 79  3e 31 30 30 20 80 20 62  |) . (bby>100 . b|
00001010  62 79 3c 39 32 33 29 20  8c 20 68 69 74 3d 62 62  |by<923) . hit=bb|
00001020  79 3a 64 69 73 74 3d 94  28 62 62 78 2d 36 34 30  |y:dist=.(bbx-640|
00001030  29 3a 6d 69 6e 3d 30 3a  6d 61 78 3d 30 0d 04 24  |):min=0:max=0..$|
00001040  2f 20 f4 20 4f 74 68 65  72 77 69 73 65 20 66 69  |/ . Otherwise fi|
00001050  6e 64 20 73 68 6f 72 74  65 73 74 20 65 78 74 72  |nd shortest extr|
00001060  65 6d 65 20 6f 66 20 72  61 6e 67 65 0d 04 2e 53  |eme of range...S|
00001070  20 e7 20 b5 28 af 2a 6d  69 6e 2f 31 38 30 29 3c  | . .(.*min/180)<|
00001080  3e 30 20 8c 20 64 69 73  74 3d 28 36 34 30 2d 62  |>0 . dist=(640-b|
00001090  62 78 29 2f b5 28 af 2a  6d 69 6e 2f 31 38 30 29  |bx)/.(.*min/180)|
000010a0  3a 68 69 74 3d 62 62 79  2b 28 36 34 30 2d 62 62  |:hit=bby+(640-bb|
000010b0  78 29 2f b7 28 af 2a 6d  69 6e 2f 31 38 30 29 0d  |x)/.(.*min/180).|
000010c0  04 38 55 20 e7 20 b5 28  af 2a 6d 61 78 2f 31 38  |.8U . .(.*max/18|
000010d0  30 29 3c 3e 30 20 8c 20  64 69 73 74 61 3d 28 36  |0)<>0 . dista=(6|
000010e0  34 30 2d 62 62 78 29 2f  b5 28 af 2a 6d 61 78 2f  |40-bbx)/.(.*max/|
000010f0  31 38 30 29 3a 68 69 74  61 3d 62 62 79 2b 28 36  |180):hita=bby+(6|
00001100  34 30 2d 62 62 78 29 2f  b7 28 af 2a 6d 61 78 2f  |40-bbx)/.(.*max/|
00001110  31 38 30 29 0d 04 42 2c  20 f4 20 4a 75 73 74 20  |180)..B, . Just |
00001120  63 68 65 63 6b 20 69 66  20 70 6f 73 74 20 69 6e  |check if post in|
00001130  20 6d 69 64 64 6c 65 20  6f 66 20 72 61 6e 67 65  | middle of range|
00001140  0d 04 4c 64 20 e7 20 62  62 78 3c 36 34 30 20 80  |..Ld . bbx<640 .|
00001150  20 68 69 74 3e 31 30 30  20 80 20 28 68 69 74 61  | hit>100 . (hita|
00001160  3c 31 30 30 20 84 20 64  69 73 74 61 3c 30 29 20  |<100 . dista<0) |
00001170  80 20 64 69 73 74 3e 30  20 8c 20 68 69 74 61 3d  |. dist>0 . hita=|
00001180  31 30 30 3a 64 69 73 74  61 3d b6 28 28 62 62 78  |100:dista=.((bbx|
00001190  2d 36 34 30 29 5e 32 2b  28 62 62 79 2d 31 30 30  |-640)^2+(bby-100|
000011a0  29 5e 32 29 0d 04 56 62  20 e7 20 62 62 78 3c 36  |)^2)..Vb . bbx<6|
000011b0  34 30 20 80 20 68 69 74  61 3c 39 32 33 20 80 20  |40 . hita<923 . |
000011c0  28 68 69 74 3e 39 32 33  20 84 20 64 69 73 74 3c  |(hit>923 . dist<|
000011d0  30 29 20 80 20 64 69 73  74 61 3e 30 20 8c 20 68  |0) . dista>0 . h|
000011e0  69 74 3d 39 32 33 3a 64  69 73 74 3d b6 28 28 62  |it=923:dist=.((b|
000011f0  62 78 2d 36 34 30 29 5e  32 2b 28 62 62 79 2d 39  |bx-640)^2+(bby-9|
00001200  32 33 29 5e 32 29 0d 04  60 62 20 e7 20 62 62 78  |23)^2)..`b . bbx|
00001210  3e 36 34 30 20 80 20 68  69 74 61 3e 31 30 30 20  |>640 . hita>100 |
00001220  80 20 28 68 69 74 3c 31  30 30 20 84 20 64 69 73  |. (hit<100 . dis|
00001230  74 3c 30 29 20 80 20 64  69 73 74 61 3e 30 20 8c  |t<0) . dista>0 .|
00001240  20 68 69 74 3d 31 30 30  3a 64 69 73 74 3d b6 28  | hit=100:dist=.(|
00001250  28 62 62 78 2d 36 34 30  29 5e 32 2b 28 62 62 79  |(bbx-640)^2+(bby|
00001260  2d 31 30 30 29 5e 32 29  0d 04 6a 64 20 e7 20 62  |-100)^2)..jd . b|
00001270  62 78 3e 36 34 30 20 80  20 68 69 74 3c 39 32 33  |bx>640 . hit<923|
00001280  20 80 20 28 68 69 74 61  3e 39 32 33 20 84 20 64  | . (hita>923 . d|
00001290  69 73 74 61 3c 30 29 20  80 20 64 69 73 74 3e 30  |ista<0) . dist>0|
000012a0  20 8c 20 68 69 74 61 3d  39 32 33 3a 64 69 73 74  | . hita=923:dist|
000012b0  61 3d b6 28 28 62 62 78  2d 36 34 30 29 5e 32 2b  |a=.((bbx-640)^2+|
000012c0  28 62 62 79 2d 39 32 33  29 5e 32 29 0d 04 74 1d  |(bby-923)^2)..t.|
000012d0  20 f4 20 50 69 63 6b 20  62 65 73 74 20 74 6f 20  | . Pick best to |
000012e0  73 65 6e 64 20 6f 66 66  21 0d 04 7e 48 20 e7 20  |send off!..~H . |
000012f0  64 69 73 74 3c 30 20 84  20 28 64 69 73 74 61 3c  |dist<0 . (dista<|
00001300  64 69 73 74 20 80 20 68  69 74 61 3e 31 30 30 20  |dist . hita>100 |
00001310  80 20 68 69 74 61 3c 39  32 33 29 20 8c 20 64 69  |. hita<923) . di|
00001320  73 74 3d 64 69 73 74 61  3a 68 69 74 3d 68 69 74  |st=dista:hit=hit|
00001330  61 0d 04 88 3b 20 e7 20  68 69 74 3e 39 32 33 20  |a...; . hit>923 |
00001340  84 20 68 69 74 3c 31 30  30 20 84 20 64 69 73 74  |. hit<100 . dist|
00001350  3c 30 20 8c 20 66 74 79  70 65 24 3d 22 55 22 3a  |<0 . ftype$="U":|
00001360  3d 66 72 65 71 2b b3 28  36 29 2d 33 0d 04 92 2b  |=freq+.(6)-3...+|
00001370  20 e7 20 68 69 74 3e 39  30 30 20 84 20 68 69 74  | . hit>900 . hit|
00001380  3c 31 32 33 20 8c 20 66  74 79 70 65 24 3d 22 50  |<123 . ftype$="P|
00001390  22 3a 3d 64 69 73 74 0d  04 9c 0f 20 66 74 79 70  |":=dist.... ftyp|
000013a0  65 24 3d 22 4e 22 0d 04  a6 0a 20 3d 64 69 73 74  |e$="N".... =dist|
000013b0  0d 04 b0 06 20 3a 0d 04  ba 32 20 f4 20 43 61 6c  |.... :...2 . Cal|
000013c0  63 75 6c 61 74 65 20 42  61 6c 6c 62 6f 74 27 73  |culate Ballbot's|
000013d0  20 72 65 61 64 69 6e 67  73 20 28 4d 41 49 4e 20  | readings (MAIN |
000013e0  52 4f 55 54 49 4e 45 29  0d 04 c4 06 20 3a 0d 04  |ROUTINE).... :..|
000013f0  ce 0c 20 dd f2 73 65 6e  73 65 0d 04 d8 2a 20 f4  |.. ..sense...* .|
00001400  20 47 65 74 20 62 61 63  6b 67 72 6f 75 6e 64 20  | Get background |
00001410  72 65 61 64 69 6e 67 73  20 66 72 6f 6d 20 46 4e  |readings from FN|
00001420  62 61 63 6b 0d 04 e2 15  20 66 72 65 71 3d b3 28  |back.... freq=.(|
00001430  32 35 30 29 2b 31 35 30  30 0d 04 ec 2f 20 66 72  |250)+1500.../ fr|
00001440  65 71 61 3d a4 62 61 63  6b 28 66 72 65 71 2c 64  |eqa=.back(freq,d|
00001450  69 72 2d 31 35 2c 64 69  72 2b 31 35 29 3a 66 61  |ir-15,dir+15):fa|
00001460  24 3d 66 74 79 70 65 24  0d 04 f6 2f 20 66 72 65  |$=ftype$.../ fre|
00001470  71 62 3d a4 62 61 63 6b  28 66 72 65 71 2c 64 69  |qb=.back(freq,di|
00001480  72 2d 34 35 2c 64 69 72  2d 31 35 29 3a 66 62 24  |r-45,dir-15):fb$|
00001490  3d 66 74 79 70 65 24 0d  05 00 2f 20 66 72 65 71  |=ftype$.../ freq|
000014a0  63 3d a4 62 61 63 6b 28  66 72 65 71 2c 64 69 72  |c=.back(freq,dir|
000014b0  2b 31 35 2c 64 69 72 2b  34 35 29 3a 66 63 24 3d  |+15,dir+45):fc$=|
000014c0  66 74 79 70 65 24 0d 05  0a 2f 20 66 72 65 71 64  |ftype$.../ freqd|
000014d0  3d a4 62 61 63 6b 28 66  72 65 71 2c 64 69 72 2d  |=.back(freq,dir-|
000014e0  37 35 2c 64 69 72 2d 34  35 29 3a 66 64 24 3d 66  |75,dir-45):fd$=f|
000014f0  74 79 70 65 24 0d 05 14  06 20 3a 0d 05 1e 44 20  |type$.... :...D |
00001500  f4 20 41 64 64 20 61 6e  79 20 72 65 6c 65 76 61  |. Add any releva|
00001510  6e 74 20 62 61 6c 6c 73  20 74 6f 20 72 65 61 64  |nt balls to read|
00001520  69 6e 67 73 20 28 75 73  69 6e 67 20 68 61 69 72  |ings (using hair|
00001530  79 20 74 72 69 67 6f 6e  6f 6d 65 74 72 79 29 0d  |y trigonometry).|
00001540  05 28 06 20 3a 0d 05 32  0e 20 e3 62 61 6c 6c 3d  |.(. :..2. .ball=|
00001550  30 b8 34 0d 05 3c 34 20  64 25 3d b6 28 28 62 61  |0.4..<4 d%=.((ba|
00001560  6c 6c 28 62 61 6c 6c 2c  30 29 2d 62 62 78 29 5e  |ll(ball,0)-bbx)^|
00001570  32 2b 28 62 61 6c 6c 28  62 61 6c 6c 2c 31 29 2d  |2+(ball(ball,1)-|
00001580  62 62 79 29 5e 32 29 0d  05 46 1f 20 e7 20 62 61  |bby)^2)..F. . ba|
00001590  6c 6c 28 62 61 6c 6c 2c  30 29 3d 30 20 8c 20 64  |ll(ball,0)=0 . d|
000015a0  25 3d 39 39 39 39 0d 05  50 34 20 61 3d a4 61 6e  |%=9999..P4 a=.an|
000015b0  67 6c 65 28 62 61 6c 6c  28 62 61 6c 6c 2c 30 29  |gle(ball(ball,0)|
000015c0  2c 62 61 6c 6c 28 62 61  6c 6c 2c 31 29 2c 62 62  |,ball(ball,1),bb|
000015d0  78 2c 62 62 79 29 2d 64  69 72 0d 05 5a 15 20 e7  |x,bby)-dir..Z. .|
000015e0  61 3e 31 38 30 20 8c 20  61 3d 61 2d 33 36 30 0d  |a>180 . a=a-360.|
000015f0  05 64 17 20 e7 61 3c 3d  2d 31 37 39 20 8c 20 61  |.d. .a<=-179 . a|
00001600  3d 61 2b 33 36 30 0d 05  6e 2c 20 e7 20 94 28 61  |=a+360..n, . .(a|
00001610  29 3c 31 35 20 80 20 66  72 65 71 61 3e 64 25 20  |)<15 . freqa>d% |
00001620  8c 20 66 72 65 71 61 3d  64 25 3a 66 61 24 3d 22  |. freqa=d%:fa$="|
00001630  42 22 0d 05 78 33 20 e7  20 61 3e 2d 34 36 20 80  |B"..x3 . a>-46 .|
00001640  20 61 3c 3d 2d 31 35 20  80 20 66 72 65 71 62 3e  | a<=-15 . freqb>|
00001650  64 25 20 8c 20 66 72 65  71 62 3d 64 25 3a 66 62  |d% . freqb=d%:fb|
00001660  24 3d 22 42 22 0d 05 82  31 20 e7 20 61 3e 3d 31  |$="B"...1 . a>=1|
00001670  35 20 80 20 61 3c 34 36  20 80 20 66 72 65 71 63  |5 . a<46 . freqc|
00001680  3e 64 25 20 8c 20 66 72  65 71 63 3d 64 25 3a 66  |>d% . freqc=d%:f|
00001690  63 24 3d 22 42 22 0d 05  8c 33 20 e7 20 61 3e 2d  |c$="B"...3 . a>-|
000016a0  37 35 20 80 20 61 3c 3d  2d 34 36 20 80 20 66 72  |75 . a<=-46 . fr|
000016b0  65 71 64 3e 64 25 20 8c  20 66 72 65 71 64 3d 64  |eqd>d% . freqd=d|
000016c0  25 3a 66 64 24 3d 22 42  22 0d 05 96 06 20 ed 0d  |%:fd$="B".... ..|
000016d0  05 a0 06 20 3a 0d 05 aa  1b 20 f4 20 55 70 64 61  |... :.... . Upda|
000016e0  74 65 20 75 73 65 72 20  64 69 73 70 6c 61 79 73  |te user displays|
000016f0  0d 05 b4 06 20 3a 0d 05  be 14 20 e7 20 74 79 70  |.... :.... . typ|
00001700  65 24 3d 22 32 22 20 8c  20 e1 0d 05 c8 3a 20 f1  |e$="2" . ....: .|
00001710  8a 30 2c 30 29 a8 28 28  91 2d 73 74 61 72 74 29  |.0,0).((.-start)|
00001720  2f 36 30 30 30 29 3b 22  3a 22 3b 28 a8 28 28 91  |/6000);":";(.((.|
00001730  2d 73 74 61 72 74 29 2f  31 30 30 29 83 36 30 29  |-start)/100).60)|
00001740  3b 22 20 22 0d 05 d2 4b  20 f1 8a 30 2c 33 31 29  |;" "...K ..0,31)|
00001750  66 64 24 2c 66 62 24 2c  66 61 24 2c 66 63 24 2c  |fd$,fb$,fa$,fc$,|
00001760  73 74 61 67 65 2c a8 28  73 65 61 72 63 68 69 6e  |stage,.(searchin|
00001770  67 29 2c 6c 65 66 74 2c  72 69 67 68 74 2c 22 20  |g),left,right," |
00001780  22 2c 64 69 72 2c 22 20  22 2c 6e 65 61 72 3b 0d  |",dir," ",near;.|
00001790  05 dc 37 20 d4 20 31 2c  2d 31 2c 66 72 65 71 61  |..7 . 1,-1,freqa|
000017a0  2f 34 2c 35 3a d4 20 32  2c 2d 31 2c 66 72 65 71  |/4,5:. 2,-1,freq|
000017b0  62 2f 34 2c 35 3a d4 20  33 2c 2d 31 2c 66 72 65  |b/4,5:. 3,-1,fre|
000017c0  71 63 2f 34 2c 35 0d 05  e6 06 20 e1 0d 05 f0 05  |qc/4,5.... .....|
000017d0  3a 0d 05 fa 24 20 f4 20  43 61 6c 63 75 6c 61 74  |:...$ . Calculat|
000017e0  65 20 62 65 61 72 69 6e  67 20 6f 66 20 42 20 66  |e bearing of B f|
000017f0  72 6f 6d 20 41 0d 06 04  19 20 dd a4 61 6e 67 6c  |rom A.... ..angl|
00001800  65 28 78 31 2c 79 31 2c  78 32 2c 79 32 29 0d 06  |e(x1,y1,x2,y2)..|
00001810  0e 34 20 e7 20 79 32 3d  79 31 20 8c 20 61 6e 67  |.4 . y2=y1 . ang|
00001820  3d 39 30 20 8b 20 61 6e  67 3d 31 38 30 2a 99 28  |=90 . ang=180*.(|
00001830  28 78 32 2d 78 31 29 2f  28 79 32 2d 79 31 29 29  |(x2-x1)/(y2-y1))|
00001840  2f af 0d 06 18 1c 20 e7  20 28 79 32 3e 79 31 29  |/..... . (y2>y1)|
00001850  20 8c 20 61 6e 67 3d 61  6e 67 2b 31 38 30 0d 06  | . ang=ang+180..|
00001860  22 1a 20 e7 20 61 6e 67  3c 30 20 8c 20 61 6e 67  |". . ang<0 . ang|
00001870  3d 61 6e 67 2b 33 36 30  0d 06 2c 0f 20 3d 61 6e  |=ang+360..,. =an|
00001880  67 20 83 20 33 36 30 0d  06 36 06 20 3a 0d 06 40  |g . 360..6. :..@|
00001890  2d 20 f4 20 43 6f 6d 70  75 74 65 72 20 4d 6f 6e  |- . Computer Mon|
000018a0  69 74 6f 72 20 6f 66 20  42 61 6c 6c 42 6f 74 27  |itor of BallBot'|
000018b0  73 20 70 72 6f 67 72 65  73 73 0d 06 4a 0e 20 dd  |s progress..J. .|
000018c0  f2 63 6f 6d 70 6d 6f 6e  0d 06 54 72 20 e7 20 69  |.compmon..Tr . i|
000018d0  64 6c 65 20 80 20 28 62  61 6c 6c 28 30 2c 30 29  |dle . (ball(0,0)|
000018e0  3c 3e 30 20 84 20 62 61  6c 6c 28 31 2c 30 29 3c  |<>0 . ball(1,0)<|
000018f0  3e 30 20 84 20 62 61 6c  6c 28 32 2c 30 29 3c 3e  |>0 . ball(2,0)<>|
00001900  30 20 84 20 62 61 6c 6c  28 33 2c 30 29 3c 3e 30  |0 . ball(3,0)<>0|
00001910  20 84 20 62 61 6c 6c 28  34 2c 30 29 3c 3e 30 29  | . ball(4,0)<>0)|
00001920  20 8c 20 73 74 24 3d 22  46 61 69 6c 22 20 8b 20  | . st$="Fail" . |
00001930  73 74 24 3d 22 50 61 73  73 22 0d 06 5e 3e 20 e7  |st$="Pass"..^> .|
00001940  20 69 64 6c 65 20 8c 20  f1 73 74 24 2c a8 28 28  | idle . .st$,.((|
00001950  91 2d 73 74 61 72 74 29  2f 36 30 30 30 29 3b 22  |.-start)/6000);"|
00001960  3a 22 3b 28 a8 28 28 91  2d 73 74 61 72 74 29 2f  |:";(.((.-start)/|
00001970  31 30 30 29 83 36 30 29  0d 06 68 2c 20 e7 20 91  |100).60)..h, . .|
00001980  3e 73 74 61 72 74 2b 33  36 30 30 30 20 8c 20 69  |>start+36000 . i|
00001990  64 6c 65 3d b9 3a f1 22  54 69 6d 65 22 2c 22 2a  |dle=.:."Time","*|
000019a0  2a 2a 2a 22 0d 06 72 3c  20 e7 62 62 78 3e 36 33  |***"..r< .bbx>63|
000019b0  35 80 62 62 78 3c 36 34  35 80 62 62 79 3e 31 30  |5.bbx<645.bby>10|
000019c0  35 80 62 62 79 3c 39 32  30 8c 69 64 6c 65 3d b9  |5.bby<920.idle=.|
000019d0  3a f1 22 43 72 61 73 68  22 2c 22 2a 2a 2a 2a 22  |:."Crash","****"|
000019e0  0d 06 7c 99 20 e7 20 69  64 6c 65 20 8c 20 62 62  |..|. . idle . bb|
000019f0  78 3d 36 34 30 3a 62 62  79 3d 39 35 30 3a 64 69  |x=640:bby=950:di|
00001a00  72 3d 32 37 30 3a 73 74  61 67 65 3d 30 3a f2 73  |r=270:stage=0:.s|
00001a10  65 74 75 70 62 62 3a 73  74 61 72 74 3d 91 3a e3  |etupbb:start=.:.|
00001a20  62 3d 30 b8 34 3a 62 61  6c 6c 28 62 2c 30 29 3d  |b=0.4:ball(b,0)=|
00001a30  b3 28 31 31 38 30 29 3a  62 61 6c 6c 28 62 2c 31  |.(1180):ball(b,1|
00001a40  29 3d b3 28 31 30 32 34  29 3a 62 61 6c 6c 28 62  |)=.(1024):ball(b|
00001a50  2c 30 29 3d 62 61 6c 6c  28 62 2c 30 29 2d 31 30  |,0)=ball(b,0)-10|
00001a60  30 2a 28 28 62 61 6c 6c  28 62 2c 30 29 20 81 20  |0*((ball(b,0) . |
00001a70  31 30 30 29 3d 36 29 3a  ed 0d 06 86 af 20 e7 20  |100)=6):..... . |
00001a80  69 64 6c 65 20 8c 20 f1  22 5b 22 3b 62 61 6c 6c  |idle . ."[";ball|
00001a90  28 30 2c 30 29 3b 22 2c  22 3b 62 61 6c 6c 28 30  |(0,0);",";ball(0|
00001aa0  2c 31 29 3b 22 5d 20 5b  22 3b 62 61 6c 6c 28 31  |,1);"] [";ball(1|
00001ab0  2c 30 29 3b 22 2c 22 3b  62 61 6c 6c 28 31 2c 31  |,0);",";ball(1,1|
00001ac0  29 3b 22 5d 20 5b 22 3b  62 61 6c 6c 28 32 2c 30  |);"] [";ball(2,0|
00001ad0  29 3b 22 2c 22 3b 62 61  6c 6c 28 32 2c 31 29 3b  |);",";ball(2,1);|
00001ae0  22 5d 20 5b 22 3b 62 61  6c 6c 28 33 2c 30 29 3b  |"] [";ball(3,0);|
00001af0  22 2c 22 3b 62 61 6c 6c  28 33 2c 31 29 3b 22 5d  |",";ball(3,1);"]|
00001b00  20 5b 22 3b 62 61 6c 6c  28 34 2c 30 29 3b 22 2c  | [";ball(4,0);",|
00001b10  22 3b 62 61 6c 6c 28 34  2c 31 29 3b 22 5d 22 2c  |";ball(4,1);"]",|
00001b20  3b 3a 69 64 6c 65 3d a3  0d 06 90 06 20 e1 0d 06  |;:idle=..... ...|
00001b30  9a 06 20 3a 0d 06 a4 2a  20 f4 20 42 41 4c 4c 42  |.. :...* . BALLB|
00001b40  4f 54 20 52 4f 42 4f 54  49 43 20 49 4e 54 45 4c  |OT ROBOTIC INTEL|
00001b50  4c 49 47 45 4e 43 45 20  4d 4f 44 55 4c 45 0d 06  |LIGENCE MODULE..|
00001b60  ae 06 20 3a 0d 06 b8 22  20 dd a4 61 69 28 66 72  |.. :..." ..ai(fr|
00001b70  65 71 61 2c 66 72 65 71  62 2c 66 72 65 71 63 2c  |eqa,freqb,freqc,|
00001b80  66 72 65 71 64 29 0d 06  c2 39 20 f4 20 41 72 74  |freqd)...9 . Art|
00001b90  69 66 69 63 69 61 6c 20  69 6e 74 65 6c 6c 69 67  |ificial intellig|
00001ba0  65 6e 63 65 20 72 6f 75  74 69 6e 65 73 20 28 69  |ence routines (i|
00001bb0  65 2e 20 57 68 61 74 20  4e 65 78 74 3f 3f 29 0d  |e. What Next??).|
00001bc0  06 cc 1e 20 ea 6c 65 66  74 2c 72 69 67 68 74 2c  |... .left,right,|
00001bd0  74 75 72 62 6f 2c 72 65  76 65 72 73 65 0d 06 d6  |turbo,reverse...|
00001be0  25 20 6c 65 66 74 3d a3  3a 72 69 67 68 74 3d a3  |% left=.:right=.|
00001bf0  3a 74 75 72 62 6f 3d a3  3a 72 65 76 65 72 73 65  |:turbo=.:reverse|
00001c00  3d a3 0d 06 e0 06 20 3a  0d 06 ea 40 20 f4 20 57  |=..... :...@ . W|
00001c10  68 61 74 20 73 74 61 67  65 20 61 72 65 20 77 65  |hat stage are we|
00001c20  20 69 6e 3f 20 48 75 6e  74 20 66 6f 72 20 62 61  | in? Hunt for ba|
00001c30  6c 6c 73 20 6f 72 20 6d  6f 76 65 20 74 6f 20 6e  |lls or move to n|
00001c40  65 77 20 61 72 65 61 3f  0d 06 f4 27 20 e7 20 6e  |ew area?...' . n|
00001c50  65 61 72 3c 3e 30 20 80  20 73 74 61 67 65 3c 34  |ear<>0 . stage<4|
00001c60  20 8c 20 f2 64 6f 6e 65  61 72 73 74 75 66 66 0d  | . .donearstuff.|
00001c70  06 fe 2b 20 e7 20 6e 65  61 72 3d 30 20 80 20 28  |..+ . near=0 . (|
00001c80  73 74 61 67 65 3d 30 20  84 20 73 74 61 67 65 3d  |stage=0 . stage=|
00001c90  32 29 20 8c 20 f2 68 75  6e 74 0d 07 08 2e 20 e7  |2) . .hunt.... .|
00001ca0  20 6e 65 61 72 3d 30 20  80 20 28 73 74 61 67 65  | near=0 . (stage|
00001cb0  3d 31 20 84 20 73 74 61  67 65 3d 33 29 20 8c 20  |=1 . stage=3) . |
00001cc0  f2 6d 6f 76 65 6f 75 74  0d 07 12 1a 20 e7 20 73  |.moveout.... . s|
00001cd0  74 61 67 65 3d 34 20 8c  20 f2 72 65 6c 65 61 73  |tage=4 . .releas|
00001ce0  65 62 0d 07 1c 06 20 3a  0d 07 26 32 20 f4 20 50  |eb.... :..&2 . P|
00001cf0  72 65 70 61 72 65 20 6f  75 74 70 75 74 20 69 6e  |repare output in|
00001d00  74 6f 20 62 69 6e 61 72  79 20 66 6f 72 20 74 72  |to binary for tr|
00001d10  61 6e 73 6d 69 73 73 69  6f 6e 0d 07 30 20 20 66  |ansmission..0  f|
00001d20  65 65 64 3d 30 3a e7 20  6c 65 66 74 20 8c 20 66  |eed=0:. left . f|
00001d30  65 65 64 3d 66 65 65 64  2b 31 0d 07 3a 1a 20 e7  |eed=feed+1..:. .|
00001d40  20 72 69 67 68 74 20 8c  20 66 65 65 64 3d 66 65  | right . feed=fe|
00001d50  65 64 2b 32 0d 07 44 1a  20 e7 20 74 75 72 62 6f  |ed+2..D. . turbo|
00001d60  20 8c 20 66 65 65 64 3d  66 65 65 64 2b 34 0d 07  | . feed=feed+4..|
00001d70  4e 1b 20 e7 20 ac 20 69  64 6c 65 20 8c 20 66 65  |N. . . idle . fe|
00001d80  65 64 3d 66 65 65 64 2b  38 0d 07 58 1d 20 e7 20  |ed=feed+8..X. . |
00001d90  72 65 76 65 72 73 65 20  8c 20 66 65 65 64 3d 66  |reverse . feed=f|
00001da0  65 65 64 2b 31 36 0d 07  62 0a 20 3d 66 65 65 64  |eed+16..b. =feed|
00001db0  0d 07 6c 06 20 3a 0d 07  76 28 20 f4 20 50 65 72  |..l. :..v( . Per|
00001dc0  66 6f 72 6d 20 61 20 73  77 65 65 70 20 74 6f 20  |form a sweep to |
00001dd0  66 69 6e 64 20 61 6e 79  20 62 61 6c 6c 73 0d 07  |find any balls..|
00001de0  80 0b 20 dd f2 68 75 6e  74 0d 07 8a 23 20 f4 20  |.. ..hunt...# . |
00001df0  57 61 74 63 68 20 6f 75  74 20 69 66 20 74 6f 6f  |Watch out if too|
00001e00  20 6e 65 61 72 20 74 6f  20 6e 65 74 0d 07 94 76  | near to net...v|
00001e10  20 e7 20 28 66 61 24 3c  3e 22 42 22 20 80 20 66  | . (fa$<>"B" . f|
00001e20  72 65 71 61 3c 33 30 29  84 28 66 62 24 3c 3e 22  |reqa<30).(fb$<>"|
00001e30  42 22 20 80 20 66 72 65  71 62 3c 31 30 29 84 28  |B" . freqb<10).(|
00001e40  66 63 24 3c 3e 22 42 22  20 80 20 66 72 65 71 63  |fc$<>"B" . freqc|
00001e50  3c 31 30 29 20 8c 20 72  65 76 69 6e 67 3d 35 3a  |<10) . reving=5:|
00001e60  74 75 72 62 6f 3d b9 3a  72 65 76 65 72 73 65 3d  |turbo=.:reverse=|
00001e70  b9 3a 72 69 67 68 74 3d  b9 3a 6c 65 66 74 3d b9  |.:right=.:left=.|
00001e80  3a e1 0d 07 9e 6a 20 e7  20 72 65 76 69 6e 67 3e  |:....j . reving>|
00001e90  30 20 80 20 28 66 72 65  71 61 3c 31 35 30 20 84  |0 . (freqa<150 .|
00001ea0  20 66 72 65 71 62 3c 31  35 30 20 84 20 66 72 65  | freqb<150 . fre|
00001eb0  71 63 3c 31 35 30 29 20  8c 20 72 65 76 69 6e 67  |qc<150) . reving|
00001ec0  3d 72 65 76 69 6e 67 2d  31 3a 74 75 72 62 6f 3d  |=reving-1:turbo=|
00001ed0  b9 3a 72 65 76 65 72 73  65 3d b9 3a 72 69 67 68  |.:reverse=.:righ|
00001ee0  74 3d a3 3a 6c 65 66 74  3d b9 3a e1 0d 07 a8 0d  |t=.:left=.:.....|
00001ef0  20 72 65 76 69 6e 67 3d  30 0d 07 b2 06 20 3a 0d  | reving=0.... :.|
00001f00  07 bc 1a 20 f4 20 52 6f  74 61 74 65 20 74 6f 20  |... . Rotate to |
00001f10  66 61 63 65 20 62 61 6c  6c 0d 07 c6 24 20 f4 20  |face ball...$ . |
00001f20  57 68 65 72 65 20 73 65  61 72 63 68 20 61 66 74  |Where search aft|
00001f30  65 72 20 74 68 69 73 20  62 61 6c 6c 3f 0d 07 d0  |er this ball?...|
00001f40  28 20 e7 20 28 66 62 24  3d 22 42 22 20 80 20 66  |( . (fb$="B" . f|
00001f50  72 65 71 62 3e 31 35 30  29 20 8c 20 74 65 6e 64  |reqb>150) . tend|
00001f60  69 6e 67 3d 30 0d 07 da  26 20 e7 20 66 63 24 3d  |ing=0...& . fc$=|
00001f70  22 42 22 20 80 20 66 72  65 71 63 3e 31 35 30 20  |"B" . freqc>150 |
00001f80  8c 20 74 65 6e 64 69 6e  67 3d 31 0d 07 e4 1f 20  |. tending=1.... |
00001f90  f4 20 50 69 63 6b 20 62  65 73 74 20 62 61 6c 6c  |. Pick best ball|
00001fa0  20 74 6f 20 61 69 6d 20  61 74 0d 07 ee 5a 20 64  | to aim at...Z d|
00001fb0  69 73 74 3d 66 72 65 71  61 2a 30 2e 37 35 3a e7  |ist=freqa*0.75:.|
00001fc0  20 64 69 73 74 3e 66 72  65 71 62 20 80 20 66 62  | dist>freqb . fb|
00001fd0  24 3d 22 42 22 20 80 20  28 66 72 65 71 62 3c 66  |$="B" . (freqb<f|
00001fe0  72 65 71 63 20 84 20 66  63 24 3c 3e 22 42 22 29  |reqc . fc$<>"B")|
00001ff0  20 8c 20 73 74 65 65 72  3d 2d 31 3a 6c 65 66 74  | . steer=-1:left|
00002000  3d b9 3a e1 0d 07 f8 2f  20 e7 20 64 69 73 74 3e  |=.:..../ . dist>|
00002010  66 72 65 71 63 20 80 20  66 63 24 3d 22 42 22 20  |freqc . fc$="B" |
00002020  8c 20 73 74 65 65 72 3d  31 3a 72 69 67 68 74 3d  |. steer=1:right=|
00002030  b9 3a e1 0d 08 02 62 20  e7 20 66 61 24 3d 22 42  |.:....b . fa$="B|
00002040  22 20 8c 20 6c 65 66 74  3d 28 73 74 65 65 72 3c  |" . left=(steer<|
00002050  3e 31 29 3a 72 69 67 68  74 3d 28 73 74 65 65 72  |>1):right=(steer|
00002060  3c 3e 2d 31 29 3a 73 74  65 65 72 3d 30 3a 73 65  |<>-1):steer=0:se|
00002070  61 72 63 68 69 6e 67 3d  73 65 61 72 63 68 69 6e  |arching=searchin|
00002080  67 2f 32 3a 74 75 72 62  6f 3d 66 72 65 71 61 3e  |g/2:turbo=freqa>|
00002090  31 30 30 3a e1 0d 08 0c  22 20 e7 20 66 62 24 3d  |100:...." . fb$=|
000020a0  22 42 22 20 8c 20 73 74  65 65 72 3d 2d 31 3a 6c  |"B" . steer=-1:l|
000020b0  65 66 74 3d b9 3a e1 0d  08 16 22 20 e7 20 66 63  |eft=.:...." . fc|
000020c0  24 3d 22 42 22 20 8c 20  73 74 65 65 72 3d 31 3a  |$="B" . steer=1:|
000020d0  72 69 67 68 74 3d b9 3a  e1 0d 08 20 06 20 3a 0d  |right=.:... . :.|
000020e0  08 2a 30 20 f4 20 49 66  20 6e 6f 20 62 61 6c 6c  |.*0 . If no ball|
000020f0  20 69 6e 20 73 69 67 68  74 2c 20 63 6f 6e 74 69  | in sight, conti|
00002100  6e 75 65 20 72 6f 74 61  74 69 6f 6e 2e 2e 2e 0d  |nue rotation....|
00002110  08 34 36 20 73 65 61 72  63 68 69 6e 67 3d 73 65  |.46 searching=se|
00002120  61 72 63 68 69 6e 67 2b  31 3a 74 75 72 62 6f 3d  |arching+1:turbo=|
00002130  28 73 65 61 72 63 68 69  6e 67 3e 35 29 3a 73 74  |(searching>5):st|
00002140  65 65 72 3d 30 0d 08 3e  2a 20 e7 20 28 74 65 6e  |eer=0..>* . (ten|
00002150  64 69 6e 67 20 80 20 31  29 3c 3e 30 20 8c 20 72  |ding . 1)<>0 . r|
00002160  69 67 68 74 3d b9 20 8b  20 6c 65 66 74 3d b9 0d  |ight=. . left=..|
00002170  08 48 2a 20 e7 20 73 65  61 72 63 68 69 6e 67 3d  |.H* . searching=|
00002180  35 20 8c 20 74 65 6e 64  69 6e 67 3d 28 74 65 6e  |5 . tending=(ten|
00002190  64 69 6e 67 20 82 20 31  29 0d 08 52 23 20 e7 20  |ding . 1)..R# . |
000021a0  73 65 61 72 63 68 69 6e  67 3e 35 30 20 8c 20 73  |searching>50 . s|
000021b0  74 61 67 65 3d 73 74 61  67 65 2b 31 0d 08 5c 06  |tage=stage+1..\.|
000021c0  20 e1 0d 08 66 06 20 3a  0d 08 70 3c 20 f4 20 46  | ...f. :..p< . F|
000021d0  69 6e 64 20 65 64 67 65  20 6f 66 20 6e 65 74 20  |ind edge of net |
000021e0  61 6e 64 20 61 69 6d 20  66 6f 72 20 69 74 20 74  |and aim for it t|
000021f0  6f 20 6d 6f 76 65 20 74  6f 20 6f 74 68 65 72 20  |o move to other |
00002200  73 69 64 65 0d 08 7a 0e  20 dd f2 6d 6f 76 65 6f  |side..z. ..moveo|
00002210  75 74 0d 08 84 23 20 f4  20 57 61 74 63 68 20 6f  |ut...# . Watch o|
00002220  75 74 20 69 66 20 74 6f  6f 20 6e 65 61 72 20 74  |ut if too near t|
00002230  6f 20 6e 65 74 0d 08 8e  7b 20 e7 20 28 66 72 65  |o net...{ . (fre|
00002240  71 61 3c 33 30 20 84 20  66 72 65 71 62 3c 33 30  |qa<30 . freqb<30|
00002250  20 84 20 66 72 65 71 63  3c 33 30 29 20 84 20 28  | . freqc<30) . (|
00002260  72 65 76 69 6e 67 20 80  20 28 66 72 65 71 61 3c  |reving . (freqa<|
00002270  37 35 20 84 20 66 72 65  71 62 3c 37 35 20 84 20  |75 . freqb<75 . |
00002280  66 72 65 71 63 3c 37 35  29 29 20 8c 20 72 65 76  |freqc<75)) . rev|
00002290  69 6e 67 3d b9 3a 72 65  76 65 72 73 65 3d b9 3a  |ing=.:reverse=.:|
000022a0  72 69 67 68 74 3d b9 3a  6c 65 66 74 3d b9 3a e1  |right=.:left=.:.|
000022b0  0d 08 98 0d 20 72 65 76  69 6e 67 3d a3 0d 08 a2  |.... reving=....|
000022c0  23 20 f4 20 49 66 20 62  61 6c 6c 20 69 6e 20 73  |# . If ball in s|
000022d0  69 67 68 74 2c 20 67 6f  20 67 65 74 20 69 74 21  |ight, go get it!|
000022e0  0d 08 ac 41 20 e7 20 66  61 24 3d 22 42 22 20 84  |...A . fa$="B" .|
000022f0  20 66 62 24 3d 22 42 22  20 84 20 66 63 24 3d 22  | fb$="B" . fc$="|
00002300  42 22 20 8c 20 73 74 61  67 65 3d 73 74 61 67 65  |B" . stage=stage|
00002310  2d 31 3a 73 65 61 72 63  68 69 6e 67 3d 34 34 3a  |-1:searching=44:|
00002320  e1 0d 08 b6 2c 20 f4 20  41 6c 69 67 6e 20 62 61  |...., . Align ba|
00002330  6c 6c 62 6f 74 20 74 6f  20 66 61 63 65 20 74 68  |llbot to face th|
00002340  65 20 6e 65 74 20 70 6f  73 74 2e 2e 2e 0d 08 c0  |e net post......|
00002350  24 20 e7 20 66 61 24 3d  22 4e 22 20 84 20 66 61  |$ . fa$="N" . fa|
00002360  24 3d 22 50 22 20 8c 20  72 69 67 68 74 3d b9 3a  |$="P" . right=.:|
00002370  e1 0d 08 ca 25 20 e7 20  66 62 24 3c 3e 22 4e 22  |....% . fb$<>"N"|
00002380  20 80 20 66 62 24 3c 3e  22 50 22 20 8c 20 6c 65  | . fb$<>"P" . le|
00002390  66 74 3d b9 3a e1 0d 08  d4 2d 20 e7 20 66 62 24  |ft=.:....- . fb$|
000023a0  3d 22 50 22 20 80 20 66  72 65 71 62 3c 31 35 30  |="P" . freqb<150|
000023b0  20 8c 20 72 69 67 68 74  3d b9 3a 6e 65 61 72 3d  | . right=.:near=|
000023c0  31 3a e1 0d 08 de 1b 20  74 75 72 62 6f 3d b9 3a  |1:..... turbo=.:|
000023d0  6c 65 66 74 3d b9 3a 72  69 67 68 74 3d b9 0d 08  |left=.:right=...|
000023e0  e8 06 20 e1 0d 08 f2 06  20 3a 0d 08 fc 47 20 f4  |.. ..... :...G .|
000023f0  20 4e 65 61 72 6c 79 20  74 68 65 72 65 2e 2e 2e  | Nearly there...|
00002400  20 4a 75 73 74 20 6e 65  65 64 20 61 20 6c 69 74  | Just need a lit|
00002410  74 6c 65 20 6e 75 64 67  65 20 69 6e 20 74 68 65  |tle nudge in the|
00002420  20 72 69 67 68 74 20 64  69 72 65 63 74 69 6f 6e  | right direction|
00002430  2e 0d 09 06 12 20 dd f2  64 6f 6e 65 61 72 73 74  |..... ..donearst|
00002440  75 66 66 0d 09 10 26 20  e7 20 66 72 65 71 61 3c  |uff...& . freqa<|
00002450  33 30 20 80 20 66 61 24  3c 3e 22 42 22 20 8c 20  |30 . fa$<>"B" . |
00002460  72 69 67 68 74 3d b9 3a  e1 0d 09 1a 2b 20 e7 20  |right=.:....+ . |
00002470  6e 65 61 72 3d 31 20 80  20 66 64 24 3c 3e 22 55  |near=1 . fd$<>"U|
00002480  22 20 8c 20 6c 65 66 74  3d b9 3a 72 69 67 68 74  |" . left=.:right|
00002490  3d b9 3a e1 0d 09 24 32  20 6e 65 61 72 3d 6e 65  |=.:...$2 near=ne|
000024a0  61 72 2b 31 3a 6c 65 66  74 3d b9 3a 72 69 67 68  |ar+1:left=.:righ|
000024b0  74 3d 28 6e 65 61 72 20  83 20 32 29 3d 31 3a 74  |t=(near . 2)=1:t|
000024c0  75 72 62 6f 3d b9 0d 09  2e 3b 20 e7 20 6e 65 61  |urbo=....; . nea|
000024d0  72 3e 31 38 20 8c 20 6e  65 61 72 3d 30 3a 73 74  |r>18 . near=0:st|
000024e0  61 67 65 3d 73 74 61 67  65 2b 31 3a 73 65 61 72  |age=stage+1:sear|
000024f0  63 68 69 6e 67 3d 30 3a  74 65 6e 64 69 6e 67 3d  |ching=0:tending=|
00002500  31 0d 09 38 06 20 e1 0d  09 42 06 20 3a 0d 09 4c  |1..8. ...B. :..L|
00002510  3d 20 f4 20 49 6e 69 74  69 61 6c 69 73 65 20 42  |= . Initialise B|
00002520  61 6c 6c 42 6f 74 20 76  61 72 69 61 62 6c 65 73  |allBot variables|
00002530  20 61 74 20 74 68 65 20  62 65 67 69 6e 6e 69 6e  | at the beginnin|
00002540  67 20 6f 66 20 61 20 72  75 6e 0d 09 56 0e 20 dd  |g of a run..V. .|
00002550  f2 73 65 74 75 70 62 62  0d 09 60 2f 20 72 65 76  |.setupbb..`/ rev|
00002560  69 6e 67 3d a3 3a 6c 65  66 74 3d a3 3a 72 69 67  |ing=.:left=.:rig|
00002570  68 74 3d a3 3a 73 65 61  72 63 68 69 6e 67 3d 30  |ht=.:searching=0|
00002580  3a 69 64 6c 65 3d b9 0d  09 6a 1d 20 6e 65 61 72  |:idle=...j. near|
00002590  3d a3 3a 74 65 6e 64 69  6e 67 3d 31 3a 73 74 65  |=.:tending=1:ste|
000025a0  65 72 3d 30 0d 09 74 06  20 e1 0d 09 7e 06 20 3a  |er=0..t. ...~. :|
000025b0  0d 09 88 0f 20 dd f2 72  65 6c 65 61 73 65 62 0d  |.... ..releaseb.|
000025c0  09 92 2d 20 f4 20 47 6f  74 20 61 6c 6c 20 74 68  |..- . Got all th|
000025d0  65 20 62 61 6c 6c 73 2c  20 6e 6f 77 20 6a 75 73  |e balls, now jus|
000025e0  74 20 64 75 6d 70 20 74  68 65 6d 21 0d 09 9c 10  |t dump them!....|
000025f0  20 6e 65 61 72 3d 6e 65  61 72 2b 31 0d 09 a6 1d  | near=near+1....|
00002600  20 e7 20 6e 65 61 72 3e  39 20 8c 20 69 64 6c 65  | . near>9 . idle|
00002610  3d b9 3a 6e 65 61 72 3d  a3 0d 09 b0 06 20 e1 0d  |=.:near=..... ..|
00002620  ff                                                |.|
00002621
BioBot/BBMotor3.m0
BioBot/BBMotor3.m1
BioBot/BBMotor3.m2
BioBot/BBMotor3.m4
BioBot/BBMotor3.m5