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

BioBot/BBMotor

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/BBMotor
Read OK:
File size: 275A bytes
Load address: FFFFFB47
Exec address: F98DDE24
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 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$
 1285 freqd=FNback(freq,dir-75,dir-45):fd$=ftype$
 1290 :
 1300 REM Add any relevant balls to readings (using hairy trigonometry)
 1310 :
 1320 FORball=0TO4
 1330 d%=SQR((ball(ball,0)-bbx)^2+(ball(ball,1)-bby)^2)
 1340 IF ball(ball,0)=0 THEN d%=9999
 1350 a=FNangle(ball(ball,0),ball(ball,1),bbx,bby)-dir:IFa>180 THEN a=a-360
 1360 IF ABS(a)<15 AND freqa>d% THEN freqa=d%:fa$="B"
 1370 IF a>-46 AND a<=-15 AND freqb>d% THEN freqb=d%:fb$="B"
 1380 IF a>=15 AND a<46 AND freqc>d% THEN freqc=d%:fc$="B"
 1385 IF a>-76 AND a<=-75 AND freqd>d% THEN freqd=d%:fd$="B"
 1390 NEXT
 1400 :
 1410 REM Update user displays
 1420 :
 1430 IF type$="2" THEN ENDPROC
 1440 PRINTTAB(0,0)INT((TIME-start)/6000);":";(INT((TIME-start)/100)MOD60);" "
 1450 PRINTTAB(0,31)fb$,fa$,fc$,stage,INT(searching),left,right," ",dir," ",near;
 1460 SOUND 1,-1,freqa/4,5:SOUND 2,-1,freqb/4,5:SOUND 3,-1,freqc/4,5
 1470 ENDPROC
 1480:
 1490 REM Calculate bearing of B from A
 1500 DEFFNangle(x1,y1,x2,y2)
 1510 IF y2=y1 THEN ang=90 ELSE ang=180*ATN((x2-x1)/(y2-y1))/PI
 1520 IF (y2>y1) THEN ang=ang+180
 1530 IF ang<0 THEN ang=ang+360
 1540 =ang MOD 360
 1550 :
 1560 REM Computer Monitor of BallBot's progress
 1570 DEFPROCcompmon
 1580 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"
 1590 IF idle THEN PRINTst$,INT((TIME-start)/6000);":";(INT((TIME-start)/100)MOD60)
 1600 IF TIME>start+36000 THEN idle=TRUE:PRINT"Time","****"
 1610 IFbbx>635ANDbbx<645ANDbby>105ANDbby<920THENidle=TRUE:PRINT"Crash","****"
 1620 IF idle THEN bbx=640:bby=950:dir=270:stage=0:PROCsetupbb:start=TIME:FORb=0TO4:ball(b,0)=RND(1280):ball(b,1)=RND(1024):NEXT
 1630 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
 1640 ENDPROC
 1650 :
 1660 REM BALLBOT ROBOTIC INTELLIGENCE MODULE
 1670 :
 1680 DEFFNai(freqa,freqb,freqc,freqd)
 1690 REM Artificial intelligence routines (ie. What Next??)
 1700 LOCALleft,right,turbo,reverse
 1710 left=FALSE:right=FALSE:turbo=FALSE:reverse=FALSE
 1720 :
 1730 REM What stage are we in? Hunt for balls or move to new area?
 1740 IF near<>0 AND stage<8 THEN PROCdonearstuff
 1750 IF near=0 AND (stage=0 OR stage=2) THEN PROChunt
 1760 IF near=0 AND (stage=1 OR stage=3) THEN PROCmoveout
 1770 IF stage=4 THEN PROCreleaseb
 1780 :
 1790 REM Prepare output into binary for transmission
 1800 feed=0:IF left THEN feed=feed+1
 1810 IF right THEN feed=feed+2
 1820 IF turbo THEN feed=feed+4
 1830 IF NOT idle THEN feed=feed+8
 1840 IF reverse THEN feed=feed+16
 1850 =feed
 1860 :
 1870 REM Perform a sweep to find any balls
 1880 DEFPROChunt
 1890 REM Watch out if too near to net
 1900 IF (freqa<30 OR freqb<10 OR freqc<10) AND (fa$<>"B" OR freqa>30) AND (fb$<>"B" OR freqb>30) AND (fc$<>"B" OR freqc>30) THEN reving=5:turbo=TRUE:reverse=TRUE:right=TRUE:left=TRUE:ENDPROC
 1910 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
 1920 reving=0
 1930 :
 1940 REM Rotate to face ball
 1950 REM Where search after this ball?
 1960 IF (fb$="B" AND freqb>150) THEN tending=0
 1970 IF fc$="B" AND freqc>150 THEN tending=1
 1980 REM Pick best ball to aim at
 1990 dist=freqa*0.75:IF dist>freqb AND fb$="B" AND (freqb<freqc OR fc$<>"B") THEN steer=-1:left=TRUE:ENDPROC
 2000 IF dist>freqc AND fc$="B" THEN steer=1:right=TRUE:ENDPROC
 2010 IF fa$="B" THEN left=(steer<>1):right=(steer<>-1):steer=0:searching=searching/2:turbo=freqa>100:ENDPROC
 2020 IF fb$="B" THEN steer=-1:left=TRUE:ENDPROC
 2030 IF fc$="B" THEN steer=1:right=TRUE:ENDPROC
 2040 :
 2050 REM If no ball in sight, continue rotation...
 2060 searching=searching+1:turbo=(searching>5):steer=0
 2070 IF (tending AND 1)<>0 THEN right=TRUE ELSE left=TRUE
 2080 IF searching=5 THEN tending=(tending EOR 1)
 2090 IF searching>50 THEN stage=stage+1
 2100 ENDPROC
 2110 :
 2120 REM Find edge of net and aim for it to move to other side
 2130 DEFPROCmoveout
 2140 REM Watch out if too near to net
 2150 IF (freqa<30 OR freqb<30 OR freqc<30) THEN reving=TRUE:turbo=TRUE:reverse=TRUE:left=NOT(freqb<(freqa*1.25)):right=(NOT(freqc<(freqa*1.25)))OR (NOT left):ENDPROC
 2160 IF reving AND (freqa<150 OR freqb<150 OR freqc<150) THEN turbo=TRUE:reverse=TRUE:left=NOT(freqb<(freqa*1.25)):right=(NOT(freqc<(freqa*1.25)))OR (NOT left):ENDPROC
 2170 reving=FALSE
 2180 REM Jump back to hunt mode if new ball seen
 2190 IF fb$="B" OR fa$="B" OR fc$="B" THEN stage=stage-1:searching=45:ENDPROC
 2200 REM Align ballbot to face the net post...
 2210 IF fa$="N" OR fa$="P" THEN right=TRUE:ENDPROC
 2220 IF fb$<>"N" AND fb$<>"P" THEN left=TRUE:steer=6:ENDPROC
 2230 IF fb$="P" AND freqb<100 AND fa$<>"P" AND fa$<>"N" THEN near=1:ENDPROC
 2240 IF steer>0 THEN steer=steer-1:left=TRUE: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 REM Watch out if too near to net
 2305 IF freqa<30 OR freqb<30 OR freqc<30 THEN near=0:ENDPROC
 2310 IF near<6 THEN right=TRUE:left=FALSE:near=near-(fa$="U"):ENDPROC
 2320 IF near<10 THEN left=TRUE:turbo=TRUE:right=TRUE:near=near+1:ENDPROC
 2330 IF near<15 THEN left=TRUE:turbo=TRUE:right=FALSE:near=near+1:ENDPROC
 2340 left=TRUE:right=TRUE:near=near+1
 2350 IF near>20 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 �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)
 :
( �ball=0�4
24 d%=�((ball(ball,0)-bbx)^2+(ball(ball,1)-bby)^2)
< � ball(ball,0)=0 � d%=9999
FE a=�angle(ball(ball,0),ball(ball,1),bbx,bby)-dir:�a>180 � a=a-360
P, � �(a)<15 � freqa>d% � freqa=d%:fa$="B"
Z3 � a>-46 � a<=-15 � freqb>d% � freqb=d%:fb$="B"
d1 � a>=15 � a<46 � freqc>d% � freqc=d%:fc$="B"
i3 � a>-76 � a<=-75 � freqd>d% � freqd=d%:fd$="B"
n �
x :
� � Update user displays
� :
� � type$="2" � �
�: �0,0)�((�-start)/6000);":";(�((�-start)/100)�60);" "
�G �0,31)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
" ��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"
6> � idle � �st$,�((�-start)/6000);":";(�((�-start)/100)�60)
@, � �>start+36000 � idle=�:�"Time","****"
J< �bbx>635�bbx<645�bby>105�bby<920�idle=�:�"Crash","****"
Tk � idle � bbx=640:bby=950:dir=270:stage=0:�setupbb:start=�:�b=0�4:ball(b,0)=�(1280):ball(b,1)=�(1024):�
^� � 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=�
h �
r :
|* � 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<8 � �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
 � turbo � feed=feed+4
& � � idle � feed=feed+8
0 � reverse � feed=feed+16
:
 =feed
D :
N( � Perform a sweep to find any balls
X ��hunt
b# � Watch out if too near to net
l� � (freqa<30 � freqb<10 � freqc<10) � (fa$<>"B" � freqa>30) � (fb$<>"B" � freqb>30) � (fc$<>"B" � freqc>30) � reving=5:turbo=�:reverse=�:right=�:left=�:�
vj � 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=�
 * � searching=5 � tending=(tending � 1)
*# � searching>50 � stage=stage+1
4 �
> :
H< � Find edge of net and aim for it to move to other side
R ��moveout
\# � Watch out if too near to net
f� � (freqa<30 � freqb<30 � freqc<30) � reving=�:turbo=�:reverse=�:left=�(freqb<(freqa*1.25)):right=(�(freqc<(freqa*1.25)))� (� left):�
p� � reving � (freqa<150 � freqb<150 � freqc<150) � turbo=�:reverse=�:left=�(freqb<(freqa*1.25)):right=(�(freqc<(freqa*1.25)))� (� left):�
z
 reving=�
�. � Jump back to hunt mode if new ball seen
�A � fb$="B" � fa$="B" � fc$="B" � stage=stage-1:searching=45:�
�, � Align ballbot to face the net post...
�$ � fa$="N" � fa$="P" � right=�:�
�- � fb$<>"N" � fb$<>"P" � left=�:steer=6:�
�; � fb$="P" � freqb<100 � fa$<>"P" � fa$<>"N" � near=1:�
�' � steer>0 � steer=steer-1:left=�:�
� turbo=�:left=�:right=�
� �
� :
�G � Nearly there... Just need a little nudge in the right direction.
� ��donearstuff
�# � Watch out if too near to net
	0 � freqa<30 � freqb<30 � freqc<30 � near=0:�
	4 � near<6 � right=�:left=�:near=near-(fa$="U"):�
	5 � near<10 � left=�:turbo=�:right=�:near=near+1:�
	5 � near<15 � left=�:turbo=�:right=�:near=near+1:�
	$ left=�:right=�:near=near+1
	.; � near>20 � 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 0e 20 f1 8a 30  2c 32 29 91 2d 54 0d 01  |..J. ..0,2).-T..|
