Code center > Dead-End and Solved Suggestion Requests

Mathematics in Conditions

<< < (3/3)

Numsgil:
You lack a compiler?  Perish the thought! ;)   Look here.  Can't say how long it will be available, so snatch it up!  No MSDN though, but you can always find hep on the internet.
The problem with mathematics in conditions, is, as you say, when mutated bots begin doing more than simple stack manipulation in a cond statement.

Store, inc, and dec should not work in a condition statement.  Easy enough fix, but what if this happens?:

cond
56
start
10 store
stop

Bad bad, here's some possible solutions.  Tell me which you like better:
* Ignore problem and live with it.
* Can't add more values to the stack at the end of a condition than were there to begin with.  You can, however, remove values from a stack.  So this:


--- Code: ---cond
start
56
stop

cond
32 >
start
do stuff...
stop
--- End code ---

will work, but this won't (won't increment 25 that is):


--- Code: ---cond
56 32 >
25
start
inc
stop
--- End code ---

The only bug is when two values are removed and one is added.  Then the problem I showed above is still possible.

* All newly placed stack vars are removed at the end of the cond.  That is, stack values are removed until the stack reaches values that were there before the cond started.

PurpleYouko:

--- Quote ---cond
56
start
10 store
stop
--- End quote ---

Why exactly is this bad? It works this way now without any kind of hitch.

Try running this ultra simple test bot. It just moves forward continuously using a system exactly like the one you describe above.

 :D  PY  :D

PurpleYouko:
I don't really see this as a problem. You can make some really good use out of this for programming interesting behaviour.

I would agree that no actions should be taken in the cond. Values in memory cells must not be changed so inc, dec and store should not work there but there is no harm in placing stuff on the stack.

At the moment it isn't possible to use these in the cond at all. (modify my tester bot by moving the store command into the cond to see this)
All we would need to do to perform math in the cond is to allow mathematical operators to work without any kind of memory cell manipulation (store, inc, dec)

 :D  PY  :D

Numsgil:
This should work now in 2.4.  Even though no one has tried running it yet...

Anyway, thought people should know.

Navigation

[0] Message Index

[*] Previous page

Go to full version