#side Noffee 2 #author Warren/Devon NoFF, with Escherichia for an economy. #seed 2 1 2 #type No friendly fire #author Warren started 20030614 A blaster turret which won't shoot friends. (Devon 20030627) Smaller solar cells, more storage, smaller blaster. Don't scan when out of energy. (20030628) Slightly faster friend-avoiding loop. (Devon 20030814) Fixed sensor/blaster range mismatch. (Devon 20030815) Ignore shielded targets unless full. #hardware energy 100 0 armor 100 processor 40 solar-cells 0.15 robot-sensor 16 10 blaster 25 16 40 #code ;;#vector enemy-position ;#vector enemy-velocity ;#var enemy-time #var enemy-distance #vector target-delta #vector expected-shot-velocity do energy blaster-firing-cost robot-sensor-firing-cost + > if time robot-sensor-time - blaster-reload-time > and-if 0 robot-sensor-sees-friends! 1 robot-sensor-sees-enemies! 0 robot-sensor-focus-distance! fire-robot-sensor sync robot-found if robot-shield-fraction 0.2 < if energy max-energy 10 - < No-Shoot& ifg then robot-distance enemy-distance! ;determine which way to fire robot-position position v- robot-velocity velocity v- robot-distance blaster-speed / vs* v+ target-delta! blaster-speed target-delta angle polar-to-rect velocity v+ expected-shot-velocity! ;look for friends in line of fire 1 robot-sensor-sees-friends! 0 robot-sensor-sees-enemies! target-delta 0.5 vs* rect-to-polar robot-sensor-focus-direction! robot-sensor-focus-distance! fire-robot-sensor sync robot-found if do robot-position position v- target-delta unitize dot dup 0 > swap enemy-distance < and if ;if the friend is between us and the enemy robot-position position v- expected-shot-velocity robot-velocity v- unitize ;stack: vector to ally, shots expected closing velocity cross abs ;stack: ally distance from line of fire robot-radius 0.3 + < no-shoot& ifg then next-robot while-loop then ;friends target-delta angle fire-blaster No-Shoot: then ;enemies found then ;time to fire forever #type Escherichia #author Devon #color 970 (20030418) Bigger eater and constructor. Flee away from shot as well as parallel to it. (20030428) Wander more locally. Scan for food more often. (20030517) Don't starve self gestating. #hardware eater 1.5 constructor 1 energy 200 10 armor 90 processor 8 food-sensor 6 shot-sensor 5 engine .02 #code #vector dest #const wander-range 40 new-dest: position swap dup wander-range - 0 max swap wander-range + world-width min random swap dup wander-range - 0 max swap wander-range + world-height min random dest! return construct: constructor-type if energy 180 constructor-remaining 15 + min >= constructor-max-rate 0 ifev constructor-rate! else energy 180 > if 1 2 random-int constructor-type! constructor-max-rate constructor-rate! then then return #start main: new-dest do eaten nif time food-sensor-time 60 + >= and-if fire-food-sensor sync then food-found if food-position seek-location else position dest 5 in-range if new-dest then dest seek-location then energy 10 > if time shot-sensor-time 10 + >= and-if fire-shot-sensor sync shot-found run& ifg then construct forever run: shot-velocity unitize position shot-position v- unitize v+ 15 vs* position v+ 0 max world-width min swap 0 max world-height min swap dest! do dest seek-location construct position dest 4 in-range until-loop main& jump #end