; P-scan flag retriever.
Not so good, but it could be a lot worse.
; The order of the routines matters in some of
these.
5: -- explain
if damage is = 0 then goto az
-- explain
scan relative 1
-- explain
if scan found flag then goto al
-- explain
scan relative 2
-- explain
if scan found flag then goto ah
-- explain
scan relative 8
-- explain
if scan found flag then goto ak
-- explain
cross scan
-- explain
if value #scan <> 5 then move backward
scan relative 3
-- explain
if scan found flag then goto am
-- explain
scan relative 7
-- explain
if scan found flag then goto ao
-- explain
scan relative 5
-- explain
if scan found flag then goto an
-- explain
scan relative 4
-- explain
if scan found flag then goto ai
-- explain
scan relative 6
-- explain
if scan found flag then goto aj
-- explain
az:
-- explain
scan relative 5
-- explain
if scan found flag then move forward
-- explain
if value #scan <> 5 then move backward
-- explain
if scan found flag then gosub az2
-- explain
if bump barrier then generate random
-- explain
if bump barrier then if value #random >= 3 then
turn right -- explain
if bump barrier then if value #random <= 2
then turn left -- explain
if bump barrier then goto az
-- explain
scan perimeter
-- explain
if value #inbound >= 1 then goto
locked_ #cur_head #inbound --
explain
if scan found flag then goto az
-- explain
if damage is = 0 then discharge energy
-- explain
move forward
if value #inbound = 0 then if value #enemy_x <>
#x_pos then if value #enemy_y <> #y_pos then goto
start_ #cur_head -- explain
if value #x_pos = #enemy_x then goto
same_x_ #cur_head -- explain
if value #y_pos = #enemy_y then goto
same_y_ #cur_head -- explain
if value #inbound >= 1 then goto
locked_ #cur_head #inbound --
explain
az2:
-- explain
turn right
math v2 = #x_pos - #enemy_x - #enemy_x * #x_pos
/ #enemy_x + #enemy_x * #enemy_x / #y_pos + #y_pos - #enemy_y - #enemy_y
* #y_pos / #enemy_y + #enemy_y * #enemy_y -- explain
if value ~v2 < 3 then if value #enemy_x <>
0 then if value ~v9 = ~v9 then goto
2 --
explain
scan right
-- explain
if scan found flag then discharge energy
-- explain
turn right
-- explain
return
ai:
-- explain
turn right
scan perimeter
-- explain
if scan found enemy then goto
#scan
ah:
-- explain
move forward
scan perimeter
-- explain
if scan found enemy then goto
#scan
am:
-- explain
turn right
scan perimeter
-- explain
if scan found enemy then goto
#scan
move forward
if value #inbound = 0 then if value #x_pos <>
#enemy_x then if value #y_pos <> #enemy_y then if not bump barrier then
goto start_ #cur_head
-- explain
if value #x_pos = #enemy_x then goto
same_x_ #cur_head -- explain
if value #y_pos = #enemy_y then goto
same_y_ #cur_head -- explain
if value #inbound >= 1 then goto
locked_ #cur_head #inbound --
explain
if damage is > 89 then goto
backherup_ #cur_head -- explain
discharge energy
if value #inbound = 0 then if value #enemy_x <>
#x_pos then if value #enemy_y <> #y_pos then goto
start_ #cur_head -- explain
if value #x_pos = #enemy_x then goto
same_x_ #cur_head -- explain
if value #y_pos = #enemy_y then goto
same_y_ #cur_head -- explain
if value #inbound >= 1 then goto
locked_ #cur_head #inbound --
explain
aj:
-- explain
turn left
scan perimeter
-- explain
if scan found enemy then goto
#scan
ak:
-- explain
move forward
scan perimeter
-- explain
if scan found enemy then goto
#scan
ao:
-- explain
turn left
scan perimeter
-- explain
if scan found enemy then goto
#scan
al:
-- explain
move forward
if value #inbound = 0 then if value #x_pos <>
#enemy_x then if value #y_pos <> #enemy_y then if not bump barrier then
goto start_ #cur_head
-- explain
if value #x_pos = #enemy_x then goto
same_x_ #cur_head -- explain
if value #y_pos = #enemy_y then goto
same_y_ #cur_head -- explain
if value #inbound >= 1 then goto
locked_ #cur_head #inbound --
explain
if damage is > 89 then goto
backherup_ #cur_head -- explain
discharge energy
-- explain
if value #inbound = 0 then if value #x_pos <>
#enemy_x then if value #y_pos <> #enemy_y then goto
start_ #cur_head -- explain
if value #x_pos = #enemy_x then goto
same_x_ #cur_head -- explain
if value #y_pos = #enemy_y then goto
same_y_ #cur_head -- explain
if value #inbound >= 1 then goto
locked_ #cur_head #inbound --
explain
an:
-- explain
move backward
if value #inbound = 0 then if value #x_pos <>
#enemy_x then if value #y_pos <> #enemy_y then goto
start_ #cur_head -- explain
if value #x_pos = #enemy_x then goto
same_x_ #cur_head -- explain
if value #y_pos = #enemy_y then goto
same_y_ #cur_head -- explain
if value #inbound >= 1 then goto
locked_ #cur_head #inbound --
explain