#side Grudge 4
#author Devon
12, 15 November 2002

Keeps track of which other sides are hostile.
A cell's side is considered hostile if it has a bomb or is reloading.

This side is only to demonstrate the benefits of coexistence. It would work much better if it were something other than Gunner.

#color 9cf

Protocol:
Addresses that are side IDs hold true if the side is hostile.
(Actually they hold the time the side was declared hostile.)

(20021120) Slightly shorter range and more growth.
(20021120) Reduced angry time after being hurt.
(20040811) Use robot-bomb. Ignore nearby or approaching targets.
(20040813) Use robot-reloading. Some reorganization.
(20050211) Multiple sensor returns, to skip decoys. Ignore shielded targets.
     

#type Unforgiving
#color 33c

#hardware
  solar-cells .4
  constructor .4
  energy 40 0
  armor 150
  grenades 30 18 40
  robot-sensor 18 5
  radio write read
  processor 12
#code

#var next-scan

do
  constructor-type nif 1 constructor-type! then
  energy 35 > constructor-max-rate 0 ifev constructor-rate!
  time next-scan >= if
    fire-robot-sensor sync
    robot-found if
      maybe-shoot^
      time grenades-reload-time + next-scan!
    else
      time 60 80 random-int + next-scan!
    then
  then
  sync
forever

maybe-shoot:
  do
    robot-side read robot-bomb or robot-reloading or if
    robot-shield-fraction .3 > and-if
      robot-velocity velocity v- 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 robot-side write
      return
    then
  next-robot while-loop
return
#end
