#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.

#hardware
  solar-cells .5
  constructor .49
  processor 4
  energy 5 0
  armor 90

#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 not new-baby& ifc
  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.
(20020102) Now goes off on contact.

#hardware
  engine .07   ;c 60 m 1.2
  bomb 1000   ;c 150 m 4.5 ;could be bigger
  armor 120   ;c 120 m 4.8
  processor 10
  energy 10 5
  solar-cells .09   ;c 144 m 6.48 :-(
  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

#start
  world-width edge-space - right!
  world-height edge-space - top!
  position home!
  new-dest
  do
    fire-robot-sensor sync
    robot-found position home home-dist in-range not robot-mass 9 > and and if
      enemy-collision if
        die sync
      else
        robot-position dest!
      then
    else
      dest seek-location
      position dest 1.5 in-range new-dest& ifc
      sync sync sync sync sync sync sync sync sync sync
      sync sync sync sync sync sync sync sync sync sync
    then
    dest seek-location
    position dest 1.5 in-range new-dest& ifc
    sync sync sync sync sync sync sync sync sync sync
    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.

#hardware
  processor 15
  armor 150
  grenades 32 17 24
  robot-sensor 17
  energy 50 0
  solar-cells .35
  constructor .33
#code

#var next-scan

#start
  time 20 + next-scan!
do
  constructor-type nif
    1 constructor-type!
  then
  energy 45 >= 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
