Bots and Simulations > DNA - General

DNA language

(1/2) > >>

Lorgar:
If I understand well; you can write a bot dna like this
cond
*.eye5 0!=
*.refeye 0 =
start
'deal with veggie
stop

start
*.eye5 0 !=
*.refeye *.myeye !=
*.refeye 0!=
start
'kill the dreaded foe with much bloodshed and slaughter
stop

cond
*.eye5 0 !=
*.refeye *.myeye =
start
'move away from siblings
stop
end

Or you can write it like this
start
If *.eye5 0 !=
 If *.refeye *.myeye !=
  if *.refeye 0 =
   start 'deal with veggy
   else deal with foe
  else 'deal with family
Else 'look around
stop
the problem is that I can not figure how I can translate it using "clearbool, dupbool, etc"
I dunno if I wrote it well, I did not use elseif things. If you see a mistake in either code, please point it out.

Shasta:
I wrote a tutorial on the wiki about how to do this, not perfect, but should get you started.

Lorgar:
I read it, but cant grasp a thing  :(
http://darwinbots.com/WikiManual/index.php/Inline_Conditions_Tutorial
first :
Can not see how the boolean stack work, do store action "use" the upper unit of the boolean stack? or does it remain un changed after the action has been made? What is the clearbool command use (if the boolean stack is cleared at the end of the cycle?) how do you make sure that this boolean value should be merged with this one to be used in the last statement, if they are not different? I printed it, read through and through for days but cant understand how you use it.

what I do not understand is all the complicated use of dupbool command, overbool etc, if a boolean value is not deleted when an action is made, why bother dup it if it stay where it is? why reduce the size of the boolean stack  if it is cleared after stop command? why not only use simple not command when you need an else?

If the boolean is evaluated before any action, does this evaluation delete the top unit of the boolean stack?
I read the tutos but still... (yes when I will have understood that I feel that I will be able to understand the tuto about conditionless bots).
why am I so stupid?

Shasta:
Here is a quick example of how the boolean stack works. I put the action performed, and the state of the boolean stack one after another. The labels (A, B, C, etc.) are there to illustrate how some commands work, they are not truly there and have no effect. Note that this all happens while the DNA is being processed each cycle. These commands could all happen one after another in DNA and it would give the exact same result as I have written down here. Any command that does not operate on the boolean stack (store, add, shoot) will take place only if the top value on the boolean stack is true.


--- Code: ---50 40 <
    (1) False - A
50 40 >
    (1) True - B
    (2) False - A
50 40 =
    (1) False - C
    (2) True - B
    (3) False - A
overbool
    (1) True - B'
    (2) False - C
    (3) True - B
    (4) False - A
and
    (1) False - (B' and C)
    (2) True - B
    (3) False - A
dupbool
    (1) False - (B' and C)
    (2) False - (B' and C)
    (3) True - B
    (4) False - A
not
    (1) True - (not (B' and C))
    (2) False - (B' and C)
    (3) True - B
    (4) False - A
or
    (1) True - ((B' and C) or (not (B' and C))
    (2) True - B
    (3) False - A
swapbool
    (1) True - B
    (2) True - ((B' and C) or (not (B' and C))
    (3) False - A
dropbool
    (1) True - ((B' and C) or (not (B' and C))
    (2) False - A
true
    (1) True - D
    (2) True - ((B' and C) or (not (B' and C))
    (3) False - A
clearbool
    (empty)

--- End code ---

Lorgar:
I understand this, but when an action take place, will it automaticaly delete the top value of the boolean stack?
If when reaching start there are two or more values on the boolean stack, first action will use the first, delet it then use the second for the second action?

Navigation

[0] Message Index

[#] Next page

Go to full version