Home » Personal collection » Acorn ADFS disks » Greaseweazled » dos34_s2312.016_compaq_user_programs.adf » BioBot/BBMotor2

BioBot/BBMotor2

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 » Greaseweazled » dos34_s2312.016_compaq_user_programs.adf
Filename: BioBot/BBMotor2
Read OK:
File size: 260E bytes
Load address: FFFFFB47
Exec address: FA895758
Duplicates

There are 5 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:IFa>180 THEN a=a-360
 1370 IF ABS(a)<15 AND freqa>d% THEN freqa=d%:fa$="B"
 1380 IF a>-46 AND a<=-15 AND freqb>d% THEN freqb=d%:fb$="B"
 1390 IF a>=15 AND a<46 AND freqc>d% THEN freqc=d%:fc$="B"
 1400 IF a>-76 AND a<=-75 AND freqd>d% THEN freqd=d%:fd$="B"
 1410 NEXT
 1420 :
 1430 REM Update user displays
 1440 :
 1450 IF type$="2" THEN ENDPROC
 1460 PRINTTAB(0,0)INT((TIME-start)/6000);":";(INT((TIME-start)/100)MOD60);" "
 1470 PRINTTAB(0,31)fd$,fb$,fa$,fc$,stage,INT(searching),left,right," ",dir," ",near;
 1480 SOUND 1,-1,freqa/4,5:SOUND 2,-1,freqb/4,5:SOUND 3,-1,freqc/4,5
 1490 ENDPROC
 1500:
 1510 REM Calculate bearing of B from A
 1520 DEFFNangle(x1,y1,x2,y2)
 1530 IF y2=y1 THEN ang=90 ELSE ang=180*ATN((x2-x1)/(y2-y1))/PI
 1540 IF (y2>y1) THEN ang=ang+180
 1550 IF ang<0 THEN ang=ang+360
 1560 =ang MOD 360
 1570 :
 1580 REM Computer Monitor of BallBot's progress
 1590 DEFPROCcompmon
 1600 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"
 1610 IF idle THEN PRINTst$,INT((TIME-start)/6000);":";(INT((TIME-start)/100)MOD60)
 1620 IF TIME>start+36000 THEN idle=TRUE:PRINT"Time","****"
 1630 IFbbx>635ANDbbx<645ANDbby>105ANDbby<920THENidle=TRUE:PRINT"Crash","****"
 1640 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
 1650 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
 1660 ENDPROC
 1670 :
 1680 REM BALLBOT ROBOTIC INTELLIGENCE MODULE
 1690 :
 1700 DEFFNai(freqa,freqb,freqc,freqd)
 1710 REM Artificial intelligence routines (ie. What Next??)
 1720 LOCALleft,right,turbo,reverse
 1730 left=FALSE:right=FALSE:turbo=FALSE:reverse=FALSE
 1740 :
 1750 REM What stage are we in? Hunt for balls or move to new area?
 1760 IF near<>0 AND stage<4 THEN PROCdonearstuff
 1770 IF near=0 AND (stage=0 OR stage=2) THEN PROChunt
 1780 IF near=0 AND (stage=1 OR stage=3) THEN PROCmoveout
 1790 IF stage=4 THEN PROCreleaseb
 1800 :
 1810 REM Prepare output into binary for transmission
 1820 feed=0:IF left THEN feed=feed+1
 1830 IF right THEN feed=feed+2
 1840 IF turbo THEN feed=feed+4
 1850 IF NOT idle THEN feed=feed+8
 1860 IF reverse THEN feed=feed+16
 1870 =feed
 1880 :
 1890 REM Perform a sweep to find any balls
 1900 DEFPROChunt
 1910 REM Watch out if too near to net
 1920 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
 1930 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
 1940 reving=0
 1950 :
 1960 REM Rotate to face ball
 1970 REM Where search after this ball?
 1980 IF (fb$="B" AND freqb>150) THEN tending=0
 1990 IF fc$="B" AND freqc>150 THEN tending=1
 2000 REM Pick best ball to aim at
 2010 dist=freqa*0.75:IF dist>freqb AND fb$="B" AND (freqb<freqc OR fc$<>"B") THEN steer=-1:left=TRUE:ENDPROC
 2020 IF dist>freqc AND fc$="B" THEN steer=1:right=TRUE:ENDPROC
 2030 IF fa$="B" THEN left=(steer<>1):right=(steer<>-1):steer=0:searching=searching/2:turbo=freqa>100:ENDPROC
 2040 IF fb$="B" THEN steer=-1:left=TRUE:ENDPROC
 2050 IF fc$="B" THEN steer=1:right=TRUE:ENDPROC
 2060 :
 2070 REM If no ball in sight, continue rotation...
 2080 searching=searching+1:turbo=(searching>5):steer=0
 2090 IF (tending AND 1)<>0 THEN right=TRUE ELSE left=TRUE
 2100 IF searching=5 THEN tending=(tending EOR 1)
 2110 IF searching>50 THEN stage=stage+1
 2120 ENDPROC
 2130 :
 2140 REM Find edge of net and aim for it to move to other side
 2150 DEFPROCmoveout
 2160 REM Watch out if too near to net
 2170 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
 2180 reving=FALSE
 2190 REM If ball in sight, go get it!
 2200 IF fa$="B" OR fb$="B" OR fc$="B" OR fd$="B" THEN stage=stage-1:searching=44:ENDPROC
 2210 REM Align ballbot to face the net post...
 2220 IF fa$="N" OR fa$="P" THEN right=TRUE:ENDPROC
 2230 IF fb$<>"N" AND fb$<>"P" THEN left=TRUE:ENDPROC
 2240 IF fb$="P" AND freqb<150 THEN right=TRUE:near=1:ENDPROC
 2250 turbo=TRUE:left=TRUE:right=TRUE
 2260 ENDPROC
 2270 :
 2280 REM Nearly there... Just need a little nudge in the right direction.
 2290 DEFPROCdonearstuff
 2300 IF freqa<30 AND fa$<>"B" THEN right=TRUE:ENDPROC
 2310 IF near=1 AND fd$<>"U" THEN left=TRUE:right=TRUE:ENDPROC
 2320 near=near+1:left=TRUE:right=(near MOD 2)=1:turbo=TRUE
 2330 IF near>18 THEN near=0:stage=stage+1:searching=0:tending=1
 2340 ENDPROC
 2350 :
 2360 REM Initialise BallBot variables at the beginning of a run
 2370 DEFPROCsetupbb
 2380 reving=FALSE:left=FALSE:right=FALSE:searching=0:idle=TRUE
 2390 near=FALSE:tending=1:steer=0
 2400 ENDPROC
 2410 :
 2420 DEFPROCreleaseb
 2430 REM Got all the balls, now just dump them!
 2440 near=near+1
 2450 IF near>9 THEN idle=TRUE:near=FALSE
 2460 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.
