Darwinbots Forum
Code center => Darwinbots3 => Topic started by: ikke on December 23, 2009, 07:04:53 AM
-
I'm not quite sure I grasp the codule concept, and maybe that is the reason for the question, but what is the benefit for an evolved bot in developing codules? As I see them they are more or less functions, more of use for easily being able to program more complex bots, than of is in an evo.
-
Primarily code reuse.
-
I fail to see how that would work. Only the last store is actually executed, so running the same code twice gives no advantage. Inversely, if the codule is already called any subsequent call is void, if I understand correctly
-
The call is voided if the codule already exists in the call stack. But you can call the same codule repeatedly since it would pop from the call stack after it's finished each time.
Codules don't segment the other stacks at all. So you could have a codule that just does something like:
up store
And stores the top value of the stack in to .up Then if you called that multiple times it would overwrite values in .up. Or the codule might just store random values to random places (as is common with zerobots) and this would allow that code to easily be replicated.
-
It's also possible for the logic in the codule to be affected by the value of a memory location altered by it. In this situation, more calls might do different things. For example:
customvariablename inc
5 customvariablename * store