'Tribolis 0.3
'A multibot by Bacillus
'Updates from previous version:
'Tweaked Variables
'Changed defensive scheme
'Introduced patience factor to help split up bots
'Issues with Tribolis:
''Branching limbs didn't work properly
'SYSVARS
''Amount to wait before panicking
def patience 997
''Amount of ties last cycle
def prevties 998
''Type of body part
def type 999
'Defense controls
def sustshell 988
def sustpoison 989
'Body part variables
def head 1
def middle 2
def tail 3
'Velocity Variables
''MinV-minimum velocity sustained by organism
def minv 20
''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
''3-Xpos
''4-Ypos
''5-Shell Info
''6-Poison Info
''8-Worm size
''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
*.tout9 .tout8 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
''Also calls tail
cond
*.type .head =
*.eyef 0 >
*.in1 *.out1 !=
start
*.refxpos *.refypos angle .setaim store
*.refxpos .tout3 store
*.refypos .tout4 store
stop
'No food, stop tail from coming
cond
*.type .head =
*.eyef 0 =
*.in1 *.out1 = or
start
.tout3 store
.tout4 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
'Relay info
cond
*.type .middle =
start
.tout7 dec
*.tin3 .tout3 store
*.tin4 .tout4 store
*.tin8 .tout8 store
stop
'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
'Fix broken organsims
''Patience is needed
cond
*.type .middle =
*.numties 1 =
start
.patience inc
stop
''OK, time to break up
cond
*.type .middle =
*.numties 1 =
*.patience 25 =
start
0 .patience store
*.tiepres .deltie store
stop
'TAIL DNA REGION
'Tail stuns prey
cond
*.type .tail =
*.in1 *.out1 !=
*.eye5 30 >
*.reffixed 0 =
start
.shootval inc
.fixpos .shoot 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
'DEFENSE SYSTEM
'Kill off foreign ties
cond
*.tin1 *.tout1 !=
start
*.tiepres .deltie store
stop
'Remember shots
cond
*.shflav -1 =
start
.shoot .ploc store
.sustpoison inc
stop
cond
*.shflav -6 =
start
.sustshell inc
stop
'Relay shot info
cond
*.tin5 *.tout5 >
start
*.tin5 .sustshell store
stop
cond
*.tin6 *.tout6 >
start
*.tin6 .sustpoison store
stop
'REPRODUCTION
'Form new cell
cond
*.numties 1 =
*.type .head =
*.nrg 5500 *.tout9 100 mult add >
*.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
'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
40 .stifftie store
*.sustshell *.nrg 6 div ceil .tout5 store
*.sustpoison *.nrg 6 div ceil .tout6 store
*.sustshell *.shell sub .mkshell store
*.sustpoison *.poison sub .strpoison store
-15 *.type .tail sub sgn abs -- abs mult 100 *.type .middle sub sgn abs -- abs mult add .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
0 .fixpos store
0 .backshot store
*.mkvirus .delgene store
stop