def ang 50
def acl 51
def ang2 52
def bored 53
def last 54
def arr 55
def dx2 56
def up2 57

'born
cond
*.robage 0 =
start
1 .tie store
.eye5width .memloc store
stop

cond
*.robage 1 =
start
1220 .eye5width store
1 .deltie store
stop

'always
cond
*.robage 1 >
start
314 .setaim store
.bored *.bored 1 sub abs sgn mult dec
0 .out1 store
*.last 1 add .arr store
stop

cond
*.robage 1 >
*.eye5 30 >
*.refeye *.myeye =
*.in1 0 =
start
.bored *.bored 1 sub sqr sgn mult dec
stop

cond
*.robage 1 >
*.eye5 0 >
*.refeye *.myeye =
*.refage *.arr =
*.in1 0 =
start
.bored *.bored 1 sub sqr sgn mult dec
.bored *.bored 1 sub sqr sgn mult dec
.bored *.bored 1 sub sqr sgn mult dec
stop


'avoid
cond
*.robage 1 >
*.eye5 0 >
*.numties 0 =
*.refeye *.myeye =
start
*.refxpos *.refypos angle - *.aim add .ang  store
*.maxvel *.bored div *.nrg *.mass div 20 div ceil 1 floor - .acl store
*.refage .last store
.bored inc
.bored inc
.bored inc
stop


'eat
cond
*.robage 1 >
*.eye5 0 >
*.refeye *.myeye !=
start
-6 .shoot store
*.ang .aimshoot store

*.refxpos *.refveldx *.veldx add 2 mult add
*.refypos *refvelup *.velup add 2 mult add
angle - *.aim add .ang  store

*.refxpos
*.refveldx add *.veldx add
*.refypos
*refvelup add *.velup add 
dist 125 sub 2 mult *.maxvel ceil *.nrg *.mass div 20 div ceil .acl store

1 .bored *.bored 1 sub sqr sgn mult store
.out1 inc
.out1 inc
stop


cond
*.robage 1 >
*.eye5 0 >
*.refeye *.myeye !=
*.refeye 0 >
*.memval 1220 !=
start
*.nrg 20 div 20 ceil .shootval store
stop


cond
*.robage 1 >
*.numties 0 >
start
*.tiepres .deltie store
stop

'go!
cond
*.acl 0 !=
start
'sin(x) = x - x^3/3! + x^5/5! - x^7/7!
'cos(x) = 1 - x^2/2! + x^4/4! - x^6/6!

*.ang 3141 mult 628 div 1000 div .ang2 store
*.ang2 *.ang2 3 pow 6 div sub *.ang2 5 pow 120 div add *.ang2 7 pow 5040 div sub *.acl mult
.dx2 store
1 *.ang2 2 pow 2 div sub *.ang2 4 pow 24 div add *.ang2 6 pow 720 div sub *.acl mult 
.up2 store


*.dx2 *.veldx sub .dx 
  *.dx2 abs *.veldx abs sub sqr sgn 
  *.dx2 sgn *.veldx sgn sub sgn abs
  add sgn mult
store
*.up2 *.velup sub .up 
  *.up2 abs *.velup abs sub sqr sgn 
  *.up2 sgn *.velup sgn sub sgn abs
  add sgn mult
store

0 .acl store
stop


cond
*.nrg *.body >
start
*.nrg *.body sub 2 div 10 mult .strbody store
stop

cond
*.nrg *.body <
start
*.body *.nrg sub 2 div .fdbody store
stop

cond
*.body *.shell !=
start
*.body *.shell sub .mkshell store
stop

'poop
cond
*.waste 100 >
start
-4 .shoot store
*.waste .shootval store
stop
'repro

cond
*.robage 1 >
*.eye5 0 =
start
50 .repro store
stop

cond
*.robage 1 >
*.eye5 60 <
*.nrg 5000 >
*.body 5000 >
start
50 .repro store
stop
end