Author Topic: Gene structure - cond start stop  (Read 14442 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 #30 on: November 29, 2007, 02:29:36 PM »
Auto simplifing the command structute:

If we have
Quote
A 'condition
A 'condition
and
C 'action
It is changed to
Quote
A 'condition
C 'action

If we have
Quote
A 'condition
A 'condition
or
C 'action
It is changed to
Quote
A 'condition
C 'action

If we have
Quote
conditionless
A 'condition
or
C 'action
It is changed to
Quote
conditionless
C 'action

If we have
Quote
conditionless
A 'condition
and
C 'action
It is changed to
Quote
A 'condition
C 'action

  corrected

An else command simply works by reversing the top of the condition stack ex:

Quote
A 'condition
B 'condition
C 'condition
or
else
or

means

not(B or C) or A

---
If there is a cndmove , cndmdup , or cndmtt, the above codes do not apply.
move , mdup and mtt, change negative values to positive once. But if any input values is zero they are changed to one.
« Last Edit: November 30, 2007, 10:34:53 AM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Gene structure - cond start stop
« Reply #31 on: November 29, 2007, 03:27:49 PM »
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?

You could drop the int suffix, and have it just assumed.  So then you would have:

clearbool, clear, popbool, pop

Makes the syntax a little clearner, I think.

Offline Gobo

  • Bot Builder
  • **
  • Posts: 67
    • View Profile
Gene structure - cond start stop
« Reply #32 on: November 30, 2007, 05:06:43 AM »
I'd also shorten 'bool' to just 'b' and put it in the beginning and changed 'pop' to 'drop' (which is more descriptive)
Code: [Select]
drop
bdrop
clear
bclear

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 #33 on: November 30, 2007, 10:40:12 AM »
(see correction to the above post.)

More simplifications:

Quote
A 'condition
B 'action
A
C 'action

is simplfied as

Quote
A 'condition
B 'action
C 'action

If there is two elses in a row ex:
Quote
conditionless
else
else

is simplfied as

Quote
conditionless

---

Quote
conditionless
else
B 'action

is simplfied as

Quote
B 'action

---

Quote
conditionless
A 'action
else
B 'action

is simplfied as

Quote
B 'action
conditionless
A 'action
« Last Edit: November 30, 2007, 10:49:38 AM by Botsareus »

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #34 on: November 30, 2007, 10:59:33 AM »
Quote from: Numsgil
You could drop the int suffix, and have it just assumed.  So then you would have:

clearbool, clear, popbool, pop
Personally, I like the specificity of popint and popbool but then my code always has longHardToReadLongVariableNames.

Quote from: Gobo
I'd also shorten 'bool' to just 'b' and put it in the beginning and changed 'pop' to 'drop' (which is more descriptive)
I like 'bool' better than 'b' and I like 'pop' better than 'drop'.  Pop is the well understood term for popping a value off a stack and bool is more descriptive.

The code already supports sysvar synonyms: .aimdx and .aimright for example.  I could add built in operator synonyms or add an aliasing mechanism for DNA fiel parsing but I think I'll make it clearbool, clearint, popbool, popint for now.
Many beers....

Offline Gobo

  • Bot Builder
  • **
  • Posts: 67
    • View Profile
Gene structure - cond start stop
« Reply #35 on: November 30, 2007, 11:06:11 AM »
Quote from: EricL
I like 'bool' better than 'b' and I like 'pop' better than 'drop'.  Pop is the well understood term for popping a value off a stack and bool is more descriptive.
pop is well understood term for popping a value off a stack and store it in a variable or a register. It's drop that is used for discarding the top value in languages operating with stack, such as Forth. And 'bool' is too long itself to join it with something else, IMHO. I don't insist, I just try to explain my position.
« Last Edit: November 30, 2007, 11:07:46 AM by Gobo »

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #36 on: November 30, 2007, 11:18:56 AM »
Quote from: Gobo
b]pop[/b] is well understood term for popping a value off a stack and store it in a variable or a register. It's drop that is used for discarding the top value in languages operating with stack, such as Forth. And 'bool' is too long itself to join it with something else, IMHO. I don't insist, I just try to explain my position.
I've never coded in Forth.  My tiny brain just does not think of the term 'drop' as a stack operator.   Since actual pops to a location are implicit in DNA, I thought using it for drop was appropriate but if drop is the term actually used in real languages for a pop to nowhere, then we can go with that.  It's not a big deal.

I like longer, more descriptive names in general.  e.g. .totalmyspecies.  The only reason to keep things short is to make DNA text more compact for the human.  This all has no impact on the underlying numerical DNA of course.

Can we go with:

ClearBool
DropBool
ClearInt
DropInt
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Gene structure - cond start stop
« Reply #37 on: November 30, 2007, 04:33:47 PM »
I LikeVariableNamesThatAreLongAndDescriptiveToo, but the DNA language has a sort of assembly feel to it that just begs for 3 and 4 letter operators (sysvars not so much).

For DB3, I was toying with different stack operations based on booleans, nd ran into this same problem.  So for the boolean versions of dup and swap, (which we might want to add, too), I used dub and swab.  In general, most stack operations have a p in them.  push, pop, dup, swap, etc.  So the rule I chose was that operations on the boolean stack replace any instances of p with b.  Thus you have bob (like bobbing hair), swab, and dub.

