Author Topic: Tuning gene  (Read 1957 times)

Offline d-EVO

  • Bot Destroyer
  • ***
  • Posts: 125
    • View Profile
Tuning gene
« on: December 18, 2008, 03:12:56 PM »
No more trouble choosing constants
because YOU DONT HAVE TO !!!  

this gene can "tune" any constant you want.
some examples are:
turning constants, shootval, up, repro (not recomended), and baisicaly any other constant.

This gene works by storing a value in ratial memory (the constant to be tuned),
Any child that the bot has will randomly inc or dec the constant,
the more successful child will have the most children and pass the more successful constant on (baisicaly, very controlled evolution)
Capable of producing realy finly tuned bots.

Here is the code (actualy consits of 2 genes)

first you can define the constant to a memory location,
it is nt nessicary but will make it more readable,
a RACTIAL memory location MUST be used ( 971 -990 )

Code: [Select]
def iset 972           'this is so the bot knows if it has already set an initial value, only the first bot will initiate the primary constant
def constant 971    'the "constant" can be replaced with anything you want, eg. shootvalue, aimright, moveup (note: must not be the same name as an existing memory name

Now you need to initiate the constant,
the first constant can be totaly random or a specific value

Code: [Select]
'initial random setup
cond
 *.robage 0 =
 *.iset 0 =
start
 .iset inc
 100 rnd .constant store
stop

Code: [Select]
'initial specified setup
cond
 *.robage 0 =
 *.iset 0 =
start
 .iset inc
 50 .constant store
stop

now the constant is inced or deced
note: this gene will only inc or dec the constant 50% of the time, this can be changed of course

Code: [Select]
'evo constant
cond
 *.robage 0 =
start
 'evo
 1 rnd 970 add dup
 1 rnd 0 =
 inc
 not
 dec
 dropbool
stop

And what you do now is instead of puting the actuale constant were you want it, you put the memory location of were it is stored
example:

instead of writing

20 .shootval store

you write

*.constant .shootval store

to see what the constant is, you simply view the bots memory location to which the constant is stored

The following is a mod af animal_minimalus
It changes shootval to find its optimum value in its location
once you found the optimum value, you can replace the constant in the bot you are developing with the one that the *.constant memory location holds

The following are to bots I developed,
First is a mod of Animal_minimalis that develops its shootval, the optimal constant I found for shootval was 32
The second is totaly original and capable of developing interesting swarming capabilities, note: this bot develops multiple constants

Code: [Select]
'evoless evo
'Animal_Adaptis

'seting vars
def iset 972
def shootvalue 971

'initial random setup
cond
 *.robage 0 =
 *.iset 0 =
start
 .iset inc
 100 rnd .shootvalue store
stop

'setup / evo
cond
 *.robage 0 =
start
 'evo
 1 rnd 970 add dup
 1 rnd 0 =
 inc
 not
 dec
 dropbool
stop

' Food Finder
cond
 *.eye5 0 >
 *.refeye *.myeye !=
start
 *.refveldx .dx store
 *.refvelup 30 add .up store
stop

' Eat Food
cond
 *.robage 0 !=
 *.eye5 50 >
 *.refeye *.myeye !=
start
*.shootvalue .shootval store
-1 .shoot store
 *.refvelup .up store
stop

' Avoiding Family
cond
 *.eye5 0 =
 *.refeye *.myeye = or
start
 314 rnd .aimdx store
stop

' Reproduce
cond
 *.nrg 20000 >
start
 30 .repro store
stop

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

end

Code: [Select]
'evoless evo
'Adaptive_preditor

'seting vars
def iset 971
def mconup 972
def mconsx 973
def mcondx 974
def scondi 975

'initial random setup
cond
 *.robage 0 =
 *.iset 0 =
start
 .iset inc
 100 rnd .mconup store
 100 rnd .mconsx store
 100 rnd .mcondx store
 100 rnd .scondi store
stop

'setup / evo
cond
 *.robage 0 =
start
 'setting eyes
 40 .eye5width store
 60 .eye1width store
 60 .eye9width store
 'evo
 5 rnd 970 add dup
 1 rnd 0 =
 inc
 not
 dec
 dropbool
stop

'chasing food / feeding

cond
 *.robage 0 >
 *.eye5 0 >
 *.refeye *.myeye !=
start
 *.eye5 *.scondi >
 -1 .shoot store
 not
 *.mconup .up store
 dropbool
stop

'finding food

cond
 *.eye1 *.eye9 add 0 =
 *.eye5 0 =
 *.refeye *.myeye = or and
 *.robage 0 >
start
 rnd *.mcondx *.mcondx add .aimdx store
stop

cond
 *.eye1 *.eye9 >
 *.eye5 0 =
 *.refeye *.myeye = or and
 *.robage 0 >
start
 *.mconsx .aimsx store
 *.mconup .up store
stop

cond
 *.eye9 *.eye1 >
 *.eye5 0 =
 *.refeye *.myeye = or and
 *.robage 0 >
start
 *.mcondx .aimdx store
 *.mconup .up store
stop

cond
 *.scondi *.eyef <
 *.refeye *.myeye =
 *.robage 0 >
start
 *.mconup .dn store
 0 .up store
stop

'reprodicing

cond
 *.nrg 3000 >
start
 30 .repro store
stop

1:      2 is true
2:      1 is false

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
Tuning gene
« Reply #1 on: December 19, 2008, 07:27:28 AM »
Quote
*.mconup .dn store
0 .up store
up and dn are opposites? Not sure what the code actually does

Offline d-EVO

  • Bot Destroyer
  • ***
  • Posts: 125
    • View Profile
Tuning gene
« Reply #2 on: December 19, 2008, 10:22:15 AM »
Quote from: ikke
Quote
*.mconup .dn store
0 .up store
up and dn are opposites? Not sure what the code actually does

what can happen is it can store a value in up and then when it stores a value in down it cancels each other out and the bot doesnt move ore move's incorrectly

I could add a condition to the gene which moves it down but I was to lazy.
0 .up store is much simpler than a whole lot of conditions that may not work.
sure its a waste of a store, but what is one store. It is not a league bot so who cares?

tell me what you think of it
« Last Edit: December 19, 2008, 05:49:12 PM by d-EVO »
1:      2 is true
2:      1 is false

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
Tuning gene
« Reply #3 on: December 19, 2008, 10:29:05 AM »
Quote from: d-EVO
what can happen is it can store a value in up and then when it stores a value in down it cancels each other out and the bot doesnt move ore move's incorrectly
Not sure if this is correct. up and down are different memory locations, so you should be able to save different values in them. The DBII code may or may not have an algorithm to link the locations or resolve conflicts between information in the locations

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7716
    • View Profile
Tuning gene
« Reply #4 on: December 19, 2008, 03:39:57 PM »
When the sysvars are processed, *.up and *.dn are subtracted (up - dn) to arrive at a final value representing the desired forward motion.  Same with *.sx and *.dx.  So if you have a bot storing 10 in .up and 10 in .dn, it won't move anywhere and won't use any nrg beyond that needed to store every cycle.

Offline d-EVO

  • Bot Destroyer
  • ***
  • Posts: 125
    • View Profile
Tuning gene
« Reply #5 on: December 19, 2008, 05:47:59 PM »
Quote from: Numsgil
When the sysvars are processed, *.up and *.dn are subtracted (up - dn) to arrive at a final value representing the desired forward motion.  Same with *.sx and *.dx.  So if you have a bot storing 10 in .up and 10 in .dn, it won't move anywhere and won't use any nrg beyond that needed to store every cycle.

Man
You can explainthings so much better than I can  
Ya, that is what I ment
1:      2 is true
2:      1 is false

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7716
    • View Profile
Tuning gene
« Reply #6 on: December 19, 2008, 07:36:47 PM »
It helps to have been neck deep in the source code

Offline d-EVO

  • Bot Destroyer
  • ***
  • Posts: 125
    • View Profile
Tuning gene
« Reply #7 on: December 20, 2008, 11:08:09 AM »
Quote from: Numsgil
It helps to have been neck deep in the source code
lol, good point
getting into it.
got a lot to cover alot of stuff about c# so dont expect any contributions any time soon
1:      2 is true
2:      1 is false

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7716
    • View Profile
Tuning gene
« Reply #8 on: December 20, 2008, 12:30:03 PM »