#side Bacteria 3

Originally intended as a Microb clone, this is a simple skittish gatherer.

(20030428) Don't seed any cyanobacteria.

#author Devon
#color AFA
#seed 2

#type Cyanobacterium
#color 0FF
#hardware
  solar-cells .18
  constructor .18
  armor 10
  processor 1
#code
do
  constructor-type nif
    1 2 random-int constructor-type!
  then
  constructor-max-rate constructor-rate!
forever

#type Escherichia
#color 970

(20030418) Bigger eater and constructor.
           Flee away from shot as well as parallel to it.
(20030428) Wander more locally.
           Scan for food more often.
(20030517) Don't starve self gestating.

#hardware
  eater 1.5
  constructor 1
  energy 200 10
  armor 90
  processor 8
  food-sensor 6
  shot-sensor 5
  engine .02
#code

#vector dest
#const wander-range 40

new-dest:
  position swap
    dup wander-range - 0 max swap wander-range + world-width min random
    swap dup wander-range - 0 max swap wander-range + world-height min random
    dest!
return

construct:
  constructor-type if
    energy 180 constructor-remaining 15 + min >=
      constructor-max-rate 0 ifev constructor-rate!
  else energy 180 > if
    1 2 random-int constructor-type!
    constructor-max-rate constructor-rate!
  then then
return

#start
main:
  new-dest
do
  eaten nif time food-sensor-time 60 + >= and-if
    fire-food-sensor sync
  then
  food-found if
    food-position seek-location
  else 
    position dest 5 in-range if
      new-dest
    then
    dest seek-location
  then
  energy 10 > if time shot-sensor-time 10 + >= and-if
    fire-shot-sensor sync
    shot-found run& ifg
  then
  construct
forever

run:
  shot-velocity unitize position shot-position v- unitize v+ 15 vs* position v+
    0 max world-width min swap 0 max world-height min swap dest!
do
  dest seek-location
  construct
position dest 4 in-range until-loop
main& jump

#end
