Author Topic: Gene structure - cond start stop  (Read 14444 times)

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Gene structure - cond start stop
« Reply #15 on: November 15, 2007, 01:51:08 PM »
Quote
QUOTE(Botsareus @ Nov 8 2007, 11:11 AM)

Lets say the robot does .dx .up and .shoot within a single condition...



start
*.nrg 1000 >
10 .dx store
10 .up store
-1 .shoot store
stop

Would be sufficient.

I have a better idea, just stay with me, it gets complex. I will start from a simpe example. Then intermediate. then advanced.
I use "A" thru "Z" as code fragments:
If "A" is a 'condition it means something like: *.nrg 1000 >
If "A" is a 'action it means something like: -1 .shoot store
If you don't understand, quote what part you don't understand and I will try to explain in detail.
Introducing a new command called "conditionless"


example1: simple
Quote
A 'action
B 'condition
C 'action
D 'action
conditionless
E 'action
F 'action

the top of the dna is automaticaly conditionless, therefor the above means in the old db:

Quote
cond
start
A
stop
cond
B
start
C
D
stop
cond
start
E
F
stop

example2: very long but intermediate
Quote
A 'condition
B 'condition
C 'action
D or 'condition
E 'action
F and 'condition
G 'action
conditionless
H 'action
I 'condition
J 'action
K 'action
L 'action
conditionless
M 'action
N 'action
O 'action
P 'condition
Q 'action
R or 'condition
S 'condition
T 'action
UU or 'condition
V or 'condition
W 'action
X 'condition
Y or 'condition
Z 'action

means in old db:
Quote
cond
A
B
and
start
C
stop
cond
A
B
and
D
or
start
E
stop
cond
A
B
and
D
or
F
and
start
G
stop
cond
start
H
stop
cond
I
start
J
K
L
stop
cond
start
M
N
O
stop
cond
P
start
Q
stop
cond
P
R
or
S
and
start
T
stop
cond
P
R
or
S
and
UU
or
V
or
start
W
stop
cond
X
Y
or
start
Z
stop

example3: advanced example

Quote
A 'condition
B 'condition
C and 'condition
D 'action

means:

Quote
cond
A
B
C
and
and
start
D
stop

example 3b:

Quote
A 'condition
B 'condition
C and 'condition
or
D 'action

means:

Quote
cond
A
B
C
and
or
start
D
stop

example4: more advanced example

Quote
A 'condition
B 'condition
C and 'condition
D 'action
or
E 'action

means:

Quote
cond
A
B
C
and
and
start
D
stop
cond
A
B
C
and
or
start
E
stop

example5:  even more advanced example
Quote
A 'condition
B 'action
C 'condition
D and 'condition
E 'action
or
F 'action

means:

Quote
cond
A
start
B
stop
cond
C
D
and
start
E
stop
cond
A
C
D
and
or
start
F
stop

thank you for your time...
« Last Edit: November 15, 2007, 02:26:08 PM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Gene structure - cond start stop
« Reply #16 on: November 15, 2007, 04:13:30 PM »
That's basically how the system Eric's describing works Bots.  Instead of a conditionless command, you would just use cond to reset the boolean stack (I got that correct, right?)

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #17 on: November 15, 2007, 06:47:05 PM »
Yup.  It's already implemented in recent buddy drops.  Works well.
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Gene structure - cond start stop
« Reply #18 on: November 15, 2007, 08:13:05 PM »
I might need to write some abusive DNA now just to try it out

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #19 on: November 15, 2007, 09:00:55 PM »
Quote from: Numsgil
I might need to write some abusive DNA now just to try it out
Please do!  I've done a little testing, but not exhaustive.  My suspicsion is that this is a very powerful and profound change whose impact won't be fully explored or fully understood for months.
Many beers....

Offline Peksa

  • Bot Destroyer
  • ***
  • Posts: 118
    • View Profile
Gene structure - cond start stop
« Reply #20 on: November 24, 2007, 07:59:58 AM »
Looks very nice!

Just to check, if I understood this completely, would this work?

start
*.body *.nrg >
*.nrg 500 >
50 .strbody store
and
-50 .strbody store
stop


EDIT:
Oh, what about else? Would this work?

start
*.eye5 50 >
.shoot dec
else
314 rnd .aimsx store
stop
« Last Edit: November 24, 2007, 08:24:00 AM by Peksa »

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #21 on: November 24, 2007, 08:33:13 PM »
Quote from: Peksa
Just to check, if I understood this completely, would this work?

' Cooments below