000004c0  54 11 20 f5 20 fd 20 91  3e 28 54 2b 31 35 29 0d  |T. . . .>(T+15).|
000004d0  01 5e 08 20 fd 20 a3 0d  01 68 06 20 3a 0d 01 72  |.^. . ...h. :..r|
000004e0  18 20 f4 20 47 72 61 70  68 69 63 20 69 6e 74 65  |. . Graphic inte|
000004f0  72 66 61 63 65 0d 01 7c  0f 20 dd f2 64 72 61 77  |rface..|. ..draw|
00000500  66 75 6c 6c 0d 01 86 17  20 f4 20 53 65 74 20 75  |full.... . Set u|
00000510  70 20 63 6f 6e 73 74 61  6e 74 73 0d 01 90 11 20  |p constants.... |
00000520  ea 73 78 2c 73 79 2c 77  69 64 74 68 0d 01 9a 17  |.sx,sy,width....|
00000530  20 73 78 3d 31 3a 73 79  3d 32 3a 77 69 64 74 68  | sx=1:sy=2:width|
00000540  3d 31 30 0d 01 a4 14 20  f4 20 53 65 74 75 70 20  |=10.... . Setup |
00000550  43 6f 6c 6f 75 72 73 0d  01 ae 56 20 fb 30 2c 30  |Colours...V .0,0|
00000560  2c 36 34 2c 30 3a fb 31  2c 32 35 35 2c 30 2c 30  |,64,0:.1,255,0,0|
00000570  3a fb 32 2c 32 35 35 2c  32 35 35 2c 32 35 35 3a  |:.2,255,255,255:|
00000580  fb 33 2c 32 35 35 2c 30  2c 30 3a fb 34 2c 32 35  |.3,255,0,0:.4,25|
00000590  35 2c 32 35 35 2c 30 3a  fb 35 2c 30 2c 30 2c 30  |5,255,0:.5,0,0,0|
000005a0  3a fb 36 2c 32 35 35 2c  32 35 35 2c 30 0d 01 b8  |:.6,255,255,0...|
000005b0  06 20 3a 0d 01 c2 1c 20  f4 20 44 72 61 77 20 67  |. :.... . Draw g|
000005c0  72 65 65 6e 20 63 6f 75  72 74 20 61 72 65 61 0d  |reen court area.|
000005d0  01 cc 1f 20 db 3a e6 30  2c 30 3a c8 93 20 c8 90  |... .:.0,0:.. ..|
000005e0  20 30 2c 30 2c 31 32 37  39 2c 31 30 32 33 0d 01  | 0,0,1279,1023..|
000005f0  d6 26 20 f4 20 4d 61 72  6b 20 6f 75 74 20 77 68  |.& . Mark out wh|
00000600  69 74 65 20 6c 69 6e 65  73 20 6f 6e 74 6f 20 63  |ite lines onto c|
00000610  6f 75 72 74 0d 01 e0 ac  20 e6 30 2c 32 3a c8 93  |ourt.... .0,2:..|
00000620  20 c8 90 20 73 78 2f 28  32 33 2e 37 37 2b 32 2a  | .. sx/(23.77+2*|
00000630  73 78 29 2a 31 32 38 30  2c 73 79 2f 28 31 30 2e  |sx)*1280,sy/(10.|
00000640  39 37 2b 32 2a 73 79 29  2a 31 30 32 34 2c 32 33  |97+2*sy)*1024,23|
00000650  2e 37 37 2f 28 32 33 2e  37 37 2b 32 2a 73 78 29  |.77/(23.77+2*sx)|
00000660  2a 31 32 38 30 2c 77 69  64 74 68 3a c8 93 20 c8  |*1280,width:.. .|
00000670  90 20 73 78 2f 28 32 33  2e 37 37 2b 32 2a 73 78  |. sx/(23.77+2*sx|
00000680  29 2a 31 32 38 30 2c 28  31 2e 33 37 2b 73 79 29  |)*1280,(1.37+sy)|
00000690  2f 28 31 30 2e 39 37 2b  32 2a 73 79 29 2a 31 30  |/(10.97+2*sy)*10|
000006a0  32 34 2c 32 33 2e 37 37  2f 28 32 33 2e 37 37 2b  |24,23.77/(23.77+|
000006b0  32 2a 73 78 29 2a 31 32  38 30 2c 77 69 64 74 68  |2*sx)*1280,width|
000006c0  0d 01 ea ae 20 c8 93 20  c8 90 20 73 78 2f 28 32  |.... .. .. sx/(2|
000006d0  33 2e 37 37 2b 32 2a 73  78 29 2a 31 32 38 30 2c  |3.77+2*sx)*1280,|
000006e0  28 39 2e 36 2b 73 79 29  2f 28 31 30 2e 39 37 2b  |(9.6+sy)/(10.97+|
000006f0  32 2a 73 79 29 2a 31 30  32 34 2c 32 33 2e 37 37  |2*sy)*1024,23.77|
00000700  2f 28 32 33 2e 37 37 2b  32 2a 73 78 29 2a 31 32  |/(23.77+2*sx)*12|
00000710  38 30 2c 77 69 64 74 68  3a c8 93 20 c8 90 20 73  |80,width:.. .. s|
00000720  78 2f 28 32 33 2e 37 37  2b 32 2a 73 78 29 2a 31  |x/(23.77+2*sx)*1|
00000730  32 38 30 2c 28 31 30 2e  39 37 2b 73 79 29 2f 28  |280,(10.97+sy)/(|
00000740  31 30 2e 39 37 2b 32 2a  73 79 29 2a 31 30 32 34  |10.97+2*sy)*1024|
00000750  2c 32 33 2e 37 37 2f 28  32 33 2e 37 37 2b 32 2a  |,23.77/(23.77+2*|
00000760  73 78 29 2a 31 32 38 30  2c 77 69 64 74 68 0d 01  |sx)*1280,width..|
00000770  f4 5f 20 c8 93 20 c8 90  20 28 73 78 2b 35 2e 34  |._ .. .. (sx+5.4|
00000780  37 29 2f 28 32 33 2e 37  37 2b 32 2a 73 78 29 2a  |7)/(23.77+2*sx)*|
00000790  31 32 38 30 2c 28 73 79  2b 35 2e 34 39 29 2f 28  |1280,(sy+5.49)/(|
000007a0  31 30 2e 39 37 2b 32 2a  73 79 29 2a 31 30 32 34  |10.97+2*sy)*1024|
000007b0  2c 31 32 2e 38 2f 28 32  33 2e 37 37 2b 32 2a 73  |,12.8/(23.77+2*s|
000007c0  78 29 2a 31 32 38 30 2c  77 69 64 74 68 0d 01 fe  |x)*1280,width...|
000007d0  ae 20 c8 93 20 c8 90 20  73 78 2f 28 32 33 2e 37  |. .. .. sx/(23.7|
000007e0  37 2b 32 2a 73 78 29 2a  31 32 38 30 2c 73 79 2f  |7+2*sx)*1280,sy/|
000007f0  28 31 30 2e 39 37 2b 32  2a 73 79 29 2a 31 30 32  |(10.97+2*sy)*102|
00000800  34 2c 77 69 64 74 68 2c  31 30 2e 39 37 2f 28 31  |4,width,10.97/(1|
00000810  30 2e 39 37 2b 32 2a 73  79 29 2a 31 30 32 34 3a  |0.97+2*sy)*1024:|
00000820  c8 93 20 c8 90 20 28 73  78 2b 32 33 2e 37 37 29  |.. .. (sx+23.77)|
00000830  2f 28 32 33 2e 37 37 2b  32 2a 73 78 29 2a 31 32  |/(23.77+2*sx)*12|
00000840  38 30 2c 73 79 2f 28 31  30 2e 39 37 2b 32 2a 73  |80,sy/(10.97+2*s|
00000850  79 29 2a 31 30 32 34 2c  77 69 64 74 68 2c 31 30  |y)*1024,width,10|
00000860  2e 39 37 2f 28 31 30 2e  39 37 2b 32 2a 73 79 29  |.97/(10.97+2*sy)|
00000870  2a 31 30 32 34 2b 77 69  64 74 68 0d 02 08 ba 20  |*1024+width.... |
00000880  c8 93 20 c8 90 20 28 73  78 2b 35 2e 34 37 29 2f  |.. .. (sx+5.47)/|
00000890  28 32 33 2e 37 37 2b 32  2a 73 78 29 2a 31 32 38  |(23.77+2*sx)*128|
000008a0  30 2c 28 73 79 2b 31 2e  33 37 29 2f 28 31 30 2e  |0,(sy+1.37)/(10.|
000008b0  39 37 2b 32 2a 73 79 29  2a 31 30 32 34 2c 77 69  |97+2*sy)*1024,wi|
000008c0  64 74 68 2c 38 2e 32 33  2f 28 31 30 2e 39 37 2b  |dth,8.23/(10.97+|
000008d0  32 2a 73 79 29 2a 31 30  32 34 3a c8 93 20 c8 90  |2*sy)*1024:.. ..|
000008e0  20 28 73 78 2b 31 38 2e  33 29 2f 28 32 33 2e 37  | (sx+18.3)/(23.7|
000008f0  37 2b 32 2a 73 78 29 2a  31 32 38 30 2c 28 73 79  |7+2*sx)*1280,(sy|
00000900  2b 31 2e 33 37 29 2f 28  31 30 2e 39 37 2b 32 2a  |+1.37)/(10.97+2*|
00000910  73 79 29 2a 31 30 32 34  2c 77 69 64 74 68 2c 38  |sy)*1024,width,8|
00000920  2e 32 33 2f 28 31 30 2e  39 37 2b 32 2a 73 79 29  |.23/(10.97+2*sy)|
00000930  2a 31 30 32 34 0d 02 12  06 20 3a 0d 02 1c 0f 20  |*1024.... :.... |
00000940  f4 20 44 72 61 77 20 6e  65 74 0d 02 26 89 20 e6  |. Draw net..&. .|
00000950  30 2c 35 3a e3 6c 3d 31  30 30 b8 39 32 34 88 31  |0,5:.l=100.924.1|
00000960  30 3a ec 20 36 34 30 2c  6c 3a df 20 36 38 30 2c  |0:. 640,l:. 680,|
00000970  6c 2b 35 30 3a ed 3a e3  6c 3d 30 b8 34 30 88 31  |l+50:.:.l=0.40.1|
00000980  30 3a ec 20 36 34 30 2b  6c 2c 31 30 30 2b 6c 3a  |0:. 640+l,100+l:|
00000990  df 36 34 30 2b 6c 2c 39  32 34 2b 6c 3a ed 3a e3  |.640+l,924+l:.:.|
000009a0  6c 3d 30 b8 35 3a ec 36  33 37 2b 6c 2c 31 30 30  |l=0.5:.637+l,100|
000009b0  3a df 36 37 37 2b 6c 2c  31 35 30 3a ec 36 33 37  |:.677+l,150:.637|
000009c0  2b 6c 2c 39 32 34 3a df  36 37 37 2b 6c 2c 39 37  |+l,924:.677+l,97|
000009d0  34 3a ed 0d 02 30 1c 20  e6 30 2c 32 3a ec 20 36  |4:...0. .0,2:. 6|
000009e0  38 32 2c 31 34 32 3a df  36 38 32 2c 39 36 36 0d  |82,142:.682,966.|
000009f0  02 3a 0e 20 f2 64 72 61  77 6d 69 6e 69 0d 02 44  |.:. .drawmini..D|
00000a00  06 20 e1 0d 02 4e 06 20  3a 0d 02 58 1d 20 f4 20  |. ...N. :..X. . |
00000a10  44 72 61 77 20 62 61 6c  6c 62 6f 74 20 61 6e 64  |Draw ballbot and|
00000a20  20 62 61 6c 6c 73 0d 02  62 0f 20 dd f2 64 72 61  | balls..b. ..dra|
00000a30  77 6d 69 6e 69 0d 02 6c  14 20 e7 20 74 79 70 65  |wmini..l. . type|
00000a40  24 3d 22 32 22 20 8c 20  e1 0d 02 76 10 20 e6 33  |$="2" . ...v. .3|
00000a50  2c 34 3a e3 62 3d 30 b8  34 0d 02 80 42 20 e7 20  |,4:.b=0.4...B . |
00000a60  62 61 6c 6c 28 62 2c 30  29 3c 3e 30 20 84 20 62  |ball(b,0)<>0 . b|
00000a70  61 6c 6c 28 62 2c 31 29  3c 3e 30 20 8c 20 c8 93  |all(b,1)<>0 . ..|
00000a80  20 c8 90 20 62 61 6c 6c  28 62 2c 30 29 2c 62 61  | .. ball(b,0),ba|
00000a90  6c 6c 28 62 2c 31 29 2c  35 2c 35 0d 02 8a 06 20  |ll(b,1),5,5.... |
00000aa0  ed 0d 02 94 1b 20 e6 33  2c 33 3a c8 93 20 c8 90  |..... .3,3:.. ..|
00000ab0  20 62 62 78 2c 62 62 79  2c 35 2c 35 0d 02 9e 06  | bbx,bby,5,5....|
00000ac0  20 e1 0d 02 a8 06 20 3a  0d 02 b2 2a 20 f4 20 55  | ..... :...* . U|
00000ad0  73 65 72 20 69 6e 74 65  72 66 61 63 65 20 28 70  |ser interface (p|
00000ae0  75 74 74 69 6e 67 20 62  61 6c 6c 73 20 64 6f 77  |utting balls dow|
00000af0  6e 29 0d 02 bc 0b 20 dd  f2 75 73 65 72 0d 02 c6  |n).... ..user...|
00000b00  0d 20 c8 97 20 78 2c 79  2c 63 0d 02 d0 0e 20 e7  |. .. x,y,c.... .|
00000b10  20 63 3d 30 20 8c 20 e1  0d 02 da 61 20 e7 20 28  | c=0 . ....a . (|
00000b20  63 20 80 20 34 29 3c 3e  30 20 8c 20 f2 64 72 61  |c . 4)<>0 . .dra|
00000b30  77 6d 69 6e 69 3a 62 61  6c 6c 28 63 75 72 72 65  |wmini:ball(curre|
00000b40  6e 74 2c 30 29 3d 78 3a  62 61 6c 6c 28 63 75 72  |nt,0)=x:ball(cur|
00000b50  72 65 6e 74 2c 31 29 3d  79 3a 63 75 72 72 65 6e  |rent,1)=y:curren|
00000b60  74 3d 28 63 75 72 72 65  6e 74 2b 31 29 83 35 3a  |t=(current+1).5:|
00000b70  f2 64 72 61 77 6d 69 6e  69 0d 02 e4 2a 20 e7 20  |.drawmini...* . |
00000b80  28 63 20 80 20 32 29 3c  3e 30 20 8c 20 69 64 6c  |(c . 2)<>0 . idl|
00000b90  65 3d a3 3a 73 74 61 67  65 3d 30 3a 73 74 61 72  |e=.:stage=0:star|
00000ba0  74 3d 91 0d 02 ee 06 20  f5 0d 02 f8 0d 20 c8 97  |t=..... ..... ..|
00000bb0  20 78 2c 79 2c 63 0d 03  02 0a 20 fd 20 63 3d 30  | x,y,c.... . c=0|
00000bc0  0d 03 0c 06 20 e1 0d 03  16 06 20 3a 0d 03 20 27  |.... ..... :.. '|
00000bd0  20 f4 20 43 61 6c 63 75  6c 61 74 65 20 62 61 6c  | . Calculate bal|
00000be0  6c 62 6f 74 27 73 20 6e  65 77 20 70 6f 73 69 74  |lbot's new posit|
00000bf0  69 6f 6e 0d 03 2a 0d 20  dd f2 6d 6f 76 65 69 74  |ion..*. ..moveit|
00000c00  0d 03 34 0c 20 ea 20 73  70 65 65 64 0d 03 3e 0f  |..4. . speed..>.|
00000c10  20 e7 20 ac 20 6f 6e 20  8c 20 e1 0d 03 48 76 20  | . . on . ...Hv |
00000c20  e7 20 28 28 ac 20 72 65  76 65 72 73 65 29 20 80  |. ((. reverse) .|
00000c30  20 6c 65 66 74 20 80 20  28 ac 20 72 69 67 68 74  | left . (. right|
00000c40  29 29 20 84 20 28 72 65  76 65 72 73 65 20 80 20  |)) . (reverse . |
00000c50  72 69 67 68 74 20 80 20  28 ac 20 6c 65 66 74 29  |right . (. left)|
00000c60  29 20 8c 20 64 69 72 3d  64 69 72 2d 32 2e 35 2a  |) . dir=dir-2.5*|
00000c70  28 31 2d 33 2a 74 75 72  62 6f 29 3a 73 70 65 65  |(1-3*turbo):spee|
00000c80  64 3d 30 2e 31 2b 30 2e  32 2a 72 65 76 65 72 73  |d=0.1+0.2*revers|
00000c90  65 0d 03 52 76 20 e7 20  28 28 ac 20 72 65 76 65  |e..Rv . ((. reve|
00000ca0  72 73 65 29 20 80 20 72  69 67 68 74 20 80 20 28  |rse) . right . (|
00000cb0  ac 20 6c 65 66 74 29 29  20 84 20 28 72 65 76 65  |. left)) . (reve|
00000cc0  72 73 65 20 80 20 6c 65  66 74 20 80 20 28 ac 20  |rse . left . (. |
00000cd0  72 69 67 68 74 29 29 20  8c 20 64 69 72 3d 64 69  |right)) . dir=di|
00000ce0  72 2b 32 2e 35 2a 28 31  2d 33 2a 74 75 72 62 6f  |r+2.5*(1-3*turbo|
00000cf0  29 3a 73 70 65 65 64 3d  30 2e 31 2b 30 2e 32 2a  |):speed=0.1+0.2*|
00000d00  72 65 76 65 72 73 65 0d  03 5c 27 20 e7 20 6c 65  |reverse..\' . le|
00000d10  66 74 20 80 20 72 69 67  68 74 20 8c 20 73 70 65  |ft . right . spe|
00000d20  65 64 3d 31 2b 32 2a 72  65 76 65 72 73 65 0d 03  |ed=1+2*reverse..|
00000d30  66 06 20 3a 0d 03 70 29  20 f4 20 47 65 74 20 64  |f. :..p) . Get d|
00000d40  69 72 65 63 74 69 6f 6e  20 69 6e 20 72 61 6e 67  |irection in rang|
00000d50  65 20 30 3c 74 68 65 74  61 3c 33 36 30 0d 03 7a  |e 0<theta<360..z|
00000d60  1c 20 f5 20 e7 20 64 69  72 3c 30 20 8c 20 64 69  |. . . dir<0 . di|
00000d70  72 3d 64 69 72 2b 33 36  30 0d 03 84 1d 20 e7 20  |r=dir+360.... . |
00000d80  64 69 72 3e 3d 33 36 30  20 8c 20 64 69 72 3d 64  |dir>=360 . dir=d|
00000d90  69 72 2d 33 36 30 0d 03  8e 17 20 fd 20 64 69 72  |ir-360.... . dir|
00000da0  3e 3d 30 20 80 20 64 69  72 3c 33 36 30 0d 03 98  |>=0 . dir<360...|
00000db0  06 20 3a 0d 03 a2 3d 20  f2 64 72 61 77 6d 69 6e  |. :...= .drawmin|
00000dc0  69 3a 62 62 78 3d 62 62  78 2b 31 35 2a b5 28 af  |i:bbx=bbx+15*.(.|
00000dd0  2a 64 69 72 2f 31 38 30  29 2a 73 70 65 65 64 2a  |*dir/180)*speed*|
00000de0  28 2e 37 35 2a 2d 74 75  72 62 6f 2b 2e 32 35 29  |(.75*-turbo+.25)|
00000df0  0d 03 ac 33 20 62 62 79  3d 62 62 79 2b 32 30 2a  |...3 bby=bby+20*|
00000e00  9b 28 af 2a 64 69 72 2f  31 38 30 29 2a 73 70 65  |.(.*dir/180)*spe|
00000e10  65 64 2a 28 2e 37 35 2a  2d 74 75 72 62 6f 2b 2e  |ed*(.75*-turbo+.|
00000e20  32 35 29 0d 03 b6 51 20  e3 62 61 6c 6c 3d 30 b8  |25)...Q .ball=0.|
00000e30  34 3a e7 20 94 28 62 62  78 2d 62 61 6c 6c 28 62  |4:. .(bbx-ball(b|
00000e40  61 6c 6c 2c 30 29 29 3c  31 30 20 80 20 94 28 62  |all,0))<10 . .(b|
00000e50  62 79 2d 62 61 6c 6c 28  62 61 6c 6c 2c 31 29 29  |by-ball(ball,1))|
00000e60  3c 31 30 20 8c 20 62 61  6c 6c 28 62 61 6c 6c 2c  |<10 . ball(ball,|
00000e70  30 29 3d 30 0d 03 c0 10  20 ed 3a f2 64 72 61 77  |0)=0.... .:.draw|
00000e80  6d 69 6e 69 0d 03 ca 06  20 e1 0d 03 d4 06 20 3a  |mini.... ..... :|
00000e90  0d 03 de 3b 20 f4 20 43  61 6c 63 75 6c 61 74 65  |...; . Calculate|
00000ea0  20 62 61 6c 6c 62 6f 74  27 73 20 62 61 63 6b 67  | ballbot's backg|
00000eb0  72 6f 75 6e 64 20 65 63  68 6f 20 72 65 61 64 69  |round echo readi|
00000ec0  6e 67 20 28 2d 62 61 6c  6c 73 29 0d 03 e8 19 20  |ng (-balls).... |
00000ed0  dd a4 62 61 63 6b 28 66  72 65 71 2c 6d 69 6e 2c  |..back(freq,min,|
00000ee0  6d 61 78 29 0d 03 f2 2c  20 f4 20 47 65 74 20 61  |max)..., . Get a|
00000ef0  6e 67 75 6c 61 72 20 72  61 6e 67 65 20 69 6e 20  |ngular range in |
00000f00  66 6f 72 6d 20 30 3c 74  68 65 74 61 3c 33 36 30  |form 0<theta<360|
00000f10  0d 03 fc 2c 20 f4 20 53  65 74 20 75 70 20 69 6e  |..., . Set up in|
00000f20  69 74 69 61 6c 20 6f 75  74 73 69 64 65 20 72 61  |itial outside ra|
00000f30  6e 67 65 20 73 65 74 74  69 6e 67 73 0d 04 06 42  |nge settings...B|
00000f40  20 68 69 74 3d 30 3a 64  69 73 74 3d 39 39 39 39  | hit=0:dist=9999|
00000f50  3a 64 69 73 74 61 3d 39  39 39 39 3a 68 69 74 61  |:dista=9999:hita|
00000f60  3d 30 3a f4 20 4c 4f 43  41 4c 20 68 69 74 2c 64  |=0:. LOCAL hit,d|
00000f70  69 73 74 2c 68 69 74 61  2c 64 69 73 74 61 0d 04  |ist,hita,dista..|
00000f80  10 38 20 f4 20 49 66 20  73 74 72 61 69 67 68 74  |.8 . If straight|
00000f90  20 61 74 20 6e 65 74 20  69 73 20 69 6e 20 72 61  | at net is in ra|
00000fa0  6e 67 65 2c 20 77 69 6c  6c 20 62 65 20 73 68 6f  |nge, will be sho|
00000fb0  72 74 65 73 74 2e 0d 04  1a 77 20 e7 28 62 62 78  |rtest....w .(bbx|
00000fc0  3c 36 34 30 80 6d 69 6e  3c 3d 39 30 80 6d 61 78  |<640.min<=90.max|
00000fd0  3e 3d 39 30 29 84 28 62  62 78 3e 36 34 30 80 6d  |>=90).(bbx>640.m|
00000fe0  69 6e 3c 3d 32 37 30 80  6d 61 78 3e 3d 32 37 30  |in<=270.max>=270|
00000ff0  29 20 80 20 28 62 62 79  3e 31 30 30 20 80 20 62  |) . (bby>100 . b|
00001000  62 79 3c 39 32 33 29 20  8c 20 68 69 74 3d 62 62  |by<923) . hit=bb|
00001010  79 3a 64 69 73 74 3d 94  28 62 62 78 2d 36 34 30  |y:dist=.(bbx-640|
00001020  29 3a 6d 69 6e 3d 30 3a  6d 61 78 3d 30 0d 04 24  |):min=0:max=0..$|
00001030  2f 20 f4 20 4f 74 68 65  72 77 69 73 65 20 66 69  |/ . Otherwise fi|
00001040  6e 64 20 73 68 6f 72 74  65 73 74 20 65 78 74 72  |nd shortest extr|
00001050  65 6d 65 20 6f 66 20 72  61 6e 67 65 0d 04 2e 53  |eme of range...S|
00001060  20 e7 20 b5 28 af 2a 6d  69 6e 2f 31 38 30 29 3c  | . .(.*min/180)<|
00001070  3e 30 20 8c 20 64 69 73  74 3d 28 36 34 30 2d 62  |>0 . dist=(640-b|
00001080  62 78 29 2f b5 28 af 2a  6d 69 6e 2f 31 38 30 29  |bx)/.(.*min/180)|
00001090  3a 68 69 74 3d 62 62 79  2b 28 36 34 30 2d 62 62  |:hit=bby+(640-bb|
000010a0  78 29 2f b7 28 af 2a 6d  69 6e 2f 31 38 30 29 0d  |x)/.(.*min/180).|
000010b0  04 38 55 20 e7 20 b5 28  af 2a 6d 61 78 2f 31 38  |.8U . .(.*max/18|
000010c0  30 29 3c 3e 30 20 8c 20  64 69 73 74 61 3d 28 36  |0)<>0 . dista=(6|
000010d0  34 30 2d 62 62 78 29 2f  b5 28 af 2a 6d 61 78 2f  |40-bbx)/.(.*max/|
000010e0  31 38 30 29 3a 68 69 74  61 3d 62 62 79 2b 28 36  |180):hita=bby+(6|
000010f0  34 30 2d 62 62 78 29 2f  b7 28 af 2a 6d 61 78 2f  |40-bbx)/.(.*max/|
00001100  31 38 30 29 0d 04 42 2c  20 f4 20 4a 75 73 74 20  |180)..B, . Just |
00001110  63 68 65 63 6b 20 69 66  20 70 6f 73 74 20 69 6e  |check if post in|
00001120  20 6d 69 64 64 6c 65 20  6f 66 20 72 61 6e 67 65  | middle of range|
00001130  0d 04 4c 64 20 e7 20 62  62 78 3c 36 34 30 20 80  |..Ld . bbx<640 .|
00001140  20 68 69 74 3e 31 30 30  20 80 20 28 68 69 74 61  | hit>100 . (hita|
00001150  3c 31 30 30 20 84 20 64  69 73 74 61 3c 30 29 20  |<100 . dista<0) |
00001160  80 20 64 69 73 74 3e 30  20 8c 20 68 69 74 61 3d  |. dist>0 . hita=|
00001170  31 30 30 3a 64 69 73 74  61 3d b6 28 28 62 62 78  |100:dista=.((bbx|
00001180  2d 36 34 30 29 5e 32 2b  28 62 62 79 2d 31 30 30  |-640)^2+(bby-100|
00001190  29 5e 32 29 0d 04 56 62  20 e7 20 62 62 78 3c 36  |)^2)..Vb . bbx<6|
000011a0  34 30 20 80 20 68 69 74  61 3c 39 32 33 20 80 20  |40 . hita<923 . |
000011b0  28 68 69 74 3e 39 32 33  20 84 20 64 69 73 74 3c  |(hit>923 . dist<|
000011c0  30 29 20 80 20 64 69 73  74 61 3e 30 20 8c 20 68  |0) . dista>0 . h|
000011d0  69 74 3d 39 32 33 3a 64  69 73 74 3d b6 28 28 62  |it=923:dist=.((b|
000011e0  62 78 2d 36 34 30 29 5e  32 2b 28 62 62 79 2d 39  |bx-640)^2+(bby-9|
000011f0  32 33 29 5e 32 29 0d 04  60 62 20 e7 20 62 62 78  |23)^2)..`b . bbx|
00001200  3e 36 34 30 20 80 20 68  69 74 61 3e 31 30 30 20  |>640 . hita>100 |
00001210  80 20 28 68 69 74 3c 31  30 30 20 84 20 64 69 73  |. (hit<100 . dis|
00001220  74 3c 30 29 20 80 20 64  69 73 74 61 3e 30 20 8c  |t<0) . dista>0 .|
00001230  20 68 69 74 3d 31 30 30  3a 64 69 73 74 3d b6 28  | hit=100:dist=.(|
00001240  28 62 62 78 2d 36 34 30  29 5e 32 2b 28 62 62 79  |(bbx-640)^2+(bby|
00001250  2d 31 30 30 29 5e 32 29  0d 04 6a 64 20 e7 20 62  |-100)^2)..jd . b|
00001260  62 78 3e 36 34 30 20 80  20 68 69 74 3c 39 32 33  |bx>640 . hit<923|
00001270  20 80 20 28 68 69 74 61  3e 39 32 33 20 84 20 64  | . (hita>923 . d|
00001280  69 73 74 61 3c 30 29 20  80 20 64 69 73 74 3e 30  |ista<0) . dist>0|
00001290  20 8c 20 68 69 74 61 3d  39 32 33 3a 64 69 73 74  | . hita=923:dist|
000012a0  61 3d b6 28 28 62 62 78  2d 36 34 30 29 5e 32 2b  |a=.((bbx-640)^2+|
000012b0  28 62 62 79 2d 39 32 33  29 5e 32 29 0d 04 74 1d  |(bby-923)^2)..t.|
000012c0  20 f4 20 50 69 63 6b 20  62 65 73 74 20 74 6f 20  | . Pick best to |
000012d0  73 65 6e 64 20 6f 66 66  21 0d 04 7e 48 20 e7 20  |send off!..~H . |
000012e0  64 69 73 74 3c 30 20 84  20 28 64 69 73 74 61 3c  |dist<0 . (dista<|
000012f0  64 69 73 74 20 80 20 68  69 74 61 3e 31 30 30 20  |dist . hita>100 |
00001300  80 20 68 69 74 61 3c 39  32 33 29 20 8c 20 64 69  |. hita<923) . di|
00001310  73 74 3d 64 69 73 74 61  3a 68 69 74 3d 68 69 74  |st=dista:hit=hit|
00001320  61 0d 04 88 3b 20 e7 20  68 69 74 3e 39 32 33 20  |a...; . hit>923 |
00001330  84 20 68 69 74 3c 31 30  30 20 84 20 64 69 73 74  |. hit<100 . dist|
00001340  3c 30 20 8c 20 66 74 79  70 65 24 3d 22 55 22 3a  |<0 . ftype$="U":|
00001350  3d 66 72 65 71 2b b3 28  36 29 2d 33 0d 04 92 2b  |=freq+.(6)-3...+|
00001360  20 e7 20 68 69 74 3e 39  30 30 20 84 20 68 69 74  | . hit>900 . hit|
00001370  3c 31 32 33 20 8c 20 66  74 79 70 65 24 3d 22 50  |<123 . ftype$="P|
00001380  22 3a 3d 64 69 73 74 0d  04 9c 0f 20 66 74 79 70  |":=dist.... ftyp|
00001390  65 24 3d 22 4e 22 0d 04  a6 0a 20 3d 64 69 73 74  |e$="N".... =dist|
000013a0  0d 04 b0 06 20 3a 0d 04  ba 32 20 f4 20 43 61 6c  |.... :...2 . Cal|
000013b0  63 75 6c 61 74 65 20 42  61 6c 6c 62 6f 74 27 73  |culate Ballbot's|
000013c0  20 72 65 61 64 69 6e 67  73 20 28 4d 41 49 4e 20  | readings (MAIN |
000013d0  52 4f 55 54 49 4e 45 29  0d 04 c4 06 20 3a 0d 04  |ROUTINE).... :..|
000013e0  ce 0c 20 dd f2 73 65 6e  73 65 0d 04 d8 2a 20 f4  |.. ..sense...* .|
000013f0  20 47 65 74 20 62 61 63  6b 67 72 6f 75 6e 64 20  | Get background |
00001400  72 65 61 64 69 6e 67 73  20 66 72 6f 6d 20 46 4e  |readings from FN|
00001410  62 61 63 6b 0d 04 e2 15  20 66 72 65 71 3d b3 28  |back.... freq=.(|
00001420  32 35 30 29 2b 31 35 30  30 0d 04 ec 2f 20 66 72  |250)+1500.../ fr|
00001430  65 71 61 3d a4 62 61 63  6b 28 66 72 65 71 2c 64  |eqa=.back(freq,d|
00001440  69 72 2d 31 35 2c 64 69  72 2b 31 35 29 3a 66 61  |ir-15,dir+15):fa|
00001450  24 3d 66 74 79 70 65 24  0d 04 f6 2f 20 66 72 65  |$=ftype$.../ fre|
00001460  71 62 3d a4 62 61 63 6b  28 66 72 65 71 2c 64 69  |qb=.back(freq,di|
00001470  72 2d 34 35 2c 64 69 72  2d 31 35 29 3a 66 62 24  |r-45,dir-15):fb$|
00001480  3d 66 74 79 70 65 24 0d  05 00 2f 20 66 72 65 71  |=ftype$.../ freq|
00001490  63 3d a4 62 61 63 6b 28  66 72 65 71 2c 64 69 72  |c=.back(freq,dir|
000014a0  2b 31 35 2c 64 69 72 2b  34 35 29 3a 66 63 24 3d  |+15,dir+45):fc$=|
000014b0  66 74 79 70 65 24 0d 05  05 2f 20 66 72 65 71 64  |ftype$.../ freqd|
000014c0  3d a4 62 61 63 6b 28 66  72 65 71 2c 64 69 72 2d  |=.back(freq,dir-|
000014d0  37 35 2c 64 69 72 2d 34  35 29 3a 66 64 24 3d 66  |75,dir-45):fd$=f|
000014e0  74 79 70 65 24 0d 05 0a  06 20 3a 0d 05 14 44 20  |type$.... :...D |
000014f0  f4 20 41 64 64 20 61 6e  79 20 72 65 6c 65 76 61  |. Add any releva|
00001500  6e 74 20 62 61 6c 6c 73  20 74 6f 20 72 65 61 64  |nt balls to read|
00001510  69 6e 67 73 20 28 75 73  69 6e 67 20 68 61 69 72  |ings (using hair|
00001520  79 20 74 72 69 67 6f 6e  6f 6d 65 74 72 79 29 0d  |y trigonometry).|
00001530  05 1e 06 20 3a 0d 05 28  0e 20 e3 62 61 6c 6c 3d  |... :..(. .ball=|
00001540  30 b8 34 0d 05 32 34 20  64 25 3d b6 28 28 62 61  |0.4..24 d%=.((ba|
00001550  6c 6c 28 62 61 6c 6c 2c  30 29 2d 62 62 78 29 5e  |ll(ball,0)-bbx)^|
00001560  32 2b 28 62 61 6c 6c 28  62 61 6c 6c 2c 31 29 2d  |2+(ball(ball,1)-|
00001570  62 62 79 29 5e 32 29 0d  05 3c 1f 20 e7 20 62 61  |bby)^2)..<. . ba|
00001580  6c 6c 28 62 61 6c 6c 2c  30 29 3d 30 20 8c 20 64  |ll(ball,0)=0 . d|
00001590  25 3d 39 39 39 39 0d 05  46 45 20 61 3d a4 61 6e  |%=9999..FE a=.an|
000015a0  67 6c 65 28 62 61 6c 6c  28 62 61 6c 6c 2c 30 29  |gle(ball(ball,0)|
000015b0  2c 62 61 6c 6c 28 62 61  6c 6c 2c 31 29 2c 62 62  |,ball(ball,1),bb|
000015c0  78 2c 62 62 79 29 2d 64  69 72 3a e7 61 3e 31 38  |x,bby)-dir:.a>18|
000015d0  30 20 8c 20 61 3d 61 2d  33 36 30 0d 05 50 2c 20  |0 . a=a-360..P, |
000015e0  e7 20 94 28 61 29 3c 31  35 20 80 20 66 72 65 71  |. .(a)<15 . freq|
000015f0  61 3e 64 25 20 8c 20 66  72 65 71 61 3d 64 25 3a  |a>d% . freqa=d%:|
00001600  66 61 24 3d 22 42 22 0d  05 5a 33 20 e7 20 61 3e  |fa$="B"..Z3 . a>|
00001610  2d 34 36 20 80 20 61 3c  3d 2d 31 35 20 80 20 66  |-46 . a<=-15 . f|
00001620  72 65 71 62 3e 64 25 20  8c 20 66 72 65 71 62 3d  |reqb>d% . freqb=|
00001630  64 25 3a 66 62 24 3d 22  42 22 0d 05 64 31 20 e7  |d%:fb$="B"..d1 .|
00001640  20 61 3e 3d 31 35 20 80  20 61 3c 34 36 20 80 20  | a>=15 . a<46 . |
00001650  66 72 65 71 63 3e 64 25  20 8c 20 66 72 65 71 63  |freqc>d% . freqc|
00001660  3d 64 25 3a 66 63 24 3d  22 42 22 0d 05 69 33 20  |=d%:fc$="B"..i3 |
00001670  e7 20 61 3e 2d 37 36 20  80 20 61 3c 3d 2d 37 35  |. a>-76 . a<=-75|
00001680  20 80 20 66 72 65 71 64  3e 64 25 20 8c 20 66 72  | . freqd>d% . fr|
00001690  65 71 64 3d 64 25 3a 66  64 24 3d 22 42 22 0d 05  |eqd=d%:fd$="B"..|
000016a0  6e 06 20 ed 0d 05 78 06  20 3a 0d 05 82 1b 20 f4  |n. ...x. :.... .|
000016b0  20 55 70 64 61 74 65 20  75 73 65 72 20 64 69 73  | Update user dis|
000016c0  70 6c 61 79 73 0d 05 8c  06 20 3a 0d 05 96 14 20  |plays.... :.... |
000016d0  e7 20 74 79 70 65 24 3d  22 32 22 20 8c 20 e1 0d  |. type$="2" . ..|
000016e0  05 a0 3a 20 f1 8a 30 2c  30 29 a8 28 28 91 2d 73  |..: ..0,0).((.-s|
000016f0  74 61 72 74 29 2f 36 30  30 30 29 3b 22 3a 22 3b  |tart)/6000);":";|
00001700  28 a8 28 28 91 2d 73 74  61 72 74 29 2f 31 30 30  |(.((.-start)/100|
00001710  29 83 36 30 29 3b 22 20  22 0d 05 aa 47 20 f1 8a  |).60);" "...G ..|
00001720  30 2c 33 31 29 66 62 24  2c 66 61 24 2c 66 63 24  |0,31)fb$,fa$,fc$|
00001730  2c 73 74 61 67 65 2c a8  28 73 65 61 72 63 68 69  |,stage,.(searchi|
00001740  6e 67 29 2c 6c 65 66 74  2c 72 69 67 68 74 2c 22  |ng),left,right,"|
00001750  20 22 2c 64 69 72 2c 22  20 22 2c 6e 65 61 72 3b  | ",dir," ",near;|
00001760  0d 05 b4 37 20 d4 20 31  2c 2d 31 2c 66 72 65 71  |...7 . 1,-1,freq|
00001770  61 2f 34 2c 35 3a d4 20  32 2c 2d 31 2c 66 72 65  |a/4,5:. 2,-1,fre|
00001780  71 62 2f 34 2c 35 3a d4  20 33 2c 2d 31 2c 66 72  |qb/4,5:. 3,-1,fr|
00001790  65 71 63 2f 34 2c 35 0d  05 be 06 20 e1 0d 05 c8  |eqc/4,5.... ....|
000017a0  05 3a 0d 05 d2 24 20 f4  20 43 61 6c 63 75 6c 61  |.:...$ . Calcula|
000017b0  74 65 20 62 65 61 72 69  6e 67 20 6f 66 20 42 20  |te bearing of B |
000017c0  66 72 6f 6d 20 41 0d 05  dc 19 20 dd a4 61 6e 67  |from A.... ..ang|
000017d0  6c 65 28 78 31 2c 79 31  2c 78 32 2c 79 32 29 0d  |le(x1,y1,x2,y2).|
000017e0  05 e6 34 20 e7 20 79 32  3d 79 31 20 8c 20 61 6e  |..4 . y2=y1 . an|
000017f0  67 3d 39 30 20 8b 20 61  6e 67 3d 31 38 30 2a 99  |g=90 . ang=180*.|
00001800  28 28 78 32 2d 78 31 29  2f 28 79 32 2d 79 31 29  |((x2-x1)/(y2-y1)|
00001810  29 2f af 0d 05 f0 1c 20  e7 20 28 79 32 3e 79 31  |)/..... . (y2>y1|
00001820  29 20 8c 20 61 6e 67 3d  61 6e 67 2b 31 38 30 0d  |) . ang=ang+180.|
00001830  05 fa 1a 20 e7 20 61 6e  67 3c 30 20 8c 20 61 6e  |... . ang<0 . an|
00001840  67 3d 61 6e 67 2b 33 36  30 0d 06 04 0f 20 3d 61  |g=ang+360.... =a|
00001850  6e 67 20 83 20 33 36 30  0d 06 0e 06 20 3a 0d 06  |ng . 360.... :..|
00001860  18 2d 20 f4 20 43 6f 6d  70 75 74 65 72 20 4d 6f  |.- . Computer Mo|
00001870  6e 69 74 6f 72 20 6f 66  20 42 61 6c 6c 42 6f 74  |nitor of BallBot|
00001880  27 73 20 70 72 6f 67 72  65 73 73 0d 06 22 0e 20  |'s progress..". |
00001890  dd f2 63 6f 6d 70 6d 6f  6e 0d 06 2c 72 20 e7 20  |..compmon..,r . |
000018a0  69 64 6c 65 20 80 20 28  62 61 6c 6c 28 30 2c 30  |idle . (ball(0,0|
000018b0  29 3c 3e 30 20 84 20 62  61 6c 6c 28 31 2c 30 29  |)<>0 . ball(1,0)|
000018c0  3c 3e 30 20 84 20 62 61  6c 6c 28 32 2c 30 29 3c  |<>0 . ball(2,0)<|
000018d0  3e 30 20 84 20 62 61 6c  6c 28 33 2c 30 29 3c 3e  |>0 . ball(3,0)<>|
000018e0  30 20 84 20 62 61 6c 6c  28 34 2c 30 29 3c 3e 30  |0 . ball(4,0)<>0|
000018f0  29 20 8c 20 73 74 24 3d  22 46 61 69 6c 22 20 8b  |) . st$="Fail" .|
00001900  20 73 74 24 3d 22 50 61  73 73 22 0d 06 36 3e 20  | st$="Pass"..6> |
00001910  e7 20 69 64 6c 65 20 8c  20 f1 73 74 24 2c a8 28  |. idle . .st$,.(|
00001920  28 91 2d 73 74 61 72 74  29 2f 36 30 30 30 29 3b  |(.-start)/6000);|
00001930  22 3a 22 3b 28 a8 28 28  91 2d 73 74 61 72 74 29  |":";(.((.-start)|
00001940  2f 31 30 30 29 83 36 30  29 0d 06 40 2c 20 e7 20  |/100).60)..@, . |
00001950  91 3e 73 74 61 72 74 2b  33 36 30 30 30 20 8c 20  |.>start+36000 . |
00001960  69 64 6c 65 3d b9 3a f1  22 54 69 6d 65 22 2c 22  |idle=.:."Time","|
00001970  2a 2a 2a 2a 22 0d 06 4a  3c 20 e7 62 62 78 3e 36  |****"..J< .bbx>6|
00001980  33 35 80 62 62 78 3c 36  34 35 80 62 62 79 3e 31  |35.bbx<645.bby>1|
00001990  30 35 80 62 62 79 3c 39  32 30 8c 69 64 6c 65 3d  |05.bby<920.idle=|
000019a0  b9 3a f1 22 43 72 61 73  68 22 2c 22 2a 2a 2a 2a  |.:."Crash","****|
000019b0  22 0d 06 54 6b 20 e7 20  69 64 6c 65 20 8c 20 62  |"..Tk . idle . b|
000019c0  62 78 3d 36 34 30 3a 62  62 79 3d 39 35 30 3a 64  |bx=640:bby=950:d|
000019d0  69 72 3d 32 37 30 3a 73  74 61 67 65 3d 30 3a f2  |ir=270:stage=0:.|
000019e0  73 65 74 75 70 62 62 3a  73 74 61 72 74 3d 91 3a  |setupbb:start=.:|
000019f0  e3 62 3d 30 b8 34 3a 62  61 6c 6c 28 62 2c 30 29  |.b=0.4:ball(b,0)|
00001a00  3d b3 28 31 32 38 30 29  3a 62 61 6c 6c 28 62 2c  |=.(1280):ball(b,|
00001a10  31 29 3d b3 28 31 30 32  34 29 3a ed 0d 06 5e af  |1)=.(1024):...^.|
00001a20  20 e7 20 69 64 6c 65 20  8c 20 f1 22 5b 22 3b 62  | . idle . ."[";b|
00001a30  61 6c 6c 28 30 2c 30 29  3b 22 2c 22 3b 62 61 6c  |all(0,0);",";bal|
00001a40  6c 28 30 2c 31 29 3b 22  5d 20 5b 22 3b 62 61 6c  |l(0,1);"] [";bal|
00001a50  6c 28 31 2c 30 29 3b 22  2c 22 3b 62 61 6c 6c 28  |l(1,0);",";ball(|
00001a60  31 2c 31 29 3b 22 5d 20  5b 22 3b 62 61 6c 6c 28  |1,1);"] [";ball(|
00001a70  32 2c 30 29 3b 22 2c 22  3b 62 61 6c 6c 28 32 2c  |2,0);",";ball(2,|
00001a80  31 29 3b 22 5d 20 5b 22  3b 62 61 6c 6c 28 33 2c  |1);"] [";ball(3,|
00001a90  30 29 3b 22 2c 22 3b 62  61 6c 6c 28 33 2c 31 29  |0);",";ball(3,1)|
00001aa0  3b 22 5d 20 5b 22 3b 62  61 6c 6c 28 34 2c 30 29  |;"] [";ball(4,0)|
00001ab0  3b 22 2c 22 3b 62 61 6c  6c 28 34 2c 31 29 3b 22  |;",";ball(4,1);"|
00001ac0  5d 22 2c 3b 3a 69 64 6c  65 3d a3 0d 06 68 06 20  |]",;:idle=...h. |
00001ad0  e1 0d 06 72 06 20 3a 0d  06 7c 2a 20 f4 20 42 41  |...r. :..|* . BA|
00001ae0  4c 4c 42 4f 54 20 52 4f  42 4f 54 49 43 20 49 4e  |LLBOT ROBOTIC IN|
00001af0  54 45 4c 4c 49 47 45 4e  43 45 20 4d 4f 44 55 4c  |TELLIGENCE MODUL|
00001b00  45 0d 06 86 06 20 3a 0d  06 90 22 20 dd a4 61 69  |E.... :..." ..ai|
00001b10  28 66 72 65 71 61 2c 66  72 65 71 62 2c 66 72 65  |(freqa,freqb,fre|
00001b20  71 63 2c 66 72 65 71 64  29 0d 06 9a 39 20 f4 20  |qc,freqd)...9 . |
00001b30  41 72 74 69 66 69 63 69  61 6c 20 69 6e 74 65 6c  |Artificial intel|
00001b40  6c 69 67 65 6e 63 65 20  72 6f 75 74 69 6e 65 73  |ligence routines|
00001b50  20 28 69 65 2e 20 57 68  61 74 20 4e 65 78 74 3f  | (ie. What Next?|
00001b60  3f 29 0d 06 a4 1e 20 ea  6c 65 66 74 2c 72 69 67  |?).... .left,rig|
00001b70  68 74 2c 74 75 72 62 6f  2c 72 65 76 65 72 73 65  |ht,turbo,reverse|
00001b80  0d 06 ae 25 20 6c 65 66  74 3d a3 3a 72 69 67 68  |...% left=.:righ|
00001b90  74 3d a3 3a 74 75 72 62  6f 3d a3 3a 72 65 76 65  |t=.:turbo=.:reve|
00001ba0  72 73 65 3d a3 0d 06 b8  06 20 3a 0d 06 c2 40 20  |rse=..... :...@ |
00001bb0  f4 20 57 68 61 74 20 73  74 61 67 65 20 61 72 65  |. What stage are|
00001bc0  20 77 65 20 69 6e 3f 20  48 75 6e 74 20 66 6f 72  | we in? Hunt for|
00001bd0  20 62 61 6c 6c 73 20 6f  72 20 6d 6f 76 65 20 74  | balls or move t|
00001be0  6f 20 6e 65 77 20 61 72  65 61 3f 0d 06 cc 27 20  |o new area?...' |
00001bf0  e7 20 6e 65 61 72 3c 3e  30 20 80 20 73 74 61 67  |. near<>0 . stag|
00001c00  65 3c 38 20 8c 20 f2 64  6f 6e 65 61 72 73 74 75  |e<8 . .donearstu|
00001c10  66 66 0d 06 d6 2b 20 e7  20 6e 65 61 72 3d 30 20  |ff...+ . near=0 |
00001c20  80 20 28 73 74 61 67 65  3d 30 20 84 20 73 74 61  |. (stage=0 . sta|
00001c30  67 65 3d 32 29 20 8c 20  f2 68 75 6e 74 0d 06 e0  |ge=2) . .hunt...|
00001c40  2e 20 e7 20 6e 65 61 72  3d 30 20 80 20 28 73 74  |. . near=0 . (st|
00001c50  61 67 65 3d 31 20 84 20  73 74 61 67 65 3d 33 29  |age=1 . stage=3)|
00001c60  20 8c 20 f2 6d 6f 76 65  6f 75 74 0d 06 ea 1a 20  | . .moveout.... |
00001c70  e7 20 73 74 61 67 65 3d  34 20 8c 20 f2 72 65 6c  |. stage=4 . .rel|
00001c80  65 61 73 65 62 0d 06 f4  06 20 3a 0d 06 fe 32 20  |easeb.... :...2 |
00001c90  f4 20 50 72 65 70 61 72  65 20 6f 75 74 70 75 74  |. Prepare output|
00001ca0  20 69 6e 74 6f 20 62 69  6e 61 72 79 20 66 6f 72  | into binary for|
00001cb0  20 74 72 61 6e 73 6d 69  73 73 69 6f 6e 0d 07 08  | transmission...|
00001cc0  20 20 66 65 65 64 3d 30  3a e7 20 6c 65 66 74 20  |  feed=0:. left |
00001cd0  8c 20 66 65 65 64 3d 66  65 65 64 2b 31 0d 07 12  |. feed=feed+1...|
00001ce0  1a 20 e7 20 72 69 67 68  74 20 8c 20 66 65 65 64  |. . right . feed|
00001cf0  3d 66 65 65 64 2b 32 0d  07 1c 1a 20 e7 20 74 75  |=feed+2.... . tu|
00001d00  72 62 6f 20 8c 20 66 65  65 64 3d 66 65 65 64 2b  |rbo . feed=feed+|
00001d10  34 0d 07 26 1b 20 e7 20  ac 20 69 64 6c 65 20 8c  |4..&. . . idle .|
00001d20  20 66 65 65 64 3d 66 65  65 64 2b 38 0d 07 30 1d  | feed=feed+8..0.|
00001d30  20 e7 20 72 65 76 65 72  73 65 20 8c 20 66 65 65  | . reverse . fee|
00001d40  64 3d 66 65 65 64 2b 31  36 0d 07 3a 0a 20 3d 66  |d=feed+16..:. =f|
00001d50  65 65 64 0d 07 44 06 20  3a 0d 07 4e 28 20 f4 20  |eed..D. :..N( . |
00001d60  50 65 72 66 6f 72 6d 20  61 20 73 77 65 65 70 20  |Perform a sweep |
00001d70  74 6f 20 66 69 6e 64 20  61 6e 79 20 62 61 6c 6c  |to find any ball|
00001d80  73 0d 07 58 0b 20 dd f2  68 75 6e 74 0d 07 62 23  |s..X. ..hunt..b#|
00001d90  20 f4 20 57 61 74 63 68  20 6f 75 74 20 69 66 20  | . Watch out if |
00001da0  74 6f 6f 20 6e 65 61 72  20 74 6f 20 6e 65 74 0d  |too near to net.|
00001db0  07 6c 9d 20 e7 20 28 66  72 65 71 61 3c 33 30 20  |.l. . (freqa<30 |
00001dc0  84 20 66 72 65 71 62 3c  31 30 20 84 20 66 72 65  |. freqb<10 . fre|
00001dd0  71 63 3c 31 30 29 20 80  20 28 66 61 24 3c 3e 22  |qc<10) . (fa$<>"|
00001de0  42 22 20 84 20 66 72 65  71 61 3e 33 30 29 20 80  |B" . freqa>30) .|
00001df0  20 28 66 62 24 3c 3e 22  42 22 20 84 20 66 72 65  | (fb$<>"B" . fre|
00001e00  71 62 3e 33 30 29 20 80  20 28 66 63 24 3c 3e 22  |qb>30) . (fc$<>"|
00001e10  42 22 20 84 20 66 72 65  71 63 3e 33 30 29 20 8c  |B" . freqc>30) .|
00001e20  20 72 65 76 69 6e 67 3d  35 3a 74 75 72 62 6f 3d  | reving=5:turbo=|
00001e30  b9 3a 72 65 76 65 72 73  65 3d b9 3a 72 69 67 68  |.:reverse=.:righ|
00001e40  74 3d b9 3a 6c 65 66 74  3d b9 3a e1 0d 07 76 6a  |t=.:left=.:...vj|
00001e50  20 e7 20 72 65 76 69 6e  67 3e 30 20 80 20 28 66  | . reving>0 . (f|
00001e60  72 65 71 61 3c 31 35 30  20 84 20 66 72 65 71 62  |reqa<150 . freqb|
00001e70  3c 31 35 30 20 84 20 66  72 65 71 63 3c 31 35 30  |<150 . freqc<150|
00001e80  29 20 8c 20 72 65 76 69  6e 67 3d 72 65 76 69 6e  |) . reving=revin|
00001e90  67 2d 31 3a 74 75 72 62  6f 3d b9 3a 72 65 76 65  |g-1:turbo=.:reve|
00001ea0  72 73 65 3d b9 3a 72 69  67 68 74 3d a3 3a 6c 65  |rse=.:right=.:le|
00001eb0  66 74 3d b9 3a e1 0d 07  80 0d 20 72 65 76 69 6e  |ft=.:..... revin|
00001ec0  67 3d 30 0d 07 8a 06 20  3a 0d 07 94 1a 20 f4 20  |g=0.... :.... . |
00001ed0  52 6f 74 61 74 65 20 74  6f 20 66 61 63 65 20 62  |Rotate to face b|
00001ee0  61 6c 6c 0d 07 9e 24 20  f4 20 57 68 65 72 65 20  |all...$ . Where |
00001ef0  73 65 61 72 63 68 20 61  66 74 65 72 20 74 68 69  |search after thi|
00001f00  73 20 62 61 6c 6c 3f 0d  07 a8 28 20 e7 20 28 66  |s ball?...( . (f|
00001f10  62 24 3d 22 42 22 20 80  20 66 72 65 71 62 3e 31  |b$="B" . freqb>1|
00001f20  35 30 29 20 8c 20 74 65  6e 64 69 6e 67 3d 30 0d  |50) . tending=0.|
00001f30  07 b2 26 20 e7 20 66 63  24 3d 22 42 22 20 80 20  |..& . fc$="B" . |
00001f40  66 72 65 71 63 3e 31 35  30 20 8c 20 74 65 6e 64  |freqc>150 . tend|
00001f50  69 6e 67 3d 31 0d 07 bc  1f 20 f4 20 50 69 63 6b  |ing=1.... . Pick|
00001f60  20 62 65 73 74 20 62 61  6c 6c 20 74 6f 20 61 69  | best ball to ai|
00001f70  6d 20 61 74 0d 07 c6 5a  20 64 69 73 74 3d 66 72  |m at...Z dist=fr|
00001f80  65 71 61 2a 30 2e 37 35  3a e7 20 64 69 73 74 3e  |eqa*0.75:. dist>|
00001f90  66 72 65 71 62 20 80 20  66 62 24 3d 22 42 22 20  |freqb . fb$="B" |
00001fa0  80 20 28 66 72 65 71 62  3c 66 72 65 71 63 20 84  |. (freqb<freqc .|
00001fb0  20 66 63 24 3c 3e 22 42  22 29 20 8c 20 73 74 65  | fc$<>"B") . ste|
00001fc0  65 72 3d 2d 31 3a 6c 65  66 74 3d b9 3a e1 0d 07  |er=-1:left=.:...|
00001fd0  d0 2f 20 e7 20 64 69 73  74 3e 66 72 65 71 63 20  |./ . dist>freqc |
00001fe0  80 20 66 63 24 3d 22 42  22 20 8c 20 73 74 65 65  |. fc$="B" . stee|
00001ff0  72 3d 31 3a 72 69 67 68  74 3d b9 3a e1 0d 07 da  |r=1:right=.:....|
00002000  62 20 e7 20 66 61 24 3d  22 42 22 20 8c 20 6c 65  |b . fa$="B" . le|
00002010  66 74 3d 28 73 74 65 65  72 3c 3e 31 29 3a 72 69  |ft=(steer<>1):ri|
00002020  67 68 74 3d 28 73 74 65  65 72 3c 3e 2d 31 29 3a  |ght=(steer<>-1):|
00002030  73 74 65 65 72 3d 30 3a  73 65 61 72 63 68 69 6e  |steer=0:searchin|
00002040  67 3d 73 65 61 72 63 68  69 6e 67 2f 32 3a 74 75  |g=searching/2:tu|
00002050  72 62 6f 3d 66 72 65 71  61 3e 31 30 30 3a e1 0d  |rbo=freqa>100:..|
00002060  07 e4 22 20 e7 20 66 62  24 3d 22 42 22 20 8c 20  |.." . fb$="B" . |
00002070  73 74 65 65 72 3d 2d 31  3a 6c 65 66 74 3d b9 3a  |steer=-1:left=.:|
00002080  e1 0d 07 ee 22 20 e7 20  66 63 24 3d 22 42 22 20  |...." . fc$="B" |
00002090  8c 20 73 74 65 65 72 3d  31 3a 72 69 67 68 74 3d  |. steer=1:right=|
000020a0  b9 3a e1 0d 07 f8 06 20  3a 0d 08 02 30 20 f4 20  |.:..... :...0 . |
000020b0  49 66 20 6e 6f 20 62 61  6c 6c 20 69 6e 20 73 69  |If no ball in si|
000020c0  67 68 74 2c 20 63 6f 6e  74 69 6e 75 65 20 72 6f  |ght, continue ro|
000020d0  74 61 74 69 6f 6e 2e 2e  2e 0d 08 0c 36 20 73 65  |tation......6 se|
000020e0  61 72 63 68 69 6e 67 3d  73 65 61 72 63 68 69 6e  |arching=searchin|
000020f0  67 2b 31 3a 74 75 72 62  6f 3d 28 73 65 61 72 63  |g+1:turbo=(searc|
00002100  68 69 6e 67 3e 35 29 3a  73 74 65 65 72 3d 30 0d  |hing>5):steer=0.|
00002110  08 16 2a 20 e7 20 28 74  65 6e 64 69 6e 67 20 80  |..* . (tending .|
00002120  20 31 29 3c 3e 30 20 8c  20 72 69 67 68 74 3d b9  | 1)<>0 . right=.|
00002130  20 8b 20 6c 65 66 74 3d  b9 0d 08 20 2a 20 e7 20  | . left=... * . |
00002140  73 65 61 72 63 68 69 6e  67 3d 35 20 8c 20 74 65  |searching=5 . te|
00002150  6e 64 69 6e 67 3d 28 74  65 6e 64 69 6e 67 20 82  |nding=(tending .|
00002160  20 31 29 0d 08 2a 23 20  e7 20 73 65 61 72 63 68  | 1)..*# . search|
00002170  69 6e 67 3e 35 30 20 8c  20 73 74 61 67 65 3d 73  |ing>50 . stage=s|
00002180  74 61 67 65 2b 31 0d 08  34 06 20 e1 0d 08 3e 06  |tage+1..4. ...>.|
00002190  20 3a 0d 08 48 3c 20 f4  20 46 69 6e 64 20 65 64  | :..H< . Find ed|
000021a0  67 65 20 6f 66 20 6e 65  74 20 61 6e 64 20 61 69  |ge of net and ai|
000021b0  6d 20 66 6f 72 20 69 74  20 74 6f 20 6d 6f 76 65  |m for it to move|
000021c0  20 74 6f 20 6f 74 68 65  72 20 73 69 64 65 0d 08  | to other side..|
000021d0  52 0e 20 dd f2 6d 6f 76  65 6f 75 74 0d 08 5c 23  |R. ..moveout..\#|
000021e0  20 f4 20 57 61 74 63 68  20 6f 75 74 20 69 66 20  | . Watch out if |
000021f0  74 6f 6f 20 6e 65 61 72  20 74 6f 20 6e 65 74 0d  |too near to net.|
00002200  08 66 89 20 e7 20 28 66  72 65 71 61 3c 33 30 20  |.f. . (freqa<30 |
00002210  84 20 66 72 65 71 62 3c  33 30 20 84 20 66 72 65  |. freqb<30 . fre|
00002220  71 63 3c 33 30 29 20 8c  20 72 65 76 69 6e 67 3d  |qc<30) . reving=|
00002230  b9 3a 74 75 72 62 6f 3d  b9 3a 72 65 76 65 72 73  |.:turbo=.:revers|
00002240  65 3d b9 3a 6c 65 66 74  3d ac 28 66 72 65 71 62  |e=.:left=.(freqb|
00002250  3c 28 66 72 65 71 61 2a  31 2e 32 35 29 29 3a 72  |<(freqa*1.25)):r|
00002260  69 67 68 74 3d 28 ac 28  66 72 65 71 63 3c 28 66  |ight=(.(freqc<(f|
00002270  72 65 71 61 2a 31 2e 32  35 29 29 29 84 20 28 ac  |reqa*1.25))). (.|
00002280  20 6c 65 66 74 29 3a e1  0d 08 70 8c 20 e7 20 72  | left):...p. . r|
00002290  65 76 69 6e 67 20 80 20  28 66 72 65 71 61 3c 31  |eving . (freqa<1|
000022a0  35 30 20 84 20 66 72 65  71 62 3c 31 35 30 20 84  |50 . freqb<150 .|
000022b0  20 66 72 65 71 63 3c 31  35 30 29 20 8c 20 74 75  | freqc<150) . tu|
000022c0  72 62 6f 3d b9 3a 72 65  76 65 72 73 65 3d b9 3a  |rbo=.:reverse=.:|
000022d0  6c 65 66 74 3d ac 28 66  72 65 71 62 3c 28 66 72  |left=.(freqb<(fr|
000022e0  65 71 61 2a 31 2e 32 35  29 29 3a 72 69 67 68 74  |eqa*1.25)):right|
000022f0  3d 28 ac 28 66 72 65 71  63 3c 28 66 72 65 71 61  |=(.(freqc<(freqa|
00002300  2a 31 2e 32 35 29 29 29  84 20 28 ac 20 6c 65 66  |*1.25))). (. lef|
00002310  74 29 3a e1 0d 08 7a 0d  20 72 65 76 69 6e 67 3d  |t):...z. reving=|
00002320  a3 0d 08 84 2e 20 f4 20  4a 75 6d 70 20 62 61 63  |..... . Jump bac|
00002330  6b 20 74 6f 20 68 75 6e  74 20 6d 6f 64 65 20 69  |k to hunt mode i|
00002340  66 20 6e 65 77 20 62 61  6c 6c 20 73 65 65 6e 0d  |f new ball seen.|
00002350  08 8e 41 20 e7 20 66 62  24 3d 22 42 22 20 84 20  |..A . fb$="B" . |
00002360  66 61 24 3d 22 42 22 20  84 20 66 63 24 3d 22 42  |fa$="B" . fc$="B|
00002370  22 20 8c 20 73 74 61 67  65 3d 73 74 61 67 65 2d  |" . stage=stage-|
00002380  31 3a 73 65 61 72 63 68  69 6e 67 3d 34 35 3a e1  |1:searching=45:.|
00002390  0d 08 98 2c 20 f4 20 41  6c 69 67 6e 20 62 61 6c  |..., . Align bal|
000023a0  6c 62 6f 74 20 74 6f 20  66 61 63 65 20 74 68 65  |lbot to face the|
000023b0  20 6e 65 74 20 70 6f 73  74 2e 2e 2e 0d 08 a2 24  | net post......$|
000023c0  20 e7 20 66 61 24 3d 22  4e 22 20 84 20 66 61 24  | . fa$="N" . fa$|
000023d0  3d 22 50 22 20 8c 20 72  69 67 68 74 3d b9 3a e1  |="P" . right=.:.|
000023e0  0d 08 ac 2d 20 e7 20 66  62 24 3c 3e 22 4e 22 20  |...- . fb$<>"N" |
000023f0  80 20 66 62 24 3c 3e 22  50 22 20 8c 20 6c 65 66  |. fb$<>"P" . lef|
00002400  74 3d b9 3a 73 74 65 65  72 3d 36 3a e1 0d 08 b6  |t=.:steer=6:....|
00002410  3b 20 e7 20 66 62 24 3d  22 50 22 20 80 20 66 72  |; . fb$="P" . fr|
00002420  65 71 62 3c 31 30 30 20  80 20 66 61 24 3c 3e 22  |eqb<100 . fa$<>"|
00002430  50 22 20 80 20 66 61 24  3c 3e 22 4e 22 20 8c 20  |P" . fa$<>"N" . |
00002440  6e 65 61 72 3d 31 3a e1  0d 08 c0 27 20 e7 20 73  |near=1:....' . s|
00002450  74 65 65 72 3e 30 20 8c  20 73 74 65 65 72 3d 73  |teer>0 . steer=s|
00002460  74 65 65 72 2d 31 3a 6c  65 66 74 3d b9 3a e1 0d  |teer-1:left=.:..|
00002470  08 ca 1b 20 74 75 72 62  6f 3d b9 3a 6c 65 66 74  |... turbo=.:left|
00002480  3d b9 3a 72 69 67 68 74  3d b9 0d 08 d4 06 20 e1  |=.:right=..... .|
00002490  0d 08 de 06 20 3a 0d 08  e8 47 20 f4 20 4e 65 61  |.... :...G . Nea|
000024a0  72 6c 79 20 74 68 65 72  65 2e 2e 2e 20 4a 75 73  |rly there... Jus|
000024b0  74 20 6e 65 65 64 20 61  20 6c 69 74 74 6c 65 20  |t need a little |
000024c0  6e 75 64 67 65 20 69 6e  20 74 68 65 20 72 69 67  |nudge in the rig|
000024d0  68 74 20 64 69 72 65 63  74 69 6f 6e 2e 0d 08 f2  |ht direction....|
000024e0  12 20 dd f2 64 6f 6e 65  61 72 73 74 75 66 66 0d  |. ..donearstuff.|
000024f0  08 fc 23 20 f4 20 57 61  74 63 68 20 6f 75 74 20  |..# . Watch out |
00002500  69 66 20 74 6f 6f 20 6e  65 61 72 20 74 6f 20 6e  |if too near to n|
00002510  65 74 0d 09 01 30 20 e7  20 66 72 65 71 61 3c 33  |et...0 . freqa<3|
00002520  30 20 84 20 66 72 65 71  62 3c 33 30 20 84 20 66  |0 . freqb<30 . f|
00002530  72 65 71 63 3c 33 30 20  8c 20 6e 65 61 72 3d 30  |reqc<30 . near=0|
00002540  3a e1 0d 09 06 34 20 e7  20 6e 65 61 72 3c 36 20  |:....4 . near<6 |
00002550  8c 20 72 69 67 68 74 3d  b9 3a 6c 65 66 74 3d a3  |. right=.:left=.|
00002560  3a 6e 65 61 72 3d 6e 65  61 72 2d 28 66 61 24 3d  |:near=near-(fa$=|
00002570  22 55 22 29 3a e1 0d 09  10 35 20 e7 20 6e 65 61  |"U"):....5 . nea|
00002580  72 3c 31 30 20 8c 20 6c  65 66 74 3d b9 3a 74 75  |r<10 . left=.:tu|
00002590  72 62 6f 3d b9 3a 72 69  67 68 74 3d b9 3a 6e 65  |rbo=.:right=.:ne|
000025a0  61 72 3d 6e 65 61 72 2b  31 3a e1 0d 09 1a 35 20  |ar=near+1:....5 |
000025b0  e7 20 6e 65 61 72 3c 31  35 20 8c 20 6c 65 66 74  |. near<15 . left|
000025c0  3d b9 3a 74 75 72 62 6f  3d b9 3a 72 69 67 68 74  |=.:turbo=.:right|
000025d0  3d a3 3a 6e 65 61 72 3d  6e 65 61 72 2b 31 3a e1  |=.:near=near+1:.|
000025e0  0d 09 24 1f 20 6c 65 66  74 3d b9 3a 72 69 67 68  |..$. left=.:righ|
000025f0  74 3d b9 3a 6e 65 61 72  3d 6e 65 61 72 2b 31 0d  |t=.:near=near+1.|
00002600  09 2e 3b 20 e7 20 6e 65  61 72 3e 32 30 20 8c 20  |..; . near>20 . |
00002610  6e 65 61 72 3d 30 3a 73  74 61 67 65 3d 73 74 61  |near=0:stage=sta|
00002620  67 65 2b 31 3a 73 65 61  72 63 68 69 6e 67 3d 30  |ge+1:searching=0|
00002630  3a 74 65 6e 64 69 6e 67  3d 31 0d 09 38 06 20 e1  |:tending=1..8. .|
00002640  0d 09 42 06 20 3a 0d 09  4c 3d 20 f4 20 49 6e 69  |..B. :..L= . Ini|
00002650  74 69 61 6c 69 73 65 20  42 61 6c 6c 42 6f 74 20  |tialise BallBot |
00002660  76 61 72 69 61 62 6c 65  73 20 61 74 20 74 68 65  |variables at the|
00002670  20 62 65 67 69 6e 6e 69  6e 67 20 6f 66 20 61 20  | beginning of a |
00002680  72 75 6e 0d 09 56 0e 20  dd f2 73 65 74 75 70 62  |run..V. ..setupb|
00002690  62 0d 09 60 2f 20 72 65  76 69 6e 67 3d a3 3a 6c  |b..`/ reving=.:l|
000026a0  65 66 74 3d a3 3a 72 69  67 68 74 3d a3 3a 73 65  |eft=.:right=.:se|
000026b0  61 72 63 68 69 6e 67 3d  30 3a 69 64 6c 65 3d b9  |arching=0:idle=.|
000026c0  0d 09 6a 1d 20 6e 65 61  72 3d a3 3a 74 65 6e 64  |..j. near=.:tend|
000026d0  69 6e 67 3d 31 3a 73 74  65 65 72 3d 30 0d 09 74  |ing=1:steer=0..t|
000026e0  06 20 e1 0d 09 7e 06 20  3a 0d 09 88 0f 20 dd f2  |. ...~. :.... ..|
000026f0  72 65 6c 65 61 73 65 62  0d 09 92 2d 20 f4 20 47  |releaseb...- . G|
00002700  6f 74 20 61 6c 6c 20 74  68 65 20 62 61 6c 6c 73  |ot all the balls|
00002710  2c 20 6e 6f 77 20 6a 75  73 74 20 64 75 6d 70 20  |, now just dump |
00002720  74 68 65 6d 21 0d 09 9c  10 20 6e 65 61 72 3d 6e  |them!.... near=n|
00002730  65 61 72 2b 31 0d 09 a6  1d 20 e7 20 6e 65 61 72  |ear+1.... . near|
00002740  3e 39 20 8c 20 69 64 6c  65 3d b9 3a 6e 65 61 72  |>9 . idle=.:near|
00002750  3d a3 0d 09 b0 06 20 e1  0d ff                    |=..... ...|
0000275a
BioBot/BBMotor.m0
BioBot/BBMotor.m1
BioBot/BBMotor.m2
BioBot/BBMotor.m4
BioBot/BBMotor.m5