'Caterillar
'Creator Peter
'date 07-11-08
'V0.2


def time 100
def head 101
def move 102
def Mvel 971
def maxlengh 972
def stiftie 973
def phycics 974
def angle 104
def eddge 105



'---------MB-sharing
'MB-sharing stuff
cond
*.numties 1 =
*.trefage *.tin1 =
start
.tienum inc
*.stiftie .stifftie store
50 .sharenrg store
50 .shareshell store
50 .shareslime store
100 .sharewaste store

'628 .tieang store
*.tiepres .readtie store
stop


'------tie-moving stuff

'second step body
cond
*.move 1 !=
*.head 0 =
*.trefage *.time mod *.time 2 div >
start
*.maxlengh .fixlen store
1 .fixpos store
stop

'second step head
cond
*.move 1 !=
*.head 0 !=
*.robage *.time mod *.time 2 div >
start
0 .fixpos store
'*.eye9 *.eye1 sub 2 mult .aimdx store
stop

'first step body
cond
*.move 1 !=
*.head 0 =
*.trefage *.time mod *.time 2 div <
start
1 .fixlen store
0 .fixpos store
stop

'second step head
cond
*.move 1 !=
*.head 0 !=
*.robage *.time mod *.time 2 div <
start
1 .fixpos store
stop

'onspec stuff
cond
start
*.kills 1 add .out6 store
.tout1 inc
*.tin2 .move store
stop

'------------------------------repro stuff

'I am born
cond
*.robage 0 =
start
.shoot .ploc store 
.tie inc
14 .time store
628 .angle store
-30 .eye1width store

1117 .eye1dir store
-30 .eye9width store
-157 .eye9dir store
stop

'Split MB
cond
*.nrg 5000 >
*.body 2000 >
start
.deltie inc
stop

'first ever bot
cond
*.maxlengh 0 =
start
1000 .maxlengh store
100 .stiftie store
stop

'birth turn
cond
'*.trefage *.refage =
'*.robage 2 >
*.refeye *.myeye =
*.eye5 0 !=
start
628 .aimdx store
stop

'I'm old and no MB, strange.
cond
*.robage 1 >
*.numties 0 =
start
100 .aimdx store
stop

'body
cond
*.nrg 500 >
*.nrg *.body >
start
100 .strbody store
stop

cond
*.nrg 200 <
start
100 .fdbody store
stop

'----------shoot
'Shooting section
cond
*.reftype 0 =
*.eye5 5 >
*.eye5 40 <
*.refkills 1 add *.in6 !=
start
'100 .maxlengh store
*.refxpos *.refypos angle .setaim store
-10 .shootval store
-6 .shoot store
0 .tout2 store
0 .move store
'1 .fixlen store 'added line
stop


cond
*.eye5 39 >
*.refkills 1 add *.in6 !=
*.reftype 0 =
start
'1 .tout2 store
'1 .move store
1 .fixlen store
*.refxpos *.refypos angle .setaim store
8 .shootval store
*.refpoison *.refshell =>
-6 .shoot store
*.refpoison *.refshell <
-1 .shoot store
stop

'Did you, did you just shoot at me.
cond
*.shflav 0 !=
*.shflav -2 !=
start
*.shang .aimshoot store
25 .shootval store
0 .shflav store
*.refpoison *.refshell =>
-6 .shoot store
*.refpoison *.refshell <
-1 .shoot store
stop

'------------edge objects
'edge object.
cond
*.tin8 0 !=
start
'1 .fixlen store
'1 .fixpos store
*.tin8 .aimdx store
stop

cond
*.tin9 0 !=
start
10 .fixlen store
1 .fixpos store
stop




cond
*.edge 1 =
*.head 1 =
and
start
1 .eddge store
200 .tout8 store
1 .tout9 store
stop



cond
*.head 1 =
*.eye1 0 !=
start
'900 .fixlen store
'1 .fixpos store
0 .tout8 store
0 .tout9 store
0 .eddge store
stop

'turning
cond
*.eye5 0 =
*.head 1 =
start
*.eye2 0 !=
45 .aimsx store
45 .tout8 store
*.eye8 0 !=
-45 .aimsx store
-45 .tout8 store
*.eye3 0 !=
30 .aimsx store
30 .tout8 store
*.eye7 0 !=
-30 .aimsx store
-30 .tout8 store
*.eye4 0 !=
15 .aimsx store
15 .tout8 store
*.eye6 0 !=
-15 .aimsx store
-15 .tout8 store
stop

cond
*.eye1 0 =
*.eye2 0 =
*.eye3 0 =
*.eye4 0 =
*.eye5 0 =
*.eye6 0 =
*.eye7 0 =
*.eye8 0 =
*.eye9 0 !=
*.head 1 =
start
'1 .eddge store
'100 .tout8 store
stop

cond
*.eye2 40 >
*.eye3 40 >
or
*.eye4 40 >
or
*.eye6 40 >
or
*.eye7 40 >
or
*.eye8 40 >
or
head 1 =
and
*.refkills 1 add *.in6 !=
and
start
-1 .fixang
1 .fixpos store
0 .eddge store
stop

cond
*.eye5 40 >
*.refkills 1 add *.in6 !=
start
1 .fixpos store
0 .eddge store
stop

cond
*.reftype 1 =
start
0 .eddge store
stop

cond
*.eddge 1 =
start
10 .fixlen store
628 .fixang store
'100 .aimdx store
stop

cond
*.vloc .shoot !=
start
-2 .venval store
.shoot .vloc store
stop

'poison reloading
cond
*.numties 0 !=
*.poison 200 <
*.nrg 1100 >
start
100 .strpoison store
stop

'increasing shell
cond
*.numties 0 !=
*.shell 200 <
*.nrg 1500 >
start
100 .mkshell store
stop

cond
*.delgene 0 !=
start
0 .delgene store
0 .repro store
stop

'reproduce
cond
*.numties 0 =
*.robage 0 !=
start
50 .repro store
1 .head store
1 .tout3 store
stop

cond
*.shoot -2 =
start
0 .fixang store
stop