start                 ' No cond section.  If stores followed this, their success would depend on boolean logic above
*.body *.nrg >        'Result of this is pushed on boolean stack.  Call it A.
*.nrg 500 >            'Result of this is pushed on boolean stack.  Call it B
50 .strbody store    ' store will occcur if B is True.  Will not if B is False.  There is no implicit AND of A and B
and                       'A is ANDed with B.  Result is pushed on Boolean stack.
-50 .strbody store  ' This store will happen if A AND B is True.
stop

Quote from: Peksa
EDIT:
Oh, what about else? Would this work?

start
*.eye5 50 >                ' Call this C
.shoot dec                   ' happens if C is true
else
314 rnd .aimsx store   ' Never happens.  Currently Else applies only to Cond section, which is missing here.
stop


But the same running boolean state works within else statements.  For example:


cond
false
start
1 *50 store
else
2 *50 store
2 1 <
3 *50 store
stop

memory location 50 will end up with a value of 2.
Many beers....

Offline Gobo

  • Bot Builder
  • **
  • Posts: 67
    • View Profile
Gene structure - cond start stop
« Reply #22 on: November 27, 2007, 10:57:09 AM »
Is there a way to clear the boolean stack within a gene's body?

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #23 on: November 27, 2007, 11:15:41 AM »
Quote from: Gobo
Is there a way to clear the boolean stack within a gene's body?

There isn't an explicit clear stack command.  A bunch of boolean logic operators which pop values would do it.  Something like 20 OR's for example, enough that you pop whatever is there and bottom the stack out so that the result of the last one is true.  

Another start won't do it.  It clears the stack after a Cond by ANDing it all up, but if the current state is the gene body already, it doesn't do anything.

EDIT:  Adding a Clear command might be usefull....
« Last Edit: November 27, 2007, 11:16:41 AM by EricL »
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Gene structure - cond start stop
« Reply #24 on: November 27, 2007, 11:30:54 AM »
I added a general purpose clear command that dumps both stacks to the DNA for Darwinbots 3, so I agree

Not sure if we need a single command for each stack or a single one for both stacks though.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #25 on: November 27, 2007, 07:47:33 PM »
I think we need two.  I can imagine cases where you want to clear the boolean stack for genome flow control reasons but keep your integer stack state.

I'm curious what do you mean by dumping the stack to DNA?
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Gene structure - cond start stop
« Reply #26 on: November 27, 2007, 08:44:47 PM »
oops, heh, typo.  I meant "that dumps both stacks from the DNA".

Offline Gobo

  • Bot Builder
  • **
  • Posts: 67
    • View Profile
Gene structure - cond start stop
« Reply #27 on: November 28, 2007, 07:20:16 PM »
It would be also nice to have a command that drops the top value from the boolean stack. It is an extremely important functionality, since it has sense of ENDIF. As for now, I couldn't express it with less than three commands: true or and. I think it's highly expensive (moreover difficult to evolve!) for such basic operation.
« Last Edit: November 28, 2007, 07:21:04 PM by Gobo »

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #28 on: November 28, 2007, 07:27:37 PM »
Sounds good to me.  So, I'll add four new commands:

clearbool   - empties the boolean stack.
clearint      - empties the integer stack
popbool     - pops a value off the boolean stack.
popint       - pops a value off the integer stack

Okay?
Many beers....

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Gene structure - cond start stop
« Reply #29 on: November 29, 2007, 01:57:02 PM »
I don't like the idea of using cond bla start for else statements.
Here is what I propose:

Quote
*.eye5 50 > ' Call this C
.shoot dec ' happens if C is true
else
314 rnd .aimsx store 'happens if C is false

Quote
A 'condition
B 'condition
C and 'condition
D 'action
or
E 'action
else
F 'action



means:


Quote
cond
A
B
C
and
and
start
D
stop
cond
A
B
C
and
or
start
E
stop
cond
A
B
C
and
or
else
start
F
stop

look here:
cond
A
B
C
and
or
else
start
F
stop

If B or C is false, and A is false then run F




Quote from: EricL
Sounds good to me.  So, I'll add four new commands:

clearbool   - empties the boolean stack.
clearint      - empties the integer stack
popbool     - pops a value off the boolean stack.
popint       - pops a value off the integer stack

Okay?

I like the conditionless command better because then you don't have to worry about were to put the stop. I will add it myself when I get a chance to program on the outside.

I love the clearbool , clearint  commands because I will need them in my extreamly complex sexrepro system.

As far as popbool and popint commands see this post with updates: http://www.darwinbots.com/Forum/index.php?showtopic=2266
« Last Edit: November 29, 2007, 02:09:44 PM by Botsareus »