Author Topic: My personal gene bank  (Read 1618 times)

Offline ashton15

  • Bot Builder
  • **
  • Posts: 99
    • View Profile
My personal gene bank
« on: April 05, 2010, 04:35:22 PM »
Here are a few things I've made. I planned to only release them with goggle goo: a bot I'm working on. I decided sharing is caring though so here's some bits and bobs I've made.

A more effcient way to store

dup *.memorylocation  sub sgn abs .memorylocation  mult store

Increases the efficiency of a store command, dramtically in some cases only stores a value if that value is not already stored in a certain location, an effective application could be:

87 dup *.memloc  sub sgn abs .memloc  mult store
27 dup *.memval  sub sgn abs .memval  mult store


For a memloc/memval based conspec recognition system this would reset the locations whenever they were alterd and at birth so poison would not badly damage them.

Body management

This keeps the body to energy ratio the same, storing 10 in .nrgratio results in a 1:1 ratio of body to energy storing 100 in .nrgratio results in having ten times the ammount of energy as body whilst storing one gives ten times the ammount of body compared to energy.

def nrgratio 100

start

10 dup *.nrgratio sub sgn abs .nrgratio mult store

100 .strbody *.nrg *.body 10 div *.nrgratio ++ mult       sub sgn 0 floor mult store
100 .fdbody        *.body 10 div *.nrgratio    mult *.nrg sub sgn 0 floor mult *.body 100 sub sgn 0 floor mult store

stop


A bit simpler, keeps body at a certain level, the main disadvantage to this is it will try and reach that body level at any cost, even if that means running out of energy and dieing

def bodyvalue 100

start

15 dup *.bodyvalue sub sgn abs .bodyvalue mult store

*.bodyvalue *.body sub .strbody *.bodyvalue *.body sub sgn abs mult store
*.bodyvalue *.body sub - .fdbody *.bodyvalue *.body sub sgn abs mult store
stop


Eye Setups

No fancy coding here, just two setups I plan to use, having the eyes to the side gives the benefit of whilst travelling forwards a wider path is surveyed

342  dup *.eye1dir   sub sgn abs .eye1dir   mult store
 223  dup *.eye2dir   sub sgn abs .eye2dir   mult store
 176  dup *.eye3dir   sub sgn abs .eye3dir   mult store
 78   dup *.eye4dir   sub sgn abs .eye4dir   mult store
 -78  dup *.eye6dir   sub sgn abs .eye6dir   mult store
 -176 dup *.eye7dir   sub sgn abs .eye7dir   mult store
 -223 dup *.eye8dir   sub sgn abs .eye8dir   mult store
 -342 dup *.eye9dir   sub sgn abs .eye9dir   mult store
 260  dup *.eye1width sub sgn abs .eye1width mult store
 -20  dup *.eye2width sub sgn abs .eye2width mult store
 115  dup *.eye3width sub sgn abs .eye3width mult store
 85   dup *.eye4width sub sgn abs .eye4width mult store
 70   dup *.eye5width sub sgn abs .eye5width mult store
 85   dup *.eye6width sub sgn abs .eye6width mult store
 115  dup *.eye7width sub sgn abs .eye7width mult store
 -20  dup *.eye8width sub sgn abs .eye8width mult store
 260  dup *.eye9width sub sgn abs .eye9width mult store


Pharlell center wieghted vision allows a bot to taget food in front better whilst keeping an eye out for predators approaching from behind

