Author Topic: Boolean memory  (Read 9523 times)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Boolean memory
« on: February 25, 2011, 09:11:24 PM »
I'm playing with the idea for bots to have a memory array of booleans in addition to the one for integers.

I suspect most people wouldn't care either way, but I have two different ideas for how this would work in DNA; if anyone has any compelling ideas for which one to choose, etc. I'd like to talk this through.

Idea 1:
If 'store' is storing to a negative location, it pops a value from the boolean stack instead of the integer stack and stores it in boolean memory.

Example:

true -10 store would store 'true' to the 10th element of the boolean memory array.

Pros: No additional commands
Cons: The behavior of store, as far as whether it pops the boolean stack or integer stack, is not immediately evident in all cases, since you have to figure out the sign of the top value of the integer stack when the store command is called.

Idea 2:
A separate command stores to the boolean stack.  Maybe:

true 10 flag (here, flag is being treated as a verb with it's definition which means "to signal")

Pros: It's easier to link up boolean sysvars that might control a specific integer's behavior, since they can share the same address.  It's a stupid example, but if there were a "Launch X ICBMs" sysvar, you could have the corresponding number in the boolean array control whether the command should be obeyed or not.  Eg: true .icbmlaunch flag 10 .icbmlaunch store.  I can't think of any real sysvars we'd want to do this for, but an idea anyway.

Also, we can add extra commands that don't necessarily make sense for the integer array.  Things like "toggle", which would turn that memory location to its reverse.  Likewise, right now the DNA module doesn't have inc, but it we added it, it only makes sense for an integer array.

Cons: More commands (whether that's bad or not depends on your perspective, though, I suppose).

...

Anyway, the main reason I'm thinking about this is that we could add a "waituntil" command to the DNA that would cause the executing chromosome to abort execution of the DNA until a certain boolean memory location were true.  Then, when the boolean memory location is true again, it can resume from that location in teh DNA.  Makes it possible to build DNA scripts meant to run over several cycles, like a high level instruction set for building a multibot.

Also, some sysvars are inherently boolean in nature and it's not always easy to think of a continuous version that makes numbers from [-9999, 9999] meaningful.  Vision, for instance.  .isBot is just more intuitive than some sort of coded type system (1 = bot, 2 = shape, etc.)

Offline Billy

  • Bot Destroyer
  • ***
  • Posts: 175
    • View Profile
Re: Boolean memory
« Reply #1 on: February 26, 2011, 08:02:18 AM »
Hmm. How would maths work with this? Say you want to go forward if X (bool) is true in a conditionless bot, what would you do? Would 40 .up *.X mult store work? When trying to multiply by true, is it treated at one?
"I cannot persuade myself that a beneficent and omnipotent God would have designedly created parasitic wasps with the express intention of their feeding within the living bodies of Caterpillars."

-Charles Darwin

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Boolean memory
« Reply #2 on: February 26, 2011, 11:17:20 PM »
booleans are on a separate stack from integers, and mult only works with integers.

'store' still either works or not based on the top value of the (boolean) stack.  That would be true regardless of which of the two ideas we end up using.

Offline Billy

  • Bot Destroyer
  • ***
  • Posts: 175
    • View Profile
Re: Boolean memory
« Reply #3 on: February 27, 2011, 05:05:21 AM »
Okay, I'm confused.
"I cannot persuade myself that a beneficent and omnipotent God would have designedly created parasitic wasps with the express intention of their feeding within the living bodies of Caterpillars."

-Charles Darwin

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Boolean memory
« Reply #4 on: February 27, 2011, 05:54:50 PM »
Ah actually, when I work through it, my first idea wouldn't work anyway, because the top value of the bool stack has to be true or the store command won't work anyway.  So you could only ever store 'true' values to boolean memory.  I'll need to work through the second idea and see if I can make it work, then.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Boolean memory
« Reply #5 on: March 19, 2011, 03:49:56 PM »
I will go with this if we can intergrade it better with condition structure, otherwise we get the same annoyance you guys Xed me from implementing earlier:

Remember when I was going to tweak Pandas code to use vegetable or chloroplast settings, and you guys said it will be confusing for the end user to have both?

similar situation here...

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Boolean memory
« Reply #6 on: July 02, 2011, 12:00:19 PM »
How about:

1.) Let's say we got 20 genes

2.) In the code we got -40 store

This means on the next cycle:

The 40 mod 20 gene's activation is reversed.

I am only suggesting this because, in my evo sim , there is less then 1% use of the condition part of the gene.
« Last Edit: July 02, 2011, 12:05:47 PM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Boolean memory
« Reply #7 on: July 04, 2011, 12:37:29 AM »
The new DNA doesn't really understand what a "gene" is.  It's just a stream of byte code.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Boolean memory
« Reply #8 on: August 14, 2011, 01:16:38 PM »
wha? :blink: details plz??

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Boolean memory
« Reply #9 on: August 14, 2011, 10:24:15 PM »
Take a look at the thread about DNA.  There's an interpreter there to play with.

There just isn't anything analogous to a gene.  It's just a list of instructions that get followed in a more or less linear fashion.  Maybe codules could be seen as a analog to a gene.  But the comparison is sorta weak.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Boolean memory
« Reply #10 on: August 15, 2011, 02:07:39 PM »
Quote
I've implemented the in-place condition programming I talked about in another thread.  stores and codule calls (not implemented yet, but it will be) will still pull values from the stack, but nothing will happen if the top value on the bool stack is false.  An empty bool stack is treated as true.

Can you give an example?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Boolean memory
« Reply #11 on: August 15, 2011, 10:08:09 PM »
Code: [Select]
false
10 20 store
*20

Try that in the interpreter.  You should get back 0 on the stack.  Meaning that the store to memloc 20 didn't happen.

Compare with this code:
Code: [Select]
true
10 20 store
*20

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Boolean memory
« Reply #12 on: August 16, 2011, 01:15:00 PM »
oh, ok (I still can not find the thread with your interpreter though, I hope it is an exe...)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Re: Boolean memory
« Reply #13 on: August 17, 2011, 01:25:56 PM »
Try this thread

It was stickied at the top of the forum.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
Re: Boolean memory
« Reply #14 on: January 21, 2012, 04:28:30 PM »
somewhat related:

Can we add inttobool and booltoint?

inttobool takes (duplicate into memory) a number on the integer stack converts it to a bool ( int > 0) and does a push into the bool stack
booltoint takes (duplicate into memory) a boolean on the bool stack converts it to an integer (0 or 1) and does a push into the integer stack