#side Homesick A basic, two-type randomized plant #author Warren #date 3/2/2002 #color 2a3 #type Gatherer #color 4c4 A gatherer. Tries to stay near birthplace. #hardware processor 10 energy 300 40 armor 150 engine 0.05 constructor 1 eater 2 food-sensor 15 50 #code #var home-x #var home-y #var last-food-scan 0 position 0 8 random random-angle polar-to-rect v+ home-y! home-x! ;record home as place of birth do constructor-type nif 0 2 random-int if 2 constructor-type! ;2/3rd chance of being a defender else 1 constructor-type! ;1/3rd chance of being a gatherer then then energy 50 > constructor-max-rate 0 ifev constructor-rate! ;scan for food and move to it time last-food-scan 50 + > if time last-food-scan! home-x home-y position v- 0.5 vs* rect-to-polar fire-food-sensor sync then food-found if food-position seek-location else 0 engine-power! then forever #type Defender Similar to fly swatter #color f05 #hardware processor 10 energy 100 10 armor 250 solar-cells 0.5 ;cost 900 constructor 0.4 grenades 50 25 50 force-field .2 25 robot-sensor 25 50 #code #var last-robot-scan 0 #var shot-arrive-time 0 #var target-x #var target-y do constructor-type nif 0 1 random-int if 1 constructor-type! ;half chance of being a gatherer else 2 constructor-type! ;half chance of being a defender then then energy 50 > constructor-max-rate 0 ifev constructor-rate! time last-robot-scan 50 + > grenades-cooldown not and if 0 10 random-int random-angle fire-robot-sensor sync time last-robot-scan! robot-found energy 20 > and if ;next three lines copied from Flyswatter robot-distance robot-direction fire-grenade time robot-distance grenades-speed / + 3 - shot-arrive-time! robot-position target-y! target-x! then then time shot-arrive-time < if force-field-max-force target-x target-y position v- rect-to-polar set-force-field else 0 0 0 set-force-field then forever #end