' Symbioticus
'
' A tank with a battery ...
'
' Ties to a veg, pulls
' it close behind it and
' uses it as an energy 
' source
'
' Version 2.0
' - Uses a modified version of Animal Minimalis' search pattern
' Version 2.1
' - Uses some better coding to save energy
' Version 2.2
' - Improves on turning and movement genes
' Version 2.3
' - Adds a roaming routine to cover more ground
' Version 2.4
' - Some minor changes, improved some routines, better .fdbody routine
' Version 2.5
' - Some minor changes, corrected an error in the coding which caused Symbioticus to become immobile when it lost it's veg, annotated some more of the code to make it more understandable
' Version 2.6
' - More SGified coding

'*************************************************************

def roam 51 ' Used for movement
def done 52 ' Used for setting tie angle + length

' Delete birth tie and set .memloc

cond
start
.tie *.robage -1 mult 1 add mult inc
.tiepres .memloc *.robage -1 mult 1 add mult store
.deltie inc
stop

'*************************************************************

' Find and tie to a veggie

cond
*.robage 0 >
*.done 0 =
*.multi 0 =
*.eye5 0 >
*.eye5 45 <
*.refshoot 0 =
*.refaimdx 1 =
*.refeye 0 =
*.memval 86 !=
*.numties 0 =
start
40 .up store
stop

cond
*.robage 0 >
*.eye5 45 >
*.refshoot 0 =
*.refaimdx 1 =
*.refeye 0 =
*.memval 86 !=
*.numties 0 =
start
86 .tie store
stop

cond
*.robage 0 >
*.numties 0 =
*.eye5 0 =
*.memval 86 = or
*.refshoot 0 != or
*.refaimdx 1 != or
*.refeye 0 != or
start
314 rnd .aimdx store
stop

'*************************************************************

' Set tie and unfix veg

cond
start
86 .tienum *.numties sgn mult *.treffixed sgn mult store
.fixpos .tieloc *.numties sgn mult *.treffixed sgn mult store
0 .tieval *.numties sgn mult *.treffixed sgn mult store
stop

cond
*.numties 1 =
*.multi 0 =
*.done 0 =
start
.done inc
628 .fixang store
15 .fixlen store
86 .tienum store
.fixang .tieloc store
628 .tieval store
86 .readtie store
stop

'*************************************************************

' When tied to a vegetable

cond
start
*.tiepres .deltie *.myeye *.trefeye sub abs sgn -1 mult 1 add mult store
0 *.shell sub .mkshell *.shell sgn mult *.numties sgn -1 mult 1 add mult store
.done *.done mult *.numties sgn -1 mult 1 add mult dec
stop

'*************************************************************

' Sharing and producing

cond
start
75 .sharenrg *.multi mult store
50 .shareslime *.multi mult store
50 .shareshell *.multi mult store
.sharewaste *.multi mult inc
*.pleas 3 div .strbody *.pleas sgn mult *.multi mult store
*.pleas 3 div .mkslime *.pleas sgn mult *.multi mult store
600 *.shell sub .mkshell *.multi mult store
stop

' Shooting and tracking genes for when I become an MB

' Shoot

cond
*.refeye *.myeye !=
*.memval 86 !=
start
-32 .shootval *.multi mult *.eye5 sgn mult store
-6 .shoot *.multi mult *.eye5 sgn mult store
stop

cond
*.eye5 45 >
*.refeye *.myeye !=
*.memval 86 !=
start
32 .shootval *.multi mult store
stop

' Move

cond
*.eye5 0 =
*.memval 86 = or
*.refeye *.myeye = or
*.roam 100 <
start
100 .aimdx *.multi mult store
.roam *.multi mult inc
stop

cond
*.roam 99 >
*.eye5 0 =
*.memval 86 = or
*.refeye *.myeye = or
start
100 .up *.multi mult store
.roam *.multi mult inc
stop

cond
*.roam 200 >
start
0 .roam store
stop

' Aim and chase

cond
*.eye5 0 >
*.refeye *.myeye !=
*.memval 86 !=
start
*.refxpos *.refypos angle .setaim *.multi mult store
*.refveldx .aimdx *.multi mult store
stop

cond
*.eye5 0 >
*.eye5 30 <
*.refeye *.myeye !=
*.memval 86 !=
start
*.refvelup *.refvelup add 60 add .up *.multi mult store
stop

'*************************************************************

' Reproduction

cond
start
10 .repro *.body *.robage 10 mult sub sgn mult *.multi sgn mult store
stop

' Feed on body

cond
*.nrg 100 <
start
*.body 100 ceil .fdbody *.body sgn mult store
stop

'*************************************************************

' Shoot back at annoying enemies

cond
*.shflav 0 !=
*.shflav -2 !=
*.shoot 0 =
*.refeye 0 = or
start
1256 *.shang sub .aimshoot *.multi mult store
64 .shootval *.multi mult store
-6 .shoot *.multi mult store
0 .shflav *.multi mult store
stop

' Antiviral (for replicating viruses)

cond
start
*.mkvirus .delgene *.mkvirus sgn mult store
stop

' Junk DNA (for conspecific recognition)

cond
start
*.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 *.eye5 
stop

end