Offline Peter

  • Bot God
  • *****
  • Posts: 1177
    • View Profile
Gene structure - cond start stop
« Reply #38 on: November 30, 2007, 04:47:36 PM »
Quote from: EricL
I like longer, more descriptive names in general.  e.g. .totalmyspecies.  The only reason to keep things short is to make DNA text more compact for the human.  This all has no impact on the underlying numerical DNA of course.

Can we go with:

ClearBool
DropBool
ClearInt
DropInt
I prefer a little longer above just a little too short. I fact at seeing it you have to know what it does, and at seeing this I know exactly wat it means, so I agree.
Oh my god, who the hell cares.

Offline Gobo

  • Bot Builder
  • **
  • Posts: 67
    • View Profile
Gene structure - cond start stop
« Reply #39 on: November 30, 2007, 05:12:24 PM »
Quote from: Numsgil
Thus you have bob (like bobbing hair), swab, and dub.
Though I'd prefer drob over bob anyway

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #40 on: November 30, 2007, 06:41:10 PM »
FYI, its implemented as

ClearBool
DropBool
ClearInt
DropInt

in 2.43u.  If someone really wants, I'll add synonyms.   Just ask.
Many beers....

Offline Gobo

  • Bot Builder
  • **
  • Posts: 67
    • View Profile
Gene structure - cond start stop
« Reply #41 on: November 30, 2007, 06:51:47 PM »
I hope, they are not case-sensitive, are they?  

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Gene structure - cond start stop
« Reply #42 on: November 30, 2007, 08:27:05 PM »
Quote from: Gobo
I hope, they are not case-sensitive, are they?  
All the sysvars get lowercased during DNA file parsing.  So, no.
« Last Edit: November 30, 2007, 08:28:06 PM by EricL »
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 #43 on: December 06, 2007, 01:39:43 PM »
I gess I will just have to program my alternate virsion myself...

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
Gene structure - cond start stop
« Reply #44 on: May 05, 2008, 10:40:42 PM »
Interesting. I definitely like the drop/clear bool/int commands. Back when I was playing/experimenting/etc, I was doing 'dup xor inc' to pop and discard a value from the stack.

The system I made for branching nested conditionals was rather complicated, and if these changes are in the latest released version of DarwinBots, then it sounds like you've made what I was doing there entirely pointless.

If anyone's curious, here's an example of what I was doing (the commented out lines are the original lines, which were translated to what's below them) - scroll down to the if (1): to see where the branch stuff is:

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']'NestedBranchTest.txt compiled by PyBot V1 from NestedBranchTest.pyr.

'def one1 at 991
def one1 991
'def one2 at 992
def one2 992
'def one3 at 993
def one3 993
'def one4 at 994
def one4 994
'def one5 at 995
def one5 995
'def zero1 at 981
def zero1 981
'def zero2 at 982
def zero2 982
'def zero3 at 983
def zero3 983
'def zero4 at 984
def zero4 984
'def zero5 at 985
def zero5 985
'def zero6 at 986
def zero6 986
'def outside1 at 1000
def outside1 1000
'if ():
cond

start
0 *980 1 sub sgn 0 floor *980 sgn - 0 floor | 980 mult store
'   #branch-use 980
'   #disable-storecheck
'   one1=0
0 .one1 store
'   one2=0
0 .one2 store
'   one3=0
0 .one3 store
'   one4=0
0 .one4 store
'   one5=0
0 .one5 store
'   zero1=0
0 .zero1 store
'   zero2=0
0 .zero2 store
'   zero3=0
0 .zero3 store
'   zero4=0
0 .zero4 store
'   zero5=0
0 .zero5 store
'   zero6=0
0 .zero6 store
'   outside1=0
0 .outside1 store
'   if (1):
1
'      one1 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .one1 *980 mult store
'      if (1):
dup dup 1 &
'         one2 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .one2 *980 mult store
'      elif 1:
- ++ & - ++ dup - ++ dup 1 &
'         zero2 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .zero2 *980 mult store
'      if 0:
add add dup ^ inc dup dup 0 &
'         zero3 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .zero3 *980 mult store
'      elif 1:
- ++ & - ++ dup - ++ dup 1 &
'         one3 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .one3 *980 mult store
'      else:
- ++ & - ++ | - ++
'         zero4 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .zero4 *980 mult store
'      if 0:
dup ^ inc dup dup 0 &
'         zero5 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .zero5 *980 mult store
'      elif 0:
- ++ & - ++ dup - ++ dup 0 &
'         zero6 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .zero6 *980 mult store
'      else:
- ++ & - ++ | - ++
'         one4 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .one4 *980 mult store
'      one5 = 1
dup ^ inc
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .one5 *980 mult store
'   else:
- ++
'      zero1 = 1
dup *980 - ++ & 980 mult inc dup - ++ *980 & 980 mult dec
1 .zero1 *980 mult store
'   outside1 = 1
dup ^ inc
1 .outside1 store
'   outside2 = 1
1 .outside2 store
stop



(There was some bug in DarwinBots at the time which was keeping that from working properly. I don't know if it's been fixed.)