#side Business Cycle #author Matt Burkholder #date 6 Aug 2002 1-15-03 uses world size. Day traders build more while the count is low. 1-19-03 Small T-Bills #color 0CC #type T-Bill #color 0f0 ;Just sits there and reproduces. #hardware processor 1 solar-cells 0.3 constructor 0.3 energy 2 0 armor 150 repair-rate 0.05 radio read write send #code #var LastArmor armor LastArmor! position 2 write 1 write constructor-type nif 1 constructor-type! then constructor-max-rate constructor-rate! max-repair-rate repair-rate! do constructor-type nif time 15000 > if 3 constructor-type! else 0 1 type-population 2 type-population + random-int 2 type-population < 1 2 ifev constructor-type! then then Armor LastArmor < if position 2 3 send then Armor LastArmor! sync sync sync sync 1 read 2 read position v+ 0.5 vs* 2 write 1 write Armor LastArmor < if position 2 3 send then Armor LastArmor! sync sync sync sync forever #type Day Trader #color 800 #hardware processor 20 constructor 0.9 energy 500 50 eater 1.3 armor 200 engine 0.1 repair-rate 0.1 food-sensor 10 robot-sensor 7 shot-sensor 5 blaster 24 6 8 radio read write send receive #code #var food-sensor-now #var robot-sensor-now #var Damage-Time #var targetDirection #var take-a-shot #vector dest #vector target #vector Home #var LastArmor Armor LastArmor! 0 100 random-int 0 100 random-int target! food-sensor-range 0.6 * food-sensor-focus-distance! Feed: do energy 400 > energy constructor-remaining 2 * > or constructor-max-rate 0 ifev constructor-rate! constructor-type nif 1 type-population 2 type-population 6 < 2 3 ifev 1 ifev constructor-type! then armor max-armor < energy 20 > and max-repair-rate 0 ifev repair-rate! 1 read 2 read Home! time robot-sensor-now < blaster-cooldown or energy 21 < or nif fire-robot-sensor sync robot-found energy 100 > and if robot-position target! Transmit^ Attack^ else time 50 + robot-sensor-now! 0 take-a-shot! then then time food-sensor-now > friendly-collision or if friendly-collision random-angle Home position v- angle ifev food-sensor-focus-direction! fire-food-sensor sync food-found if 18000 food-sensor-now! food-position 2dup seek-location sync sync sync sync else time 50 + food-sensor-now! 0 0 then dest! then dest drop if dest position radius in-range nif dest seek-location else 0 0 engine-velocity! 0.05 engine-power! then else target seek-location then time Damage-Time < energy 100 > and if fire-shot-sensor sync shot-found if shot-position shot-velocity unitize -15 vs* v+ target! Transmit^ Track^ then then Check^ Armor LastArmor < if position Home 1 type-population 2.5 * 10 max in-range if time robot-sensor-now! time 50 + Damage-Time! else home position v- 0.5 vs* position v+ dest! then then armor LastArmor! speed eaten or nif time food-sensor-now! 5 15 random-int 5 15 random-int position v+ target! then forever Transmit: target 2 3 send return Check: 3 receive energy 100 > and if target! stack dropn else stack dropn return then Track: target seek-location sync sync do time robot-sensor-now > if fire-robot-sensor sync robot-found if robot-position target! Transmit^ Attack& jump else fire-shot-sensor sync shot-found if shot-position shot-velocity unitize -15 vs* v+ target! then then time 10 + robot-sensor-now! then target seek-location target position 5 in-range not energy 100 > and while-loop 0 food-sensor-now! return Attack: 0 constructor-rate! do blaster-cooldown nif fire-robot-sensor sync robot-found not ifr energy blaster-firing-cost > robot-distance blaster-range < and if robot-position position v- robot-velocity 0.85 vs* velocity v- robot-distance blaster-speed / vs* v+ rect-to-polar fire-blaster drop then robot-position robot-velocity robot-distance speed 0.1 max / vs* v+ robot-position position v- robot-distance -0.2 * vs/ v+ target! then target seek-location armor max-armor < max-repair-rate 0 ifev repair-rate! energy 20 > while-loop 0 food-sensor-now! return #type Dot-Com #color F05 #hardware processor 5 energy 70 70 armor 40 engine 0.15 robot-sensor 12 bomb 750 solar-cells 0.01 radio read write send receive #code #var robot-sensor-now #vector target 0 0 PickDest^ do time robot-sensor-now > if fire-robot-sensor sync robot-found 3 > if robot-distance-overall robot-direction-overall polar-to-rect position v+ target! time 5 + robot-sensor-now! robot-distance-overall 4 < energy 0.5 < or if robot-position 4 write 3 write sync die then else robot-found if robot-position target! time 5 + robot-sensor-now! robot-distance 2 < if robot-position 4 write 3 write sync die then else time 50 + robot-sensor-now! then then else check^ then energy 10 > robot-found or if target seek-location else 0 engine-power! then forever #var counter 0 #var end-wait-now 0 #const Return-wait 25 Check: 1 receive counter! do counter 0 > while counter 3 - counter! target 1 in-range if 1 2 send else drop then loop return PickDest: target + 3 read 0 = or nif 3 read 10 / round 1 max 9 min 10 * 4 read 10 / round 1 max 9 min 10 * 0 3 write else 1 world-width 10.1 / floor random-int 10 * dup 20 mod 1 world-height 20.1 / ceiling random-int 20 * 10 - 1 world-height 20.1 / floor random-int 20 * ifev then target! target 1 read 2 read 20 in-range PickDest& ifg id target 3 1 send time Return-wait + end-wait-now! do time end-wait-now < while sync 2 receive counter! do counter 0 > while counter 1 - counter! id = PickDest& ifg loop loop stack dropn return #end