Feel free to use this page to experiment with the Text Formatting Rules. Just click the "Edit Page" link at the bottom of the page.
#code
#vector Destination
GoThere:
Destination seek-location
return
Destination!
GoThere^
then
return
GetToSafety: ;Put x,y on stack
#vector loc
loc!
loc position 9 in-range if
10 loc position v- angle pi + polar-to-rect position v+
#const NeedFoodChannel 2 3 4 5 6 11111 .1
BroadcastNeedFood: ;Put x,y, and percentage of energy on stack.
3 NeedFoodChannel send
return
#const EnemyChannel 1 5 324 875 98239
BroadcastEnemy: ; Put the enemys x,y on stack
2 EnemyChannel send
return
#type Solar
#hardware
energy 100 10
solar-cell 1
constructor 1.5
engine .01
armor 50
robot-sensor 10
#code
#var Build 1
10 10 Destination!
Main:
GoThere^
constructor-remaining nif
Build 1 = 2 1 ifev Build!
Build constructor-type!
constructor-max-rate constructor-rate!
then
10 periodic-robot-sensor if robot-found and-if
robot-position BroadcastEnemy^
robot-position GetToSafety^
then
energy max-energy .2 * < if
position energy max-energy / BroadcastNeedFood^
then
EnemyChannel messages if
do
EnemyChannel messages
while
EnemyChannel receive drop GetToSafety^
loop
then
Main& jump
#type EatFood
#hardware
energy 400 20
solar-cell .01
engine .02
food-sensor 10
robot-sensor 10
syphon 2 6
eater 2
#code
20 20 Destination!
GoThere^
Main:
10 periodic-robot-sensor if robot-found and-if
robot-position BroadcastEnemy^
robot-position GetToSafety^
then
10 periodic-food-sensor if food-found and-if
food-position Destination!
then
GoThere^
EnemyChannel messages if
do
EnemyChannel messages
while
EnemyChannel receive drop GetToSafety^
loop
then
energy max-energy .5 * if
do NeedFoodChannel messages while
NeedFoodChannel receive drop drop Destination!
syphon-max-rate negate syphon-rate!
Destination position v- rect-to-polar syphon-angle!
syphon-distance!
loop
then
Main& jump
#end
#vector Destination
GoThere:
Destination seek-location
return
Destination!
GoThere^
then
return
GetToSafety: ;Put x,y on stack
#vector loc
loc!
loc position 9 in-range if
10 loc position v- angle pi + polar-to-rect position v+
#const NeedFoodChannel 2 3 4 5 6 11111 .1
BroadcastNeedFood: ;Put x,y, and percentage of energy on stack.
3 NeedFoodChannel send
return
#const EnemyChannel 1 5 324 875 98239
BroadcastEnemy: ; Put the enemys x,y on stack
2 EnemyChannel send
return
#type Solar
#hardware
energy 100 10
solar-cell 1
constructor 1.5
engine .01
armor 50
robot-sensor 10
#code
#var Build 1
10 10 Destination!
Main:
GoThere^
constructor-remaining nif
Build 1 = 2 1 ifev Build!
Build constructor-type!
constructor-max-rate constructor-rate!
then
10 periodic-robot-sensor if robot-found and-if
robot-position BroadcastEnemy^
robot-position GetToSafety^
then
energy max-energy .2 * < if
position energy max-energy / BroadcastNeedFood^
then
EnemyChannel messages if
do
EnemyChannel messages
while
EnemyChannel receive drop GetToSafety^
loop
then
Main& jump
#type EatFood
#hardware
energy 400 20
solar-cell .01
engine .02
food-sensor 10
robot-sensor 10
syphon 2 6
eater 2
#code
20 20 Destination!
GoThere^
Main:
10 periodic-robot-sensor if robot-found and-if
robot-position BroadcastEnemy^
robot-position GetToSafety^
then
10 periodic-food-sensor if food-found and-if
food-position Destination!
then
GoThere^
EnemyChannel messages if
do
EnemyChannel messages
while
EnemyChannel receive drop GetToSafety^
loop
then
energy max-energy .5 * if
do NeedFoodChannel messages while
NeedFoodChannel receive drop drop Destination!
syphon-max-rate negate syphon-rate!
Destination position v- rect-to-polar syphon-angle!
syphon-distance!
loop
then
Main& jump
#end