#side World Toad #author Devon Principles: 1) Previously, large cells, to exploit their combat and coordination advantage. 2) Coordination in combat. (not yet) 3) Stay out of trouble. 4) Don't waste energy. #color fe9 (20021002) Now stops repairing when low on energy. No more sitting duck^H^H^H^Htoad. (20021002) Fixed gestation code (but was it broken?). (20021003) Stay slightly farther from target. (20021003) Higher firing rate. (20021030) More frequent scans when it hasn't seen food or robots. (20021116) Reduction for quadratic cooling cost. More frequent robot scans. (20021116) Wander when no food seen. #type Pale Wartless One #color 950 States: Idle - gestate, food->eat, shot->chase, robot->combat, message->chase Chase - shot, robot->combat, message Combat - robot Flee (later) - robot, shot, message To do: give up eating when blocked swarming eating during combat fleeing from superior force #hardware armor 550 repair-rate .2 ;c 150 grenades 40 11 20 processor 25 ;c 100? energy 600 10 solar-cells .25 ;c 450 eater 1.5 ;c 150 constructor 1.5 ;c 150 engine .18 ;c 180 robot-sensor 11 food-sensor 11 shot-sensor 6 #code #var next-robot-scan #var next-food-scan #var next-shot-scan #const robot-scan-interval 27 #const shot-scan-interval 12 #vector destination #var wandering 0 #const min-armor 100 autorepair: energy 50 > max-repair-rate 0 ifev repair-rate! return minimal-construction: constructor-remaining energy < constructor-type and constructor-max-rate 0 ifev constructor-rate! return ;;;; idle ;;;; #start idle: time next-food-scan! 0 wandering! do constructor-type nif 1 constructor-type! then energy max-energy .7 * > constructor-remaining energy <= or constructor-max-rate 0 ifev constructor-rate! autorepair time next-food-scan >= eaten not and if fire-food-sensor sync food-found if time 45 + next-food-scan! food-position destination! 0 wandering! else wandering nif 0 world-width random 0 world-height random destination! 1 wandering! then time 50 + next-food-scan! then then destination seek-location time next-robot-scan >= if fire-robot-sensor sync robot-found acquire& ifg time robot-scan-interval + next-robot-scan! then time next-shot-scan >= if fire-shot-sensor sync shot-found if shot-velocity norm chase-shot& ifg then time shot-scan-interval + next-shot-scan! then ;answer calls for help forever ;;;; chase ;;;; chase-shot: locate-shot-source^ chase: do minimal-construction autorepair destination seek-location time next-robot-scan >= if fire-robot-sensor sync robot-found acquire& ifg position destination 4 in-range if 0 engine-power! idle& jump then time robot-scan-interval + next-robot-scan! then time next-shot-scan >= if fire-shot-sensor sync shot-found if shot-velocity norm locate-shot-source& ifc then time shot-scan-interval + next-shot-scan! then forever locate-shot-source: -20 shot-velocity angle polar-to-rect shot-position v+ destination! return ;;;; combat ;;;; acquire: shoot^ adjust-range^ ;announce combat: do minimal-construction autorepair time next-robot-scan >= if fire-robot-sensor sync robot-found if shoot^ adjust-range^ else time robot-scan-interval + next-robot-scan! idle& jump then then ;armor min-armor < flee& ifg ;eat food if close? forever shoot: robot-velocity velocity v- 2dup robot-distance grenades-speed / vs* robot-position v+ ;estimated target position position dist grenades-speed / vs* robot-position v+ position v- rect-to-polar fire-grenade time grenades-reload-time + next-robot-scan! return #const combat-distance -10 ;; move to keep acceptable range. adjust-range: robot-position robot-velocity grenades-reload-time vs* v+ ;future position 2dup position v- angle combat-distance swap polar-to-rect ;delta v+ seek-location return ;;;; flee ;;;; pick-refuge: flee: pick-refuge do minimal-construction autorepair forever #end