Main.WikiSandbox History
Hide minor edits - Show changes to markup - Cancel
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.
(:source lang=grobocode tabwidth=3 :)
#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
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.
(:source lang=grobocode tabwidth=3 :)
#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:
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
BroadcastEnemy?: ; Put the enemys x,y on stack
- const EnemyChannel? 1 5 324 875 98239link text
- const EnemyChannel? 1 5 324 875 98239
- const EnemyChannel? 1
BroadcastEnemy?: ; Put the enemy's x,y on stack
- const EnemyChannel? 1 5 324 875 98239link text
BroadcastEnemy?: ; Put the enemys x,y on stack
- const NeedFoodChannel? 2
- const NeedFoodChannel? 2 3 4 5 6 11111 .1
- const EnemyChannel? 1
- const NeedFoodChannel? 2
- const NeedFoodChannel? 2
BroadcastNeedFood?: ;Put x,y, and percentage of energy on stack.
3 NeedFoodChannel? send
BroadcastNeedFood?: ;Put x,y, and percentage of energy on stack.
3 NeedFoodChannel? send
return
- const EnemyChannel? 1
BroadcastNeedFood?: ;Put x,y, and percentage of energy on stack.
3 NeedFoodChannel? send
return
BroadcastNeedFood?: ;Put x,y, and percentage of energy on stack.
3 NeedFoodChannel? send
return
BroadcaseNeedFood?: ;Put x,y, and percentage of energy on stack.
BroadcastNeedFood?: ;Put x,y, and percentage of energy on stack.
Check-Comm:
do
2 messages
while
2 receive drop 2dup vPollen!
position 2.4 in-range if
time 20 + FeedPollen?!
return
then
loop
return
- code
- vector Destination
- const EnemyChannel? 1
- const NeedFoodChannel? 2
Destination seek-location 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+
Destination!
GoThere?^
then
return
BroadcastEnemy?: ; Put the enemy's x,y on stack
2 EnemyChannel? send
return
BroadcaseNeedFood?: ;Put x,y, and percentage of energy on stack.
3 NeedFoodChannel? 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
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
(:source lang=cpp tabwidth=3 :)[@
(:source lang=grobocode tabwidth=3 :)[@
(:source lang=cpp :)[@
(:source lang=cpp tabwidth=3 :)[@
[@
(:source lang=cpp :)[@
@]
@]
Check-Comm: do 2 messages while 2 receive drop 2dup vPollen! position 2.4 in-range if time 20 + FeedPollen! return then loop return