
Rem LWM'S SUPER ROBOT

rem move right at beginning
5   if scan(90)<0 then xvel=0:a=90:gosub 150
    xvel=80*(470>xpos)
    if xpos<460 then 5
    xvel=0

rem move top
6   if scan(0)<0 then yvel=0:a=0:gosub 150
    yvel=-80*(ypos>30)
    if ypos>40 then 6
    yvel=0
    goto 65

rem subsequent move rights
10  if scan(0)<0 then xvel=0:a=0:gosub 150
    xvel=80*(470>xpos)
    if scan(90)<0 then xvel=0:a=90:gosub 150
    xvel=80*(470>xpos)
    if xpos<460 then 10
    xvel=0

rem move top
60  if scan(0)<0 then yvel=0:a=0:gosub 150
    yvel=-80*(ypos>30)
    if scan(270)<0 then yvel=0:a=270:gosub 150
    yvel=-80*(ypos>30)
    if ypos>40 then 60
    yvel=0

rem do scanning
65  a = 280:d=dmge
70  rng=scan(a):if rng<0 then aim=a:shot=-rng:gosub 80
    if d+5 < dmge then 90
    d=dmge:repair:a=a-7:if a<170 then a=a+90
    goto 70

80 rng=scan(a):if rng>0 then a=a+36:return
   shot=-rng:repair:repair:repair:repair:repair
   if d+5 < dmge then return
   goto 80

rem run away
90 xvel=-80*(45<xpos):yvel=80*(470>ypos):a=atan2(30-xpos,ypos-490)
100 rng=scan(a):if rng<-50 then xvel=0:yvel=0:gosub 150
   if xpos<50 and ypos>465 then yvel=0:goto 10
   goto 90

rem check for robot
150 rng=scan(a): if rng>0 then return
    aim=a:d=dmge
160 shot=-rng
170 if shot>10 then repair:repair:repair:repair:goto 170
    if d+5<dmge then return
    rng=scan(aim):if rng<0 then 160
    return

