[Push] Random code generation

PerPlex Ed edperplex at yahoo.com
Sun Jun 20 09:00:33 EDT 2010


Function RANDOM-CODE-WITH-SIZE (input: POINTS)
  If POINTS is 1 then choose a random element of the instruction
     set. If this is an ephemeral random constant then return a
     randomly-chosen value of the appropriate type; otherwise
     return the chosen element.
  ...

From this description I understand that the set of all possible
elements to be returned is

<all possible kinds of ephemeral random constants> + <all instructions> + <all defined instructions>

"<all defined instructions>" is not actually contained in that description 
but it's mentioned few lines above, if I recall correctly.

Since the number of instruction is 2 order of magnitude bigger than
then number of all possible kinds of ephemeral random constants (which is
the number of activated "value types"), I get code that will fail in most
of the cases because the instructions have no inputs on the stack.
So this can't be the correct procedure. How do I have to read that?

The following lisp source code seems to confirm my impression

(defun random-code-with-size (points)
  "Returns a random expression containing the given number of points."
  (if (< points 2)
    (expand-erc (random-element 
                 (append *ephemeral-random-constant-generators* 
                         *active-push-instructions*
                         (mapcar #'first *defined-instructions*))))
    (let ((elements-this-level
           (shuffle (decompose (- points 1) (- points 1)))))
          (mapcar #'random-code-with-size elements-this-level))))

Is it really the better choice? Did you do so because otherwise it would
add some bias in the kind of code generated?

Thanks!


      



More information about the Push mailing list