#side Eventually...
#author Devon
#date September 20-22 2002
#color ef0

Autotroph; once it's built enough economy it starts cranking out missiles. Hundreds of them.
(20020922) Added Sentinel for defense.

Feel free to steal/modify parts of this side.

#type Economy
#color 0b0

(20020923) Build more Sentinels early.
(20021003) Don't inadvertently abort when seeded.
(20021025) Price reduction and nifc.
(20021026) A little more armor and less economy.

#hardware
  solar-cells .46
  constructor .46
  processor 4
  energy 5 0
  armor 100

#code

new-baby:
  time 9000 > if   ;should use type-population when it's fixed
    0 3 random-int 2 1 ifev
  else
    -3 4 random-int 1 max 3 min
  then constructor-type!
  constructor-max-rate constructor-rate!
return

#start
  do
    constructor-type new-baby& nifc
  forever


#type Safety Missile
#author Devon
#color 666

"Safety" because it won't detonate close to home.

(20020922) All destinations now at edges.
(20020922) Should no longer need recharging.
(20020923) More armor and engine.
(20021002) Ignore small cells, to resist B&F's decoys.
(20021002) Now goes off on contact instead of at short range.
(20021025) Bigger engine, only used when charging.
(20021025-6) Movement and detonation changes.

#hardware
  engine .1   ;c 100 m 2
  bomb 1000   ;c 150 m 4.5 ;could be bigger
  armor 120   ;c 120 m 3.6
  processor 10
  energy 20 5
  solar-cells .07   ;c 126 m 5.04 :-(
  robot-sensor 10   ;c 26

#code

#vector dest
#vector home
#const home-dist 15
#const edge-space 6 ;close enough to see corners
#var right
#var top

new-dest: ; --
  0 1 random-int if
    0 1 random-int edge-space right ifev
    edge-space top random
    dest!
  else
    edge-space right random
    0 1 random-int edge-space top ifev
    dest!
  then
  dest home home-dist in-range new-dest& ifg
return

steer:
  dest position v- unitize 4 vs/ engine-velocity!
  position dest 1.5 in-range new-dest& ifc
return

#start
  world-width edge-space - right!
  world-height edge-space - top!
  position home!
  new-dest
  do
    position home home-dist in-range no-target& ifg
    enemy-collision if
      die sync
    then
    fire-robot-sensor sync
    robot-found if robot-mass 9 > and-if
      robot-position dest!
      energy robot-sensor-firing-cost > engine-max-power .03 ifev engine-power!
    else
    no-target:
      .05 engine-power!
      steer
      sync sync sync sync sync sync sync sync sync sync
      steer
      sync sync sync sync sync sync sync sync sync sync
    then
    steer
    sync sync sync sync sync sync sync sync sync sync
    steer
    sync sync sync sync sync sync sync sync sync sync
  forever

#type Sentinel
#color 909

Can shoot even radially moving targets. Doesn't kill incoming missiles fast enough, though.

(20020923) Slight range increase.
(20021002) More weapon, to kill incoming missiles. And a little less growth and armor, to save cost.
(20020102) Shorter sleep time.
(20021003) Reduced useless max energy.
(20021025-6) Reduced cost.

#hardware
  processor 15
  armor 120
  grenades 30 17 35
  robot-sensor 17
  energy 40 0
  solar-cells .3
  constructor .28
#code

#var next-scan

#start
  time 20 + next-scan!
do
  constructor-type nif
    1 constructor-type!
  then
  energy 35 >= if
    constructor-max-rate
  else
    0
  then constructor-rate!
  time next-scan >= if
    fire-robot-sensor sync
    robot-found if
      robot-velocity 2dup
        robot-distance grenades-speed / vs* robot-position v+
        position dist grenades-speed / vs* robot-position v+
        position v- rect-to-polar fire-grenade
      time grenades-reload-time + next-scan!
    else
      time 33 + next-scan!
    then
  then
forever
#end
