Author Topic: New Operator Ideas  (Read 2424 times)

Offline Anonomous Guest Person

  • Bot Builder
  • **
  • Posts: 85
    • View Profile
New Operator Ideas
« on: October 20, 2006, 05:02:27 PM »
It's already possible to do indirectly, but I figured why not suggest it anyway?

I don't know what it'd be called but it would check to see if there's a value on the stack. If so then it'll replace this value with 1, if not it'll add 0 to the stack.

However I don't know how the stack works... if the stack automatically has all zeroes in it at all times and has no means of telling whether a value in a stack is a 0 or is supposed to be nonexistant, then please tell me and forget the idea (sgn abs would work just as well if that's the case!)

(If you don't quite fully understand what I mean, then my love for writing examples forces me to show you the following:
0 checkstack
would return 1
while, assuming the stack doesn't have any garbage in it, simply
checkstack
would return 0.)

Additionally, a swap operator, which would basically reverse the top of the stack.
(For example:
1 2 swap
would have 1 on the top of the stack and 2 right below it.
Though this probably won't be a very good reason to use it, it would allow:
.shoot -1 swap store
to put -1 in the .shoot sysvar.)

And my final suggestion: A delete-the-top-of-the-stack operator. Which basically just gets rid of the top of the stack.

(In example:
-1 .shoot 25 del store
would put -1 into .shoot.)

Thanks for reading this, and sorry for posting so many suggestions.

[Edit]
Another idea I forgot!

The halt operation. I'm not quite sure how it'll work, but it'll skip the gene as soon as it's called with a certain value.
Perhaps if the value is 0 it'll halt. Or maybe non-zero. Or maybe positive, or negative.

Personally I prefer the "if the value is 0" bit though!

Adding this in would probably be yet another step torwards making genes merely illusions, though. And adding... almost any of these operators would be yet another step torwards making the bots closer to nanobots then organisms.

Whether those are good things or bad are up to you to decide, I guess!
« Last Edit: October 20, 2006, 05:17:08 PM by Anonomous Guest Person »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
New Operator Ideas
« Reply #1 on: October 20, 2006, 07:31:32 PM »
Quote from: Anonomous Guest Person
It's already possible to do indirectly, but I figured why not suggest it anyway?

I don't know what it'd be called but it would check to see if there's a value on the stack. If so then it'll replace this value with 1, if not it'll add 0 to the stack.

However I don't know how the stack works... if the stack automatically has all zeroes in it at all times and has no means of telling whether a value in a stack is a 0 or is supposed to be nonexistant, then please tell me and forget the idea (sgn abs would work just as well if that's the case!)

At present there is no way to tell if the stack is really empty or just has a 0 on top.  A command for returning the stack size is a valid candidate for a new command, since I can't see another way to do this.  Basically just places a number on to the stack that represents the size of the stack before the command was called.

Quote
Additionally, a swap operator, which would basically reverse the top of the stack.
(For example:
1 2 swap
would have 1 on the top of the stack and 2 right below it.
Though this probably won't be a very good reason to use it, it would allow:
.shoot -1 swap store
to put -1 in the .shoot sysvar.)

I had this idea as well.  I don't think it's possible to do without storing to a sysvar temporarily.  An XOR swap might be possible, but I don't see how you could do it.  So this is also a valid candidate for a new command.

Quote
And my final suggestion: A delete-the-top-of-the-stack operator. Which basically just gets rid of the top of the stack.

This is possible at the moment, so this is on shakier ground.

0 mult inc

would delete the top value of the stack.  (inc wouldn't do anything since it's trying to store to loc 0).

Quote
The halt operation. I'm not quite sure how it'll work, but it'll skip the gene as soon as it's called with a certain value.
Perhaps if the value is 0 it'll halt. Or maybe non-zero. Or maybe positive, or negative.

Personally I prefer the "if the value is 0" bit though!

This isn't possible at the moment, so this might be a good idea too.  However, codules might provide similar functionality by allowing for nesting conditionals.  Going the codule route would mean you'd need to do a great deal of creative architecting to get the DNA to run like you want.  ANd of course, codules don't exist at the moment, so that's an issue too

I dunno, there are alot of possibilities here.
« Last Edit: October 20, 2006, 07:33:15 PM by Numsgil »