w �(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
PE a=�angle(ball(ball,0),ball(ball,1),bbx,bby)-dir:�a>180 � a=a-360
Z, � �(a)<15 � freqa>d% � freqa=d%:fa$="B"
d3 � a>-46 � a<=-15 � freqb>d% � freqb=d%:fb$="B"
n1 � a>=15 � a<46 � freqc>d% � freqc=d%:fc$="B"
x3 � a>-76 � a<=-75 � 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
" :
,- � Computer Monitor of BallBot's progress
6 ��compmon
@r � 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"
J> � idle � �st$,�((�-start)/6000);":";(�((�-start)/100)�60)
T, � �>start+36000 � idle=�:�"Time","****"
^< �bbx>635�bbx<645�bby>105�bby<920�idle=�:�"Crash","****"
h� � 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):�
r� � 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
  feed=0:� left � feed=feed+1
& � right � feed=feed+2
0 � turbo � feed=feed+4
: � � idle � feed=feed+8
D � reverse � feed=feed+16
N
 =feed
X :
b( � Perform a sweep to find any balls
l ��hunt
v# � 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...
 6 searching=searching+1:turbo=(searching>5):steer=0
** � (tending � 1)<>0 � right=� � left=�
4* � searching=5 � tending=(tending � 1)
># � searching>50 � stage=stage+1
H �
R :
\< � Find edge of net and aim for it to move to other side
f ��moveout
p# � Watch out if too near to net
z{ � (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!
�K � fa$="B" � fb$="B" � fc$="B" � fd$="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= � Initialise BallBot variables at the beginning of a run
	B ��setupbb
	L/ reving=�:left=�:right=�:searching=0:idle=�
	V near=�:tending=1:steer=0
	` �
	j :
	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 77  20 e7 28 62 62 78 3c 36  |est....w .(bbx<6|
00000fd0  34 30 80 6d 69 6e 3c 3d  39 30 80 6d 61 78 3e 3d  |40.min<=90.max>=|
00000fe0  39 30 29 84 28 62 62 78  3e 36 34 30 80 6d 69 6e  |90).(bbx>640.min|
00000ff0  3c 3d 32 37 30 80 6d 61  78 3e 3d 32 37 30 29 20  |<=270.max>=270) |
00001000  80 20 28 62 62 79 3e 31  30 30 20 80 20 62 62 79  |. (bby>100 . bby|
00001010  3c 39 32 33 29 20 8c 20  68 69 74 3d 62 62 79 3a  |<923) . hit=bby:|
00001020  64 69 73 74 3d 94 28 62  62 78 2d 36 34 30 29 3a  |dist=.(bbx-640):|
00001030  6d 69 6e 3d 30 3a 6d 61  78 3d 30 0d 04 24 2f 20  |min=0:max=0..$/ |
00001040  f4 20 4f 74 68 65 72 77  69 73 65 20 66 69 6e 64  |. Otherwise find|
00001050  20 73 68 6f 72 74 65 73  74 20 65 78 74 72 65 6d  | shortest extrem|
00001060  65 20 6f 66 20 72 61 6e  67 65 0d 04 2e 53 20 e7  |e of range...S .|
00001070  20 b5 28 af 2a 6d 69 6e  2f 31 38 30 29 3c 3e 30  | .(.*min/180)<>0|
00001080  20 8c 20 64 69 73 74 3d  28 36 34 30 2d 62 62 78  | . dist=(640-bbx|
00001090  29 2f b5 28 af 2a 6d 69  6e 2f 31 38 30 29 3a 68  |)/.(.*min/180):h|
000010a0  69 74 3d 62 62 79 2b 28  36 34 30 2d 62 62 78 29  |it=bby+(640-bbx)|
000010b0  2f b7 28 af 2a 6d 69 6e  2f 31 38 30 29 0d 04 38  |/.(.*min/180)..8|
000010c0  55 20 e7 20 b5 28 af 2a  6d 61 78 2f 31 38 30 29  |U . .(.*max/180)|
000010d0  3c 3e 30 20 8c 20 64 69  73 74 61 3d 28 36 34 30  |<>0 . dista=(640|
000010e0  2d 62 62 78 29 2f b5 28  af 2a 6d 61 78 2f 31 38  |-bbx)/.(.*max/18|
000010f0  30 29 3a 68 69 74 61 3d  62 62 79 2b 28 36 34 30  |0):hita=bby+(640|
00001100  2d 62 62 78 29 2f b7 28  af 2a 6d 61 78 2f 31 38  |-bbx)/.(.*max/18|
00001110  30 29 0d 04 42 2c 20 f4  20 4a 75 73 74 20 63 68  |0)..B, . Just ch|
00001120  65 63 6b 20 69 66 20 70  6f 73 74 20 69 6e 20 6d  |eck if post in m|
00001130  69 64 64 6c 65 20 6f 66  20 72 61 6e 67 65 0d 04  |iddle of range..|
00001140  4c 64 20 e7 20 62 62 78  3c 36 34 30 20 80 20 68  |Ld . bbx<640 . h|
00001150  69 74 3e 31 30 30 20 80  20 28 68 69 74 61 3c 31  |it>100 . (hita<1|
00001160  30 30 20 84 20 64 69 73  74 61 3c 30 29 20 80 20  |00 . dista<0) . |
00001170  64 69 73 74 3e 30 20 8c  20 68 69 74 61 3d 31 30  |dist>0 . hita=10|
00001180  30 3a 64 69 73 74 61 3d  b6 28 28 62 62 78 2d 36  |0:dista=.((bbx-6|
00001190  34 30 29 5e 32 2b 28 62  62 79 2d 31 30 30 29 5e  |40)^2+(bby-100)^|
000011a0  32 29 0d 04 56 62 20 e7  20 62 62 78 3c 36 34 30  |2)..Vb . bbx<640|
000011b0  20 80 20 68 69 74 61 3c  39 32 33 20 80 20 28 68  | . hita<923 . (h|
000011c0  69 74 3e 39 32 33 20 84  20 64 69 73 74 3c 30 29  |it>923 . dist<0)|
000011d0  20 80 20 64 69 73 74 61  3e 30 20 8c 20 68 69 74  | . dista>0 . hit|
000011e0  3d 39 32 33 3a 64 69 73  74 3d b6 28 28 62 62 78  |=923:dist=.((bbx|
000011f0  2d 36 34 30 29 5e 32 2b  28 62 62 79 2d 39 32 33  |-640)^2+(bby-923|
00001200  29 5e 32 29 0d 04 60 62  20 e7 20 62 62 78 3e 36  |)^2)..`b . bbx>6|
00001210  34 30 20 80 20 68 69 74  61 3e 31 30 30 20 80 20  |40 . hita>100 . |
00001220  28 68 69 74 3c 31 30 30  20 84 20 64 69 73 74 3c  |(hit<100 . dist<|
00001230  30 29 20 80 20 64 69 73  74 61 3e 30 20 8c 20 68  |0) . dista>0 . h|
00001240  69 74 3d 31 30 30 3a 64  69 73 74 3d b6 28 28 62  |it=100:dist=.((b|
00001250  62 78 2d 36 34 30 29 5e  32 2b 28 62 62 79 2d 31  |bx-640)^2+(bby-1|
00001260  30 30 29 5e 32 29 0d 04  6a 64 20 e7 20 62 62 78  |00)^2)..jd . bbx|
00001270  3e 36 34 30 20 80 20 68  69 74 3c 39 32 33 20 80  |>640 . hit<923 .|
00001280  20 28 68 69 74 61 3e 39  32 33 20 84 20 64 69 73  | (hita>923 . dis|
00001290  74 61 3c 30 29 20 80 20  64 69 73 74 3e 30 20 8c  |ta<0) . dist>0 .|
000012a0  20 68 69 74 61 3d 39 32  33 3a 64 69 73 74 61 3d  | hita=923:dista=|
000012b0  b6 28 28 62 62 78 2d 36  34 30 29 5e 32 2b 28 62  |.((bbx-640)^2+(b|
000012c0  62 79 2d 39 32 33 29 5e  32 29 0d 04 74 1d 20 f4  |by-923)^2)..t. .|
000012d0  20 50 69 63 6b 20 62 65  73 74 20 74 6f 20 73 65  | Pick best to se|
000012e0  6e 64 20 6f 66 66 21 0d  04 7e 48 20 e7 20 64 69  |nd off!..~H . di|
000012f0  73 74 3c 30 20 84 20 28  64 69 73 74 61 3c 64 69  |st<0 . (dista<di|
00001300  73 74 20 80 20 68 69 74  61 3e 31 30 30 20 80 20  |st . hita>100 . |
00001310  68 69 74 61 3c 39 32 33  29 20 8c 20 64 69 73 74  |hita<923) . dist|
00001320  3d 64 69 73 74 61 3a 68  69 74 3d 68 69 74 61 0d  |=dista:hit=hita.|
00001330  04 88 3b 20 e7 20 68 69  74 3e 39 32 33 20 84 20  |..; . hit>923 . |
00001340  68 69 74 3c 31 30 30 20  84 20 64 69 73 74 3c 30  |hit<100 . dist<0|
00001350  20 8c 20 66 74 79 70 65  24 3d 22 55 22 3a 3d 66  | . ftype$="U":=f|
00001360  72 65 71 2b b3 28 36 29  2d 33 0d 04 92 2b 20 e7  |req+.(6)-3...+ .|
00001370  20 68 69 74 3e 39 30 30  20 84 20 68 69 74 3c 31  | hit>900 . hit<1|
00001380  32 33 20 8c 20 66 74 79  70 65 24 3d 22 50 22 3a  |23 . ftype$="P":|
00001390  3d 64 69 73 74 0d 04 9c  0f 20 66 74 79 70 65 24  |=dist.... ftype$|
000013a0  3d 22 4e 22 0d 04 a6 0a  20 3d 64 69 73 74 0d 04  |="N".... =dist..|
000013b0  b0 06 20 3a 0d 04 ba 32  20 f4 20 43 61 6c 63 75  |.. :...2 . Calcu|
000013c0  6c 61 74 65 20 42 61 6c  6c 62 6f 74 27 73 20 72  |late Ballbot's r|
000013d0  65 61 64 69 6e 67 73 20  28 4d 41 49 4e 20 52 4f  |eadings (MAIN RO|
000013e0  55 54 49 4e 45 29 0d 04  c4 06 20 3a 0d 04 ce 0c  |UTINE).... :....|
000013f0  20 dd f2 73 65 6e 73 65  0d 04 d8 2a 20 f4 20 47  | ..sense...* . G|
00001400  65 74 20 62 61 63 6b 67  72 6f 75 6e 64 20 72 65  |et background re|
00001410  61 64 69 6e 67 73 20 66  72 6f 6d 20 46 4e 62 61  |adings from FNba|
00001420  63 6b 0d 04 e2 15 20 66  72 65 71 3d b3 28 32 35  |ck.... freq=.(25|
00001430  30 29 2b 31 35 30 30 0d  04 ec 2f 20 66 72 65 71  |0)+1500.../ freq|
00001440  61 3d a4 62 61 63 6b 28  66 72 65 71 2c 64 69 72  |a=.back(freq,dir|
00001450  2d 31 35 2c 64 69 72 2b  31 35 29 3a 66 61 24 3d  |-15,dir+15):fa$=|
00001460  66 74 79 70 65 24 0d 04  f6 2f 20 66 72 65 71 62  |ftype$.../ freqb|
00001470  3d a4 62 61 63 6b 28 66  72 65 71 2c 64 69 72 2d  |=.back(freq,dir-|
00001480  34 35 2c 64 69 72 2d 31  35 29 3a 66 62 24 3d 66  |45,dir-15):fb$=f|
00001490  74 79 70 65 24 0d 05 00  2f 20 66 72 65 71 63 3d  |type$.../ freqc=|
000014a0  a4 62 61 63 6b 28 66 72  65 71 2c 64 69 72 2b 31  |.back(freq,dir+1|
000014b0  35 2c 64 69 72 2b 34 35  29 3a 66 63 24 3d 66 74  |5,dir+45):fc$=ft|
000014c0  79 70 65 24 0d 05 0a 2f  20 66 72 65 71 64 3d a4  |ype$.../ freqd=.|
000014d0  62 61 63 6b 28 66 72 65  71 2c 64 69 72 2d 37 35  |back(freq,dir-75|
000014e0  2c 64 69 72 2d 34 35 29  3a 66 64 24 3d 66 74 79  |,dir-45):fd$=fty|
000014f0  70 65 24 0d 05 14 06 20  3a 0d 05 1e 44 20 f4 20  |pe$.... :...D . |
00001500  41 64 64 20 61 6e 79 20  72 65 6c 65 76 61 6e 74  |Add any relevant|
00001510  20 62 61 6c 6c 73 20 74  6f 20 72 65 61 64 69 6e  | balls to readin|
00001520  67 73 20 28 75 73 69 6e  67 20 68 61 69 72 79 20  |gs (using hairy |
00001530  74 72 69 67 6f 6e 6f 6d  65 74 72 79 29 0d 05 28  |trigonometry)..(|
00001540  06 20 3a 0d 05 32 0e 20  e3 62 61 6c 6c 3d 30 b8  |. :..2. .ball=0.|
00001550  34 0d 05 3c 34 20 64 25  3d b6 28 28 62 61 6c 6c  |4..<4 d%=.((ball|
00001560  28 62 61 6c 6c 2c 30 29  2d 62 62 78 29 5e 32 2b  |(ball,0)-bbx)^2+|
00001570  28 62 61 6c 6c 28 62 61  6c 6c 2c 31 29 2d 62 62  |(ball(ball,1)-bb|
00001580  79 29 5e 32 29 0d 05 46  1f 20 e7 20 62 61 6c 6c  |y)^2)..F. . ball|
00001590  28 62 61 6c 6c 2c 30 29  3d 30 20 8c 20 64 25 3d  |(ball,0)=0 . d%=|
000015a0  39 39 39 39 0d 05 50 45  20 61 3d a4 61 6e 67 6c  |9999..PE a=.angl|
000015b0  65 28 62 61 6c 6c 28 62  61 6c 6c 2c 30 29 2c 62  |e(ball(ball,0),b|
000015c0  61 6c 6c 28 62 61 6c 6c  2c 31 29 2c 62 62 78 2c  |all(ball,1),bbx,|
000015d0  62 62 79 29 2d 64 69 72  3a e7 61 3e 31 38 30 20  |bby)-dir:.a>180 |
000015e0  8c 20 61 3d 61 2d 33 36  30 0d 05 5a 2c 20 e7 20  |. a=a-360..Z, . |
000015f0  94 28 61 29 3c 31 35 20  80 20 66 72 65 71 61 3e  |.(a)<15 . freqa>|
00001600  64 25 20 8c 20 66 72 65  71 61 3d 64 25 3a 66 61  |d% . freqa=d%:fa|
00001610  24 3d 22 42 22 0d 05 64  33 20 e7 20 61 3e 2d 34  |$="B"..d3 . a>-4|
00001620  36 20 80 20 61 3c 3d 2d  31 35 20 80 20 66 72 65  |6 . a<=-15 . fre|
00001630  71 62 3e 64 25 20 8c 20  66 72 65 71 62 3d 64 25  |qb>d% . freqb=d%|
00001640  3a 66 62 24 3d 22 42 22  0d 05 6e 31 20 e7 20 61  |:fb$="B"..n1 . a|
00001650  3e 3d 31 35 20 80 20 61  3c 34 36 20 80 20 66 72  |>=15 . a<46 . fr|
00001660  65 71 63 3e 64 25 20 8c  20 66 72 65 71 63 3d 64  |eqc>d% . freqc=d|
00001670  25 3a 66 63 24 3d 22 42  22 0d 05 78 33 20 e7 20  |%:fc$="B"..x3 . |
00001680  61 3e 2d 37 36 20 80 20  61 3c 3d 2d 37 35 20 80  |a>-76 . a<=-75 .|
00001690  20 66 72 65 71 64 3e 64  25 20 8c 20 66 72 65 71  | freqd>d% . freq|
000016a0  64 3d 64 25 3a 66 64 24  3d 22 42 22 0d 05 82 06  |d=d%:fd$="B"....|
000016b0  20 ed 0d 05 8c 06 20 3a  0d 05 96 1b 20 f4 20 55  | ..... :.... . U|
000016c0  70 64 61 74 65 20 75 73  65 72 20 64 69 73 70 6c  |pdate user displ|
000016d0  61 79 73 0d 05 a0 06 20  3a 0d 05 aa 14 20 e7 20  |ays.... :.... . |
000016e0  74 79 70 65 24 3d 22 32  22 20 8c 20 e1 0d 05 b4  |type$="2" . ....|
000016f0  3a 20 f1 8a 30 2c 30 29  a8 28 28 91 2d 73 74 61  |: ..0,0).((.-sta|
00001700  72 74 29 2f 36 30 30 30  29 3b 22 3a 22 3b 28 a8  |rt)/6000);":";(.|
00001710  28 28 91 2d 73 74 61 72  74 29 2f 31 30 30 29 83  |((.-start)/100).|
00001720  36 30 29 3b 22 20 22 0d  05 be 4b 20 f1 8a 30 2c  |60);" "...K ..0,|
00001730  33 31 29 66 64 24 2c 66  62 24 2c 66 61 24 2c 66  |31)fd$,fb$,fa$,f|
00001740  63 24 2c 73 74 61 67 65  2c a8 28 73 65 61 72 63  |c$,stage,.(searc|
00001750  68 69 6e 67 29 2c 6c 65  66 74 2c 72 69 67 68 74  |hing),left,right|
00001760  2c 22 20 22 2c 64 69 72  2c 22 20 22 2c 6e 65 61  |," ",dir," ",nea|
00001770  72 3b 0d 05 c8 37 20 d4  20 31 2c 2d 31 2c 66 72  |r;...7 . 1,-1,fr|
00001780  65 71 61 2f 34 2c 35 3a  d4 20 32 2c 2d 31 2c 66  |eqa/4,5:. 2,-1,f|
00001790  72 65 71 62 2f 34 2c 35  3a d4 20 33 2c 2d 31 2c  |reqb/4,5:. 3,-1,|
000017a0  66 72 65 71 63 2f 34 2c  35 0d 05 d2 06 20 e1 0d  |freqc/4,5.... ..|
000017b0  05 dc 05 3a 0d 05 e6 24  20 f4 20 43 61 6c 63 75  |...:...$ . Calcu|
000017c0  6c 61 74 65 20 62 65 61  72 69 6e 67 20 6f 66 20  |late bearing of |
000017d0  42 20 66 72 6f 6d 20 41  0d 05 f0 19 20 dd a4 61  |B from A.... ..a|
000017e0  6e 67 6c 65 28 78 31 2c  79 31 2c 78 32 2c 79 32  |ngle(x1,y1,x2,y2|
000017f0  29 0d 05 fa 34 20 e7 20  79 32 3d 79 31 20 8c 20  |)...4 . y2=y1 . |
00001800  61 6e 67 3d 39 30 20 8b  20 61 6e 67 3d 31 38 30  |ang=90 . ang=180|
00001810  2a 99 28 28 78 32 2d 78  31 29 2f 28 79 32 2d 79  |*.((x2-x1)/(y2-y|
00001820  31 29 29 2f af 0d 06 04  1c 20 e7 20 28 79 32 3e  |1))/..... . (y2>|
00001830  79 31 29 20 8c 20 61 6e  67 3d 61 6e 67 2b 31 38  |y1) . ang=ang+18|
00001840  30 0d 06 0e 1a 20 e7 20  61 6e 67 3c 30 20 8c 20  |0.... . ang<0 . |
00001850  61 6e 67 3d 61 6e 67 2b  33 36 30 0d 06 18 0f 20  |ang=ang+360.... |
00001860  3d 61 6e 67 20 83 20 33  36 30 0d 06 22 06 20 3a  |=ang . 360..". :|
00001870  0d 06 2c 2d 20 f4 20 43  6f 6d 70 75 74 65 72 20  |..,- . Computer |
00001880  4d 6f 6e 69 74 6f 72 20  6f 66 20 42 61 6c 6c 42  |Monitor of BallB|
00001890  6f 74 27 73 20 70 72 6f  67 72 65 73 73 0d 06 36  |ot's progress..6|
000018a0  0e 20 dd f2 63 6f 6d 70  6d 6f 6e 0d 06 40 72 20  |. ..compmon..@r |
000018b0  e7 20 69 64 6c 65 20 80  20 28 62 61 6c 6c 28 30  |. idle . (ball(0|
000018c0  2c 30 29 3c 3e 30 20 84  20 62 61 6c 6c 28 31 2c  |,0)<>0 . ball(1,|
000018d0  30 29 3c 3e 30 20 84 20  62 61 6c 6c 28 32 2c 30  |0)<>0 . ball(2,0|
000018e0  29 3c 3e 30 20 84 20 62  61 6c 6c 28 33 2c 30 29  |)<>0 . ball(3,0)|
000018f0  3c 3e 30 20 84 20 62 61  6c 6c 28 34 2c 30 29 3c  |<>0 . ball(4,0)<|
00001900  3e 30 29 20 8c 20 73 74  24 3d 22 46 61 69 6c 22  |>0) . st$="Fail"|
00001910  20 8b 20 73 74 24 3d 22  50 61 73 73 22 0d 06 4a  | . st$="Pass"..J|
00001920  3e 20 e7 20 69 64 6c 65  20 8c 20 f1 73 74 24 2c  |> . idle . .st$,|
00001930  a8 28 28 91 2d 73 74 61  72 74 29 2f 36 30 30 30  |.((.-start)/6000|
00001940  29 3b 22 3a 22 3b 28 a8  28 28 91 2d 73 74 61 72  |);":";(.((.-star|
00001950  74 29 2f 31 30 30 29 83  36 30 29 0d 06 54 2c 20  |t)/100).60)..T, |
00001960  e7 20 91 3e 73 74 61 72  74 2b 33 36 30 30 30 20  |. .>start+36000 |
00001970  8c 20 69 64 6c 65 3d b9  3a f1 22 54 69 6d 65 22  |. idle=.:."Time"|
00001980  2c 22 2a 2a 2a 2a 22 0d  06 5e 3c 20 e7 62 62 78  |,"****"..^< .bbx|
00001990  3e 36 33 35 80 62 62 78  3c 36 34 35 80 62 62 79  |>635.bbx<645.bby|
000019a0  3e 31 30 35 80 62 62 79  3c 39 32 30 8c 69 64 6c  |>105.bby<920.idl|
000019b0  65 3d b9 3a f1 22 43 72  61 73 68 22 2c 22 2a 2a  |e=.:."Crash","**|
000019c0  2a 2a 22 0d 06 68 99 20  e7 20 69 64 6c 65 20 8c  |**"..h. . idle .|
000019d0  20 62 62 78 3d 36 34 30  3a 62 62 79 3d 39 35 30  | bbx=640:bby=950|
000019e0  3a 64 69 72 3d 32 37 30  3a 73 74 61 67 65 3d 30  |:dir=270:stage=0|
000019f0  3a f2 73 65 74 75 70 62  62 3a 73 74 61 72 74 3d  |:.setupbb:start=|
00001a00  91 3a e3 62 3d 30 b8 34  3a 62 61 6c 6c 28 62 2c  |.:.b=0.4:ball(b,|
00001a10  30 29 3d b3 28 31 31 38  30 29 3a 62 61 6c 6c 28  |0)=.(1180):ball(|
00001a20  62 2c 31 29 3d b3 28 31  30 32 34 29 3a 62 61 6c  |b,1)=.(1024):bal|
00001a30  6c 28 62 2c 30 29 3d 62  61 6c 6c 28 62 2c 30 29  |l(b,0)=ball(b,0)|
00001a40  2d 31 30 30 2a 28 28 62  61 6c 6c 28 62 2c 30 29  |-100*((ball(b,0)|
00001a50  20 81 20 31 30 30 29 3d  36 29 3a ed 0d 06 72 af  | . 100)=6):...r.|
00001a60  20 e7 20 69 64 6c 65 20  8c 20 f1 22 5b 22 3b 62  | . idle . ."[";b|
00001a70  61 6c 6c 28 30 2c 30 29  3b 22 2c 22 3b 62 61 6c  |all(0,0);",";bal|
00001a80  6c 28 30 2c 31 29 3b 22  5d 20 5b 22 3b 62 61 6c  |l(0,1);"] [";bal|
00001a90  6c 28 31 2c 30 29 3b 22  2c 22 3b 62 61 6c 6c 28  |l(1,0);",";ball(|
00001aa0  31 2c 31 29 3b 22 5d 20  5b 22 3b 62 61 6c 6c 28  |1,1);"] [";ball(|
00001ab0  32 2c 30 29 3b 22 2c 22  3b 62 61 6c 6c 28 32 2c  |2,0);",";ball(2,|
00001ac0  31 29 3b 22 5d 20 5b 22  3b 62 61 6c 6c 28 33 2c  |1);"] [";ball(3,|
00001ad0  30 29 3b 22 2c 22 3b 62  61 6c 6c 28 33 2c 31 29  |0);",";ball(3,1)|
00001ae0  3b 22 5d 20 5b 22 3b 62  61 6c 6c 28 34 2c 30 29  |;"] [";ball(4,0)|
00001af0  3b 22 2c 22 3b 62 61 6c  6c 28 34 2c 31 29 3b 22  |;",";ball(4,1);"|
00001b00  5d 22 2c 3b 3a 69 64 6c  65 3d a3 0d 06 7c 06 20  |]",;:idle=...|. |
00001b10  e1 0d 06 86 06 20 3a 0d  06 90 2a 20 f4 20 42 41  |..... :...* . BA|
00001b20  4c 4c 42 4f 54 20 52 4f  42 4f 54 49 43 20 49 4e  |LLBOT ROBOTIC IN|
00001b30  54 45 4c 4c 49 47 45 4e  43 45 20 4d 4f 44 55 4c  |TELLIGENCE MODUL|
00001b40  45 0d 06 9a 06 20 3a 0d  06 a4 22 20 dd a4 61 69  |E.... :..." ..ai|
00001b50  28 66 72 65 71 61 2c 66  72 65 71 62 2c 66 72 65  |(freqa,freqb,fre|
00001b60  71 63 2c 66 72 65 71 64  29 0d 06 ae 39 20 f4 20  |qc,freqd)...9 . |
00001b70  41 72 74 69 66 69 63 69  61 6c 20 69 6e 74 65 6c  |Artificial intel|
00001b80  6c 69 67 65 6e 63 65 20  72 6f 75 74 69 6e 65 73  |ligence routines|
00001b90  20 28 69 65 2e 20 57 68  61 74 20 4e 65 78 74 3f  | (ie. What Next?|
00001ba0  3f 29 0d 06 b8 1e 20 ea  6c 65 66 74 2c 72 69 67  |?).... .left,rig|
00001bb0  68 74 2c 74 75 72 62 6f  2c 72 65 76 65 72 73 65  |ht,turbo,reverse|
00001bc0  0d 06 c2 25 20 6c 65 66  74 3d a3 3a 72 69 67 68  |...% left=.:righ|
00001bd0  74 3d a3 3a 74 75 72 62  6f 3d a3 3a 72 65 76 65  |t=.:turbo=.:reve|
00001be0  72 73 65 3d a3 0d 06 cc  06 20 3a 0d 06 d6 40 20  |rse=..... :...@ |
00001bf0  f4 20 57 68 61 74 20 73  74 61 67 65 20 61 72 65  |. What stage are|
00001c00  20 77 65 20 69 6e 3f 20  48 75 6e 74 20 66 6f 72  | we in? Hunt for|
00001c10  20 62 61 6c 6c 73 20 6f  72 20 6d 6f 76 65 20 74  | balls or move t|
00001c20  6f 20 6e 65 77 20 61 72  65 61 3f 0d 06 e0 27 20  |o new area?...' |
00001c30  e7 20 6e 65 61 72 3c 3e  30 20 80 20 73 74 61 67  |. near<>0 . stag|
00001c40  65 3c 34 20 8c 20 f2 64  6f 6e 65 61 72 73 74 75  |e<4 . .donearstu|
00001c50  66 66 0d 06 ea 2b 20 e7  20 6e 65 61 72 3d 30 20  |ff...+ . near=0 |
00001c60  80 20 28 73 74 61 67 65  3d 30 20 84 20 73 74 61  |. (stage=0 . sta|
00001c70  67 65 3d 32 29 20 8c 20  f2 68 75 6e 74 0d 06 f4  |ge=2) . .hunt...|
00001c80  2e 20 e7 20 6e 65 61 72  3d 30 20 80 20 28 73 74  |. . near=0 . (st|
00001c90  61 67 65 3d 31 20 84 20  73 74 61 67 65 3d 33 29  |age=1 . stage=3)|
00001ca0  20 8c 20 f2 6d 6f 76 65  6f 75 74 0d 06 fe 1a 20  | . .moveout.... |
00001cb0  e7 20 73 74 61 67 65 3d  34 20 8c 20 f2 72 65 6c  |. stage=4 . .rel|
00001cc0  65 61 73 65 62 0d 07 08  06 20 3a 0d 07 12 32 20  |easeb.... :...2 |
00001cd0  f4 20 50 72 65 70 61 72  65 20 6f 75 74 70 75 74  |. Prepare output|
00001ce0  20 69 6e 74 6f 20 62 69  6e 61 72 79 20 66 6f 72  | into binary for|
00001cf0  20 74 72 61 6e 73 6d 69  73 73 69 6f 6e 0d 07 1c  | transmission...|
00001d00  20 20 66 65 65 64 3d 30  3a e7 20 6c 65 66 74 20  |  feed=0:. left |
00001d10  8c 20 66 65 65 64 3d 66  65 65 64 2b 31 0d 07 26  |. feed=feed+1..&|
00001d20  1a 20 e7 20 72 69 67 68  74 20 8c 20 66 65 65 64  |. . right . feed|
00001d30  3d 66 65 65 64 2b 32 0d  07 30 1a 20 e7 20 74 75  |=feed+2..0. . tu|
00001d40  72 62 6f 20 8c 20 66 65  65 64 3d 66 65 65 64 2b  |rbo . feed=feed+|
00001d50  34 0d 07 3a 1b 20 e7 20  ac 20 69 64 6c 65 20 8c  |4..:. . . idle .|
00001d60  20 66 65 65 64 3d 66 65  65 64 2b 38 0d 07 44 1d  | feed=feed+8..D.|
00001d70  20 e7 20 72 65 76 65 72  73 65 20 8c 20 66 65 65  | . reverse . fee|
00001d80  64 3d 66 65 65 64 2b 31  36 0d 07 4e 0a 20 3d 66  |d=feed+16..N. =f|
00001d90  65 65 64 0d 07 58 06 20  3a 0d 07 62 28 20 f4 20  |eed..X. :..b( . |
00001da0  50 65 72 66 6f 72 6d 20  61 20 73 77 65 65 70 20  |Perform a sweep |
00001db0  74 6f 20 66 69 6e 64 20  61 6e 79 20 62 61 6c 6c  |to find any ball|
00001dc0  73 0d 07 6c 0b 20 dd f2  68 75 6e 74 0d 07 76 23  |s..l. ..hunt..v#|
00001dd0  20 f4 20 57 61 74 63 68  20 6f 75 74 20 69 66 20  | . Watch out if |
00001de0  74 6f 6f 20 6e 65 61 72  20 74 6f 20 6e 65 74 0d  |too near to net.|
00001df0  07 80 76 20 e7 20 28 66  61 24 3c 3e 22 42 22 20  |..v . (fa$<>"B" |
00001e00  80 20 66 72 65 71 61 3c  33 30 29 84 28 66 62 24  |. freqa<30).(fb$|
00001e10  3c 3e 22 42 22 20 80 20  66 72 65 71 62 3c 31 30  |<>"B" . freqb<10|
00001e20  29 84 28 66 63 24 3c 3e  22 42 22 20 80 20 66 72  |).(fc$<>"B" . fr|
00001e30  65 71 63 3c 31 30 29 20  8c 20 72 65 76 69 6e 67  |eqc<10) . reving|
00001e40  3d 35 3a 74 75 72 62 6f  3d b9 3a 72 65 76 65 72  |=5:turbo=.:rever|
00001e50  73 65 3d b9 3a 72 69 67  68 74 3d b9 3a 6c 65 66  |se=.:right=.:lef|
00001e60  74 3d b9 3a e1 0d 07 8a  6a 20 e7 20 72 65 76 69  |t=.:....j . revi|
00001e70  6e 67 3e 30 20 80 20 28  66 72 65 71 61 3c 31 35  |ng>0 . (freqa<15|
00001e80  30 20 84 20 66 72 65 71  62 3c 31 35 30 20 84 20  |0 . freqb<150 . |
00001e90  66 72 65 71 63 3c 31 35  30 29 20 8c 20 72 65 76  |freqc<150) . rev|
00001ea0  69 6e 67 3d 72 65 76 69  6e 67 2d 31 3a 74 75 72  |ing=reving-1:tur|
00001eb0  62 6f 3d b9 3a 72 65 76  65 72 73 65 3d b9 3a 72  |bo=.:reverse=.:r|
00001ec0  69 67 68 74 3d a3 3a 6c  65 66 74 3d b9 3a e1 0d  |ight=.:left=.:..|
00001ed0  07 94 0d 20 72 65 76 69  6e 67 3d 30 0d 07 9e 06  |... reving=0....|
00001ee0  20 3a 0d 07 a8 1a 20 f4  20 52 6f 74 61 74 65 20  | :.... . Rotate |
00001ef0  74 6f 20 66 61 63 65 20  62 61 6c 6c 0d 07 b2 24  |to face ball...$|
00001f00  20 f4 20 57 68 65 72 65  20 73 65 61 72 63 68 20  | . Where search |
00001f10  61 66 74 65 72 20 74 68  69 73 20 62 61 6c 6c 3f  |after this ball?|
00001f20  0d 07 bc 28 20 e7 20 28  66 62 24 3d 22 42 22 20  |...( . (fb$="B" |
00001f30  80 20 66 72 65 71 62 3e  31 35 30 29 20 8c 20 74  |. freqb>150) . t|
00001f40  65 6e 64 69 6e 67 3d 30  0d 07 c6 26 20 e7 20 66  |ending=0...& . f|
00001f50  63 24 3d 22 42 22 20 80  20 66 72 65 71 63 3e 31  |c$="B" . freqc>1|
00001f60  35 30 20 8c 20 74 65 6e  64 69 6e 67 3d 31 0d 07  |50 . tending=1..|
00001f70  d0 1f 20 f4 20 50 69 63  6b 20 62 65 73 74 20 62  |.. . Pick best b|
00001f80  61 6c 6c 20 74 6f 20 61  69 6d 20 61 74 0d 07 da  |all to aim at...|
00001f90  5a 20 64 69 73 74 3d 66  72 65 71 61 2a 30 2e 37  |Z dist=freqa*0.7|
00001fa0  35 3a e7 20 64 69 73 74  3e 66 72 65 71 62 20 80  |5:. dist>freqb .|
00001fb0  20 66 62 24 3d 22 42 22  20 80 20 28 66 72 65 71  | fb$="B" . (freq|
00001fc0  62 3c 66 72 65 71 63 20  84 20 66 63 24 3c 3e 22  |b<freqc . fc$<>"|
00001fd0  42 22 29 20 8c 20 73 74  65 65 72 3d 2d 31 3a 6c  |B") . steer=-1:l|
00001fe0  65 66 74 3d b9 3a e1 0d  07 e4 2f 20 e7 20 64 69  |eft=.:..../ . di|
00001ff0  73 74 3e 66 72 65 71 63  20 80 20 66 63 24 3d 22  |st>freqc . fc$="|
00002000  42 22 20 8c 20 73 74 65  65 72 3d 31 3a 72 69 67  |B" . steer=1:rig|
00002010  68 74 3d b9 3a e1 0d 07  ee 62 20 e7 20 66 61 24  |ht=.:....b . fa$|
00002020  3d 22 42 22 20 8c 20 6c  65 66 74 3d 28 73 74 65  |="B" . left=(ste|
00002030  65 72 3c 3e 31 29 3a 72  69 67 68 74 3d 28 73 74  |er<>1):right=(st|
00002040  65 65 72 3c 3e 2d 31 29  3a 73 74 65 65 72 3d 30  |eer<>-1):steer=0|
00002050  3a 73 65 61 72 63 68 69  6e 67 3d 73 65 61 72 63  |:searching=searc|
00002060  68 69 6e 67 2f 32 3a 74  75 72 62 6f 3d 66 72 65  |hing/2:turbo=fre|
00002070  71 61 3e 31 30 30 3a e1  0d 07 f8 22 20 e7 20 66  |qa>100:...." . f|
00002080  62 24 3d 22 42 22 20 8c  20 73 74 65 65 72 3d 2d  |b$="B" . steer=-|
00002090  31 3a 6c 65 66 74 3d b9  3a e1 0d 08 02 22 20 e7  |1:left=.:...." .|
000020a0  20 66 63 24 3d 22 42 22  20 8c 20 73 74 65 65 72  | fc$="B" . steer|
000020b0  3d 31 3a 72 69 67 68 74  3d b9 3a e1 0d 08 0c 06  |=1:right=.:.....|
000020c0  20 3a 0d 08 16 30 20 f4  20 49 66 20 6e 6f 20 62  | :...0 . If no b|
000020d0  61 6c 6c 20 69 6e 20 73  69 67 68 74 2c 20 63 6f  |all in sight, co|
000020e0  6e 74 69 6e 75 65 20 72  6f 74 61 74 69 6f 6e 2e  |ntinue rotation.|
000020f0  2e 2e 0d 08 20 36 20 73  65 61 72 63 68 69 6e 67  |.... 6 searching|
00002100  3d 73 65 61 72 63 68 69  6e 67 2b 31 3a 74 75 72  |=searching+1:tur|
00002110  62 6f 3d 28 73 65 61 72  63 68 69 6e 67 3e 35 29  |bo=(searching>5)|
00002120  3a 73 74 65 65 72 3d 30  0d 08 2a 2a 20 e7 20 28  |:steer=0..** . (|
00002130  74 65 6e 64 69 6e 67 20  80 20 31 29 3c 3e 30 20  |tending . 1)<>0 |
00002140  8c 20 72 69 67 68 74 3d  b9 20 8b 20 6c 65 66 74  |. right=. . left|
00002150  3d b9 0d 08 34 2a 20 e7  20 73 65 61 72 63 68 69  |=...4* . searchi|
00002160  6e 67 3d 35 20 8c 20 74  65 6e 64 69 6e 67 3d 28  |ng=5 . tending=(|
00002170  74 65 6e 64 69 6e 67 20  82 20 31 29 0d 08 3e 23  |tending . 1)..>#|
00002180  20 e7 20 73 65 61 72 63  68 69 6e 67 3e 35 30 20  | . searching>50 |
00002190  8c 20 73 74 61 67 65 3d  73 74 61 67 65 2b 31 0d  |. stage=stage+1.|
000021a0  08 48 06 20 e1 0d 08 52  06 20 3a 0d 08 5c 3c 20  |.H. ...R. :..\< |
000021b0  f4 20 46 69 6e 64 20 65  64 67 65 20 6f 66 20 6e  |. Find edge of n|
000021c0  65 74 20 61 6e 64 20 61  69 6d 20 66 6f 72 20 69  |et and aim for i|
000021d0  74 20 74 6f 20 6d 6f 76  65 20 74 6f 20 6f 74 68  |t to move to oth|
000021e0  65 72 20 73 69 64 65 0d  08 66 0e 20 dd f2 6d 6f  |er side..f. ..mo|
000021f0  76 65 6f 75 74 0d 08 70  23 20 f4 20 57 61 74 63  |veout..p# . Watc|
00002200  68 20 6f 75 74 20 69 66  20 74 6f 6f 20 6e 65 61  |h out if too nea|
00002210  72 20 74 6f 20 6e 65 74  0d 08 7a 7b 20 e7 20 28  |r to net..z{ . (|
00002220  66 72 65 71 61 3c 33 30  20 84 20 66 72 65 71 62  |freqa<30 . freqb|
00002230  3c 33 30 20 84 20 66 72  65 71 63 3c 33 30 29 20  |<30 . freqc<30) |
00002240  84 20 28 72 65 76 69 6e  67 20 80 20 28 66 72 65  |. (reving . (fre|
00002250  71 61 3c 37 35 20 84 20  66 72 65 71 62 3c 37 35  |qa<75 . freqb<75|
00002260  20 84 20 66 72 65 71 63  3c 37 35 29 29 20 8c 20  | . freqc<75)) . |
00002270  72 65 76 69 6e 67 3d b9  3a 72 65 76 65 72 73 65  |reving=.:reverse|
00002280  3d b9 3a 72 69 67 68 74  3d b9 3a 6c 65 66 74 3d  |=.:right=.:left=|
00002290  b9 3a e1 0d 08 84 0d 20  72 65 76 69 6e 67 3d a3  |.:..... reving=.|
000022a0  0d 08 8e 23 20 f4 20 49  66 20 62 61 6c 6c 20 69  |...# . If ball i|
000022b0  6e 20 73 69 67 68 74 2c  20 67 6f 20 67 65 74 20  |n sight, go get |
000022c0  69 74 21 0d 08 98 4b 20  e7 20 66 61 24 3d 22 42  |it!...K . fa$="B|
000022d0  22 20 84 20 66 62 24 3d  22 42 22 20 84 20 66 63  |" . fb$="B" . fc|
000022e0  24 3d 22 42 22 20 84 20  66 64 24 3d 22 42 22 20  |$="B" . fd$="B" |
000022f0  8c 20 73 74 61 67 65 3d  73 74 61 67 65 2d 31 3a  |. stage=stage-1:|
00002300  73 65 61 72 63 68 69 6e  67 3d 34 34 3a e1 0d 08  |searching=44:...|
00002310  a2 2c 20 f4 20 41 6c 69  67 6e 20 62 61 6c 6c 62  |., . Align ballb|
00002320  6f 74 20 74 6f 20 66 61  63 65 20 74 68 65 20 6e  |ot to face the n|
00002330  65 74 20 70 6f 73 74 2e  2e 2e 0d 08 ac 24 20 e7  |et post......$ .|
00002340  20 66 61 24 3d 22 4e 22  20 84 20 66 61 24 3d 22  | fa$="N" . fa$="|
00002350  50 22 20 8c 20 72 69 67  68 74 3d b9 3a e1 0d 08  |P" . right=.:...|
00002360  b6 25 20 e7 20 66 62 24  3c 3e 22 4e 22 20 80 20  |.% . fb$<>"N" . |
00002370  66 62 24 3c 3e 22 50 22  20 8c 20 6c 65 66 74 3d  |fb$<>"P" . left=|
00002380  b9 3a e1 0d 08 c0 2d 20  e7 20 66 62 24 3d 22 50  |.:....- . fb$="P|
00002390  22 20 80 20 66 72 65 71  62 3c 31 35 30 20 8c 20  |" . freqb<150 . |
000023a0  72 69 67 68 74 3d b9 3a  6e 65 61 72 3d 31 3a e1  |right=.:near=1:.|
000023b0  0d 08 ca 1b 20 74 75 72  62 6f 3d b9 3a 6c 65 66  |.... turbo=.:lef|
000023c0  74 3d b9 3a 72 69 67 68  74 3d b9 0d 08 d4 06 20  |t=.:right=..... |
000023d0  e1 0d 08 de 06 20 3a 0d  08 e8 47 20 f4 20 4e 65  |..... :...G . Ne|
000023e0  61 72 6c 79 20 74 68 65  72 65 2e 2e 2e 20 4a 75  |arly there... Ju|
000023f0  73 74 20 6e 65 65 64 20  61 20 6c 69 74 74 6c 65  |st need a little|
00002400  20 6e 75 64 67 65 20 69  6e 20 74 68 65 20 72 69  | nudge in the ri|
00002410  67 68 74 20 64 69 72 65  63 74 69 6f 6e 2e 0d 08  |ght direction...|
00002420  f2 12 20 dd f2 64 6f 6e  65 61 72 73 74 75 66 66  |.. ..donearstuff|
00002430  0d 08 fc 26 20 e7 20 66  72 65 71 61 3c 33 30 20  |...& . freqa<30 |
00002440  80 20 66 61 24 3c 3e 22  42 22 20 8c 20 72 69 67  |. fa$<>"B" . rig|
00002450  68 74 3d b9 3a e1 0d 09  06 2b 20 e7 20 6e 65 61  |ht=.:....+ . nea|
00002460  72 3d 31 20 80 20 66 64  24 3c 3e 22 55 22 20 8c  |r=1 . fd$<>"U" .|
00002470  20 6c 65 66 74 3d b9 3a  72 69 67 68 74 3d b9 3a  | left=.:right=.:|
00002480  e1 0d 09 10 32 20 6e 65  61 72 3d 6e 65 61 72 2b  |....2 near=near+|
00002490  31 3a 6c 65 66 74 3d b9  3a 72 69 67 68 74 3d 28  |1:left=.:right=(|
000024a0  6e 65 61 72 20 83 20 32  29 3d 31 3a 74 75 72 62  |near . 2)=1:turb|
000024b0  6f 3d b9 0d 09 1a 3b 20  e7 20 6e 65 61 72 3e 31  |o=....; . near>1|
000024c0  38 20 8c 20 6e 65 61 72  3d 30 3a 73 74 61 67 65  |8 . near=0:stage|
000024d0  3d 73 74 61 67 65 2b 31  3a 73 65 61 72 63 68 69  |=stage+1:searchi|
000024e0  6e 67 3d 30 3a 74 65 6e  64 69 6e 67 3d 31 0d 09  |ng=0:tending=1..|
000024f0  24 06 20 e1 0d 09 2e 06  20 3a 0d 09 38 3d 20 f4  |$. ..... :..8= .|
00002500  20 49 6e 69 74 69 61 6c  69 73 65 20 42 61 6c 6c  | Initialise Ball|
00002510  42 6f 74 20 76 61 72 69  61 62 6c 65 73 20 61 74  |Bot variables at|
00002520  20 74 68 65 20 62 65 67  69 6e 6e 69 6e 67 20 6f  | the beginning o|
00002530  66 20 61 20 72 75 6e 0d  09 42 0e 20 dd f2 73 65  |f a run..B. ..se|
00002540  74 75 70 62 62 0d 09 4c  2f 20 72 65 76 69 6e 67  |tupbb..L/ reving|
00002550  3d a3 3a 6c 65 66 74 3d  a3 3a 72 69 67 68 74 3d  |=.:left=.:right=|
00002560  a3 3a 73 65 61 72 63 68  69 6e 67 3d 30 3a 69 64  |.:searching=0:id|
00002570  6c 65 3d b9 0d 09 56 1d  20 6e 65 61 72 3d a3 3a  |le=...V. near=.:|
00002580  74 65 6e 64 69 6e 67 3d  31 3a 73 74 65 65 72 3d  |tending=1:steer=|
00002590  30 0d 09 60 06 20 e1 0d  09 6a 06 20 3a 0d 09 74  |0..`. ...j. :..t|
000025a0  0f 20 dd f2 72 65 6c 65  61 73 65 62 0d 09 7e 2d  |. ..releaseb..~-|
000025b0  20 f4 20 47 6f 74 20 61  6c 6c 20 74 68 65 20 62  | . Got all the b|
000025c0  61 6c 6c 73 2c 20 6e 6f  77 20 6a 75 73 74 20 64  |alls, now just d|
000025d0  75 6d 70 20 74 68 65 6d  21 0d 09 88 10 20 6e 65  |ump them!.... ne|
000025e0  61 72 3d 6e 65 61 72 2b  31 0d 09 92 1d 20 e7 20  |ar=near+1.... . |
000025f0  6e 65 61 72 3e 39 20 8c  20 69 64 6c 65 3d b9 3a  |near>9 . idle=.:|
00002600  6e 65 61 72 3d a3 0d 09  9c 06 20 e1 0d ff        |near=..... ...|
0000260e
BioBot/BBMotor2.m0
BioBot/BBMotor2.m1
BioBot/BBMotor2.m2
BioBot/BBMotor2.m4
BioBot/BBMotor2.m5