Code center > Darwinbots3

Boolean memory

(1/5) > >>

Numsgil:
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.)

Billy:
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?

Numsgil:
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.

Billy:
Okay, I'm confused.

Numsgil:
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.

Navigation

[0] Message Index

[#] Next page

Go to full version