#side Vaccine

Intended to eat Bacteria and other unarmed sides.

(20030327) Now ignores stationary shots (i.e. syphons).

#author Devon
#color 909

#type Inoculate
#color 970

Based on Bacteria's Escherichia. So I should have called it Shigella. :)

#hardware
  armor 200
  blaster 20 5 20
  eater 1.5
  constructor 1
  food-sensor 6
  robot-sensor 4.5
  shot-sensor 5
  energy 400 15
  engine .03
  processor 10

#code

#vector dest

construct:
  constructor-type if
    energy 380 constructor-remaining 20 - min >=
      constructor-max-rate 0 ifev constructor-rate!
  else energy 380 > if
    1 constructor-type!
    constructor-max-rate constructor-rate!
  then then
return

repair:
  energy 25 > max-repair-rate 0 ifev repair-rate!
return

#var next-robot-scan

scan-for-robots:
  time next-robot-scan >= if
    fire-robot-sensor sync
    robot-found if
      robot-velocity velocity v- robot-distance blaster-speed / vs*
      robot-position v+ position v- angle fire-blaster
      time blaster-reload-time + next-robot-scan!
    else
      time 26 + next-robot-scan!
    then
  then
return

scan-for-shots:
  time shot-sensor-time 10 + < ifr
  fire-shot-sensor sync
  shot-found nifr
  shot-velocity or nifr
rdrop
run& jump

eat:
do
  eaten nif time food-sensor-time 40 + >= and-if
    fire-food-sensor sync
    food-found wander& nifg
  then
  food-position seek-location
  energy 15 > if
    scan-for-shots
    scan-for-robots
  then
  construct
  repair
forever

new-dest:
  0 world-width random 0 world-height random dest!
return

#start
wander:
  new-dest
do
  time food-sensor-time 40 + >= if
    fire-food-sensor sync
    food-found eat& ifg
  then
  position dest 5 in-range if
    new-dest
  then
  dest seek-location
  energy 15 > if
    scan-for-shots
    scan-for-robots
  then
  construct
  repair
forever

run:
  shot-velocity unitize 15 vs* position v+
    0 max world-width min swap 0 max world-height min swap dest!
do
  dest seek-location
  construct
  repair
position dest 4 in-range until-loop
restart:
  fire-food-sensor sync
  food-found eat& wander& ifeg

#end
