Author Topic: codules  (Read 3050 times)

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
codules
« 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.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
codules
« Reply #1 on: December 23, 2009, 12:38:39 PM »
Primarily code reuse.

Offline ikke

  • Bot Destroyer
  • ***
  • Posts: 300
    • View Profile
codules
« Reply #2 on: December 23, 2009, 03:41:58 PM »
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

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
codules
« Reply #3 on: December 23, 2009, 04:12:05 PM »
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.

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
codules
« Reply #4 on: January 16, 2010, 12:00:00 AM »
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
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)