342  dup *.eye1dir   sub sgn abs .eye1dir   mult store
 143  dup *.eye2dir   sub sgn abs .eye2dir   mult store
 46   dup *.eye3dir   sub sgn abs .eye3dir   mult store
 3    dup *.eye4dir   sub sgn abs .eye4dir   mult store
 -3   dup *.eye6dir   sub sgn abs .eye6dir   mult store
 -46  dup *.eye7dir   sub sgn abs .eye7dir   mult store
 -143 dup *.eye8dir   sub sgn abs .eye8dir   mult store
 -342 dup *.eye9dir   sub sgn abs .eye9dir   mult store
 260  dup *.eye1width sub sgn abs .eye1width mult store
 135  dup *.eye2width sub sgn abs .eye2width mult store
 60   dup *.eye3width sub sgn abs .eye3width mult store
 25   dup *.eye4width sub sgn abs .eye4width mult store
 -20  dup *.eye5width sub sgn abs .eye5width mult store
 25   dup *.eye6width sub sgn abs .eye6width mult store
 60   dup *.eye7width sub sgn abs .eye7width mult store
 135  dup *.eye8width sub sgn abs .eye8width mult store
 260  dup *.eye9width sub sgn abs .eye9width mult store


Natrually selecting values

More or less does what fruitflies does but this has been slightly expanded, you will have to replace every instance of initvalue with the value you want the bots to start the sim with and every instance of maxvalue with what you want the maximum value selected to be. You could proably modify it to generate negative number and within a certain range ie -19 to 76 or 22 to 2098 rather than 0 to 168.

def initvalue 68
def maxvalue 69
def mutationchance 70

def rand1  71
def rand2  72
def rand3  73
def rand4  74
def rand5  75
def rand6  76
def rand7  77
def rand8  78
def rand9  79
def rand10 80
def rand11 81
def rand12 82
def rand13 83
def rand14 84
def rand15 85
def rand16 86
def rand17 87
def rand18 88
def rand19 89
def rand20 90

def select1 971
def select2 972
def select3 973
def select4 974
def select5 975
def select6 976
def select7 977
def select8 978
def select9 979
def select10 980
def select11 981
def select12 982
def select13 983
def select14 984
def select15 985
def select16 986
def select17 987
def select18 988
def select19 989
def select20 990
 
start

5 dup *.mutationchance sub sgn abs .mutationchance mult store

*.maxvalue *.mutationchance mult rnd .rand1  *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand2  *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand3  *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand4  *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand5  *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand6  *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand7  *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand8  *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand9  *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand10 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand11 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand12 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand13 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand14 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand15 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand16 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand17 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand18 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand19 *.robage sgn abs -- - mult store
*.maxvalue *.mutationchance mult rnd .rand20 *.robage sgn abs -- - mult store
*.rand1  .select1  *.maxvalue *.rand1  sub sgn mult *.select1  sgn mult *.robage sgn abs -- - mult store
*.rand2  .select2  *.maxvalue *.rand2  sub sgn mult *.select2  sgn mult *.robage sgn abs -- - mult store
*.rand3  .select3  *.maxvalue *.rand3  sub sgn mult *.select3  sgn mult *.robage sgn abs -- - mult store
*.rand4  .select4  *.maxvalue *.rand4  sub sgn mult *.select4  sgn mult *.robage sgn abs -- - mult store
*.rand5  .select5  *.maxvalue *.rand5  sub sgn mult *.select5  sgn mult *.robage sgn abs -- - mult store
*.rand6  .select6  *.maxvalue *.rand6  sub sgn mult *.select6  sgn mult *.robage sgn abs -- - mult store
*.rand7  .select7  *.maxvalue *.rand7  sub sgn mult *.select7  sgn mult *.robage sgn abs -- - mult store
*.rand8  .select8  *.maxvalue *.rand8  sub sgn mult *.select8  sgn mult *.robage sgn abs -- - mult store
*.rand9  .select9  *.maxvalue *.rand9  sub sgn mult *.select9  sgn mult *.robage sgn abs -- - mult store
*.rand10 .select10 *.maxvalue *.rand10 sub sgn mult *.select10 sgn mult *.robage sgn abs -- - mult store
*.rand11 .select11 *.maxvalue *.rand11 sub sgn mult *.select11 sgn mult *.robage sgn abs -- - mult store
*.rand12 .select12 *.maxvalue *.rand12 sub sgn mult *.select12 sgn mult *.robage sgn abs -- - mult store
*.rand13 .select13 *.maxvalue *.rand13 sub sgn mult *.select13 sgn mult *.robage sgn abs -- - mult store
*.rand14 .select14 *.maxvalue *.rand14 sub sgn mult *.select14 sgn mult *.robage sgn abs -- - mult store
*.rand15 .select15 *.maxvalue *.rand15 sub sgn mult *.select15 sgn mult *.robage sgn abs -- - mult store
*.rand16 .select16 *.maxvalue *.rand16 sub sgn mult *.select16 sgn mult *.robage sgn abs -- - mult store
*.rand17 .select17 *.maxvalue *.rand17 sub sgn mult *.select17 sgn mult *.robage sgn abs -- - mult store
*.rand18 .select18 *.maxvalue *.rand18 sub sgn mult *.select18 sgn mult *.robage sgn abs -- - mult store
*.rand19 .select19 *.maxvalue *.rand19 sub sgn mult *.select19 sgn mult *.robage sgn abs -- - mult store
*.rand20 .select20 *.maxvalue *.rand20 sub sgn mult *.select20 sgn mult *.robage sgn abs -- - mult store
*.initvalue .select1  *.select1  sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select2  *.select2  sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select3  *.select3  sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select4  *.select4  sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select5  *.select5  sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select6  *.select6  sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select7  *.select7  sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select8  *.select8  sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select9  *.select9  sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select10 *.select10 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select11 *.select11 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select12 *.select12 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select13 *.select13 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select14 *.select14 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select15 *.select15 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select16 *.select16 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select17 *.select17 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select18 *.select18 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select19 *.select19 sgn -- - mult *.robage sgn abs -- - mult store
*.initvalue .select20 *.select20 sgn -- - mult *.robage sgn abs -- - mult store

stop


Reproduction

With this gene you have a base enregy threshold like in alga_minimalis and then a certain ammount is added to the threshold for each member of the species which thus acts as population control.

def repronrg  100
def poprepro  101
def bodyrepro 102

start

50  dup *.repronrg  sub sgn abs .repronrg  mult store
40  dup *.poprepro  sub sgn abs .poprepro  mult store
850 dup *.bodyrepro sub sgn abs .bodyrepro mult store
 
*.repronrg .repro *.body *.bodyrepro *.totalmyspecies *.poprepro mult add sub sgn 0 floor mult 30 *.eye5 sub sgn 0 floor mult store

stop


Determining range

Determines how far a bot is and adjusts shootval so that the shot reaches it, the maximum ammount of energy to be spent on any one shot and power of a shot at point blank can be set

def power 100
def range 101

start

4  dup *.power sub sgn abs .power mult store
20 dup *.range sub sgn abs .range mult store

25044 217 *.eye1 600 mult sub div *.eye1width -17 div ++ mult 5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye1width sgn - mult        *.focuseye -4 sub sgn abs -- - mult *.eye1 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye2 600 mult sub div *.eye2width -17 div ++ mult 5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye2width sgn - mult        *.focuseye -3 sub sgn abs -- - mult *.eye2 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye3 600 mult sub div *.eye3width -17 div ++ mult 5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye3width sgn - mult        *.focuseye -2 sub sgn abs -- - mult *.eye3 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye4 600 mult sub div *.eye4width -17 div ++ mult 5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye4width sgn - mult        *.focuseye ++     sgn abs -- - mult *.eye4 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye5 600 mult sub div *.eye5width -17 div ++ mult 5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye5width sgn - mult        *.focuseye        sgn abs -- - mult *.eye5 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye6 600 mult sub div *.eye6width -17 div ++ mult 5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye6width sgn - mult        *.focuseye --     sgn abs -- - mult *.eye6 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye7 600 mult sub div *.eye7width -17 div ++ mult 5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye7width sgn - mult        *.focuseye 2  sub sgn abs -- - mult *.eye7 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye8 600 mult sub div *.eye8width -17 div ++ mult 5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye8width sgn - mult        *.focuseye 3  sub sgn abs -- - mult *.eye8 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye9 600 mult sub div *.eye9width -17 div ++ mult 5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye9width sgn - mult        *.focuseye 4  sub sgn abs -- - mult *.eye9 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye1 600 mult sub div *.eye1width 80  div ++ div  5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye1width sgn   mult        *.focuseye -4 sub sgn abs -- - mult *.eye1 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye2 600 mult sub div *.eye2width 80  div ++ div  5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye2width sgn   mult        *.focuseye -3 sub sgn abs -- - mult *.eye2 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye3 600 mult sub div *.eye3width 80 div  ++ div  5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye3width sgn   mult        *.focuseye -2 sub sgn abs -- - mult *.eye3 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye4 600 mult sub div *.eye4width 80 div  ++ div  5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye4width sgn   mult        *.focuseye ++     sgn abs -- - mult *.eye4 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye5 600 mult sub div *.eye5width 80 div  ++ div  5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye5width sgn   mult        *.focuseye        sgn abs -- - mult *.eye5 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye6 600 mult sub div *.eye6width 80 div  ++ div  5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye6width sgn   mult        *.focuseye --     sgn abs -- - mult *.eye6 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye7 600 mult sub div *.eye7width 80 div  ++ div  5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye7width sgn   mult        *.focuseye 2  sub sgn abs -- - mult *.eye7 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye8 600 mult sub div *.eye8width 80 div  ++ div  5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye8width sgn   mult        *.focuseye 3  sub sgn abs -- - mult *.eye8 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye9 600 mult sub div *.eye9width 80 div  ++ div  5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye9width sgn   mult        *.focuseye 4  sub sgn abs -- - mult *.eye9 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye1 600 mult sub div                             5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye1width sgn abs -- - mult *.focuseye -4 sub sgn abs -- - mult *.eye1 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye2 600 mult sub div                             5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye2width sgn abs -- - mult *.focuseye -3 sub sgn abs -- - mult *.eye2 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye3 600 mult sub div                             5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye3width sgn abs -- - mult *.focuseye -2 sub sgn abs -- - mult *.eye3 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye4 600 mult sub div                             5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye4width sgn abs -- - mult *.focuseye ++     sgn abs -- - mult *.eye4 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye5 600 mult sub div                             5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye5width sgn abs -- - mult *.focuseye        sgn abs -- - mult *.eye5 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye6 600 mult sub div                             5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye6width sgn abs -- - mult *.focuseye --     sgn abs -- - mult *.eye6 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye7 600 mult sub div                             5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye7width sgn abs -- - mult *.focuseye 2  sub sgn abs -- - mult *.eye7 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye8 600 mult sub div                             5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye8width sgn abs -- - mult *.focuseye 3  sub sgn abs -- - mult *.eye8 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store
25044 217 *.eye9 600 mult sub div                             5 mult 3 div dup sgn abs *.power mult add - *.range ceil - dup *.shootval sub sgn abs .shootval mult *.eye9width sgn abs -- - mult *.focuseye 4  sub sgn abs -- - mult *.eye9 sgn mult *.shoot sgn abs mult *.shoot -3 sub sgn abs mult *.shoot -4 sub sgn abs mult store

stop


Tracking Movement

Work in progress, when complete bot will turn to eye in which there has been the most change ie movement rather than whichever one has something closest to it like normal eyes, will also randomly glance to stop predators who may try to sneak up on the bot so it doesn't notice, it was inspired by the way we look natrually. So far what I've coded genrally works but is sometimes eratic and also it's pretty ineffcient but I'm getting there.
« Last Edit: April 05, 2010, 04:35:56 PM by ashton15 »