Bots and Simulations > DNA - General

DNA language

<< < (2/2)

ikke:
no the values on the stack stay there until removed by clearbool(clears the entire boolean stack) or dropbool (removes the first from the stack)

Lorgar:
so, the problem is, how can I create the right combination of boolean command to combine two genes in one.
like this

--- Code: ---cond
*.eye5 0 =
start
'look around
stop

cond
*.eye5 0 !=
*.refeye *.myeye !=
start
'jump at the foe
stop

cond
*.refeye 0 =
start
'eat the lettuce
stop
end
--- End code ---
can I make some code like

--- Code: ---cond
*.eye5 0 !=
*.refeye *.myeye !=
*.refeye 0 =
start
'eat the lettuce
else jump at the foe
else look around
--- End code ---
using boolean commands?

edit : yes I can, as described in the tuto, but I do not understand How you build all the dropbool, and, not structure beforehand. Using tables? I would like to know the design process step by step...

Shasta:
Ok, so the goal is to take these three genes:

--- Code: ---cond
*.eye5 0 =
start
'look around
stop

cond
*.eye5 0 !=
*.refeye *.myeye !=
start
'jump at the foe
stop

cond
*.refeye 0 =
start
'eat the lettuce
stop
end

--- End code ---
and turn them into one.

So, lets look at the shared conditions. *.eye5 0 = and *.eye5 0 != will always be opposite one another, one true, one false. This means we actually only need one of them, the other two conditions are similar, but have a large enough twist that they must be computed separately. Now lets set up the first condition.


--- Code: ---start
*.eye5 0 =
    'look around
stop

--- End code ---

Now, to add in the next conditions / actions we are going to reuse the value that is already on the boolean stack.

--- Code: ---start
*.eye5 0 =
    dupbool not 'duplicates and inverts the top value on the stack
        *.refeye *.myeye != and 'adds a new value to the top of the stack and combines it with the inverted value
            'jump at the foe
    dropbool 'remove the top value from the stack, we now only have the value of *.eye5 0 = on the stack
    dupbool not 'duplicate and invert our initial condition again
        *.refeye 0 = and 'same as before
            'eat the lettuce
    dropbool 'returns to initial condition
        'look around
stop

--- End code ---

This code can be simplified a touch by using a single != and removing some of the nots but that's not a big deal.

Lorgar:
ok, I understand, the advantage of this writing is the combinations of three genes in one.
now, what would they be over this way of writing : (not using the boolean stack)

--- Code: ---cond
start
-2. shoot *.eye5 40 sub sgn add abs div mult store (if *.eye 5 40 > shoot what's in front)
stop
--- End code ---

What are the pro and cons? :huh:
(edit) I would like to know when and why I would be better off using boolean stack maneuvers instead of integer stack ones. Since both knows no conditions they both save the condition reading price. I gather that in THIS lay all their interest..?

Lorgar:
ok, after some thinking, I would say : the use of the boolean stack in action blocks reduce significantly the size of the gene and allow to combine several genes in one.
I do not know the nrg cost of looking into the boolean stack during an action.

not using the boolean stack at all would be better (if just looking in it cost something) but would make for much longer genes, that would be a weakness against mutation...

Navigation

[0] Message Index

[*] Previous page

Go to full version