'Tribolis 0.2
'A multibot by Bacillus
'Updates from previous version:
'Increased efficiency of body control
'Regenerating tail issue resolved
'Issues with Tribolis:
''Two-headed syndrome still present, although rare
''Quite passive
''Branching limbs didn't work properly
''Body Parts useless
'SYSVARS
''Amount of ties last cycle
def prevties 998
''Type of body part
def type 999
'Body part variables
def head 1
def middle 2
def tail 3
'Velocity Variables
''MinV-minimum velocity sustained by organism
def minv 10
''Acc-scale by which speed increases
''smaller numbers result in big, sluggish worms
''optimum lies between 1 and 4
def acc 3
'IO PORTS
''1-Species conspec
''2-Cell Type
''9-Cell ID
'BEGIN DNA
'Initialize cell
''Form tie, set as head
''Conspec
cond
*.robage 0 =
start
.tie inc
654 .out1 store
.head .type store
654 .tout1 store
stop
cond
*.robage 1 =
start
628 .aimdx store
stop
''Init part 2-set cell ID
cond
*.robage 25 =
*.numties 0 >
start
*.tin9 ++ .tout9 store
stop
'If single cell, divide and form diatom
''Should become new tail
cond
*.numties 0 =
start
.tout9 store
.tail .type store
50 .repro store
stop
'HEAD DNA REGION
'Head update
''Speed determined by cell ID eg. worm size
''OCULUS II
''Move tie out of the way
cond
*.type .head =
start
.minv *.tout9 .acc mult add *.velup sub .up store
628 .fixang store
-4 *.eye1 *.eye9 sub sgn 0 floor mult *.eye1 *.eye8 sub sgn 0 floor mult *.eye1 *.eye7 sub sgn 0
floor mult *.eye1 *.eye6 sub sgn 0 floor mult *.eye1 *.eye5 sub sgn 0 floor mult *.eye1 *.eye4 sub
sgn 0 floor mult *.eye1 *.eye3 sub sgn 0 floor mult *.eye1 *.eye2 sub sgn 0 floor mult 4 *.eye9
*.eye8 sub sgn 0 floor mult *.eye9 *.eye7 sub sgn 0 floor mult *.eye9 *.eye6 sub sgn 0 floor mult
*.eye9 *.eye5 sub sgn 0 floor mult *.eye9 *.eye4 sub sgn 0 floor mult *.eye9 *.eye3 sub sgn 0 floor
mult *.eye9 *.eye2 sub sgn 0 floor mult *.eye9 *.eye1 sub sgn ++ sgn mult add -3 *.eye2 *.eye9 sub
sgn ++ sgn mult *.eye2 *.eye8 sub sgn 0 floor mult *.eye2 *.eye7 sub sgn 0 floor mult *.eye2 *.eye6
sub sgn 0 floor mult *.eye2 *.eye5 sub sgn 0 floor mult *.eye2 *.eye4 sub sgn 0 floor mult *.eye2
*.eye3 sub sgn 0 floor mult *.eye2 *.eye1 sub sgn ++ sgn mult add 3 *.eye8 *.eye9 sub sgn ++ sgn
mult *.eye8 *.eye7 sub sgn 0 floor mult *.eye8 *.eye6 sub sgn 0 floor mult *.eye8 *.eye5 sub sgn 0
floor mult *.eye8 *.eye4 sub sgn 0 floor mult *.eye8 *.eye3 sub sgn 0 floor mult *.eye8 *.eye2 sub
sgn ++ sgn mult *.eye8 *.eye1 sub sgn ++ sgn mult add -2 *.eye3 *.eye9 sub sgn ++ sgn mult *.eye3
*.eye8 sub sgn ++ sgn mult *.eye3 *.eye7 sub sgn 0 floor mult *.eye3 *.eye6 sub sgn 0 floor mult
*.eye3 *.eye5 sub sgn 0 floor mult *.eye3 *.eye4 sub sgn 0 floor mult *.eye3 *.eye2 sub sgn ++ sgn
mult *.eye3 *.eye1 sub sgn ++ sgn mult add 2 *.eye7 *.eye9 sub sgn ++ sgn mult *.eye7 *.eye8 sub
sgn ++ sgn mult *.eye7 *.eye7 sub sgn 0 floor mult *.eye7 *.eye6 sub sgn 0 floor mult *.eye7 *.eye5
sub sgn 0 floor mult *.eye7 *.eye4 sub sgn ++ sgn mult *.eye7 *.eye2 sub sgn ++ sgn mult *.eye7
*.eye1 sub sgn ++ sgn mult add -1 *.eye4 *.eye9 sub sgn ++ sgn mult *.eye4 *.eye8 sub sgn ++ sgn
mult *.eye4 *.eye7 sub sgn ++ sgn mult *.eye4 *.eye6 sub sgn 0 floor mult *.eye4 *.eye5 sub sgn 0
floor mult *.eye4 *.eye3 sub sgn ++ sgn mult *.eye4 *.eye2 sub sgn ++ sgn mult *.eye4 *.eye1 sub
sgn ++ sgn mult add 1 *.eye4 *.eye9 sub sgn ++ sgn mult *.eye4 *.eye8 sub sgn ++ sgn mult *.eye4
*.eye7 sub sgn ++ sgn mult *.eye4 *.eye6 sub sgn ++ sgn mult *.eye4 *.eye5 sub sgn 0 floor mult
*.eye4 *.eye3 sub sgn ++ sgn mult *.eye4 *.eye2 sub sgn ++ sgn mult *.eye4 *.eye1 sub sgn ++ sgn
mult add 0 *.eye5 *.eye9 sub sgn ++ sgn mult *.eye5 *.eye8 sub sgn ++ sgn mult *.eye5 *.eye7 sub
sgn ++ sgn mult *.eye5 *.eye6 sub sgn ++ sgn mult *.eye5 *.eye4 sub sgn ++ sgn mult *.eye5 *.eye3
sub sgn ++ sgn mult *.eye5 *.eye2 sub sgn ++ sgn mult *.eye5 *.eye1 sub sgn ++ sgn mult add
.focuseye store
stop
'Head seeks food
cond
*.type .head =
*.eyef 0 >
*.in1 *.out1 !=
start
*.refxpos *.refypos angle .setaim store
stop
'If head sees no food and is under attack, turn
cond
*.type .head =
*.eyef 0 =
*.in1 *.out1 = or
*.shflav 0 !=
start
*.shang .aimdx store
.shflav store
stop
'Head feeds; if stunned by tail, feed faster
cond
*.in1 *.out1 !=
*.eye5 40 >
*.type .head =
start
4 *.reffixed 28 mult add .shootval store
-6 *.refshell sgn 5 mult add .shoot store
*.veldx .sx store
*.velup 2 sub .dn store
stop
'BODY DNA REGION
'Body moves slower than head
cond
*.type .middle =
start
*.tout9 .acc mult *.velup sub .up store
stop
'Body disposes of waste
cond
*.type .middle =
*.waste 100 >
start
*.waste .shootval store
-4 .shoot store
stop
'Feed when swimming past food
cond
*.type .middle =
*.eye5 30 >
*.in1 *.out1 !=
start
4 *.reffixed 28 mult add .shootval store
-1 .shoot store
stop
'TAIL DNA REGION
'Tail stuns prey
cond
*.type .tail =
*.in1 *.out1 !=
*.eye5 30 >
*.reffixed 0 =
start
.shootval inc
.fixpos .shoot store
stop
'If idle, turn away from body
cond
*.type .tail =
*.shflav 0 =
*.eyef 0 =
*.in1 *.out1 = or
start
*.trefxpos *.trefypos angle 628 add .setaim store
stop
'Tail forces prey to shed nrg
''Useful for getting the head to locate prey
cond
*.type .tail =
*.reffixed 0 >
*.eye5 30 >
start
10 .strvenom store
-2 .venval store
.shoot .vloc store
*.venom .shootval store
-3 .shoot store
stop
'If tail sees no prey and is under attack, turn
cond
*.type .tail =
*.in1 *.out1 =
*.shflav 0 !=
start
*.shang .aimdx store
.shflav store
stop
'DEFENSE SYSTEM
'Produce shell and poison
cond
*.shflav -1 =
start
50 *.poison sub .strpoison store
.shoot .ploc store
stop
cond
*.shflav -6 =
start
25 *.shell sub .mkshell store
stop
'REPRODUCTION
'Form new cell
cond
*.numties 1 =
*.type .head =
*.nrg 6000 >
*.eye5 30 <
*.robage 25 >
start
.middle .type store
50 .repro store
314 .aimdx store
stop
'Worm bursts due to attack/tension-create lots of new little embryos
cond
*.prevties *.numties >
*.nrg 4000 >
start
.tout9 store
.deltie inc
stop
'GENERAL MAINTENANCE
'Repair tail
''No need to repair head as it would cause worm to burst anyway
cond
*.numties 1 =
*.type .middle =
*.tin9 *.tout9 >
start
.tail .type store
stop
'If foreign tie is found, feed off parasite
cond
*.tin1 *.tout1 !=
start
-1 .tieloc store
-1000 .tieval store
stop
'Every now and then, share shell around
''Not immediately to prevent overproduction
cond
*.timer 50 mod 1 =
start
50 .shareshell store
stop
'End of cycle
''update custom vars and IO ports
''Tie regulation
''Eyes have sharpshooter eyes
''Body regulation - feed of other cells if they
''are too big
''Nrg and waste regulation
''Prevent nasty tricks
''Body parts aim to side
start
-6 .tieloc store
1000 *.tin9 10 mult add *.trefbody sub 0 ceil .tieval store
40 .stifftie store
100 .tielen store
-15 *.type .tail sub sgn abs -- abs mult .eye5width store
*.type .tout2 store
*.numties .prevties store
*.type .middle sub sgn abs -- abs 314 mult *.timer 2 mod 2 mult -- mult dup .aimshoot store
.eye5dir store
50 .sharenrg store
50 .sharewaste store
500 *.tout9 10 mult add *.body sub dup .strbody store - .fdbody store
.fixpos store
.backshot store
*.mkvirus .delgene store
stop