#side Rat #author Warren #date 14 April 2002 A food-eater with flash-shielding. Reproduces slowly but survives under heavy fire. #color 880 #type Rat #color 810 #hardware energy 400 70 ; c 110 food-sensor 12 ;c ~30 engine .05 ;c 50 processor 15 ;c 45 solar-cells 0.01 ;c 18 armor 150 ;cost 1.0/armor eater 1.5 ;c 90 constructor 1.0 ;c 120 repair-rate .2 ;c 80 shield 0.5 ;c 250 shot-sensor 5 ;low radius, low cost robot-sensor 5 #code ;; steering code ;; #var dest-x #var dest-y #var destination? 0 set-destination: ; x y -- dest-y! dest-x! 1 destination?! return ;;; main ;;; #start do time food-sensor-time - 25 > seek& ifc energy constructor-remaining 250 min > if 1 constructor-type! constructor-max-rate constructor-rate! else 0 constructor-rate! then energy 20 > if ;;don't defend/offend if low energy time robot-sensor-time - 5 > if fire-shot-sensor fire-robot-sensor sync then ;Raise shields if shots were seen ;raise shields more if we are low on armor max-armor armor - 0.002 * 0.2 + ;full armor ==> 0.2 ;50 armor gone ==> 0.3 shot-found robot-found + 2 min * max-shield min shield 0.005 - max shield! energy armor 50 min > max-armor 1 - armor > and if max-repair-rate repair-rate! else 0 repair-rate! then else 0 repair-rate! 0 shield! then destination? if dest-x dest-y seek-location then ;else is handled by seek reutine forever seek: fire-food-sensor sync food-found if food-position set-destination else ;wander, at reduced power. 0 destination?! engine-max-power 0.5 * engine-power! 0.1 speed if velocity angle else random-angle then polar-to-rect engine-velocity! then return #end