Summary: a single program in the Push programming language.A PushProgram object is a program in the Push programming language. To be used in conjunction with the class PushInterpreter.
Reading and writing a Push program to a file
Parsing programs and making random code
Copying and evolving Push programs
Getting information about a Push program
Copies the contents of otherProgram to this object.
Sets this object to a genetic crossover of p1 and p2.
Removes a random subtree from the code.
Flattens a random subtree in the code.
Determines the discrepancy between this program and otherProgram. This is defined as the number of points (atoms and subtrees) found in this program which do not exist in otherProgram, plus the number of points found in otherProgram that do not exist in this program.
This method considers the order of points in a program, and considers all sublists found in a program. For this reason, it is a good measure of similarity between two evolved programs. For a simpler comparison operator, suitable for comparing lists in which order should be preserved, see get-top-level-difference.
Returns a list representation of this push program.
Returns the size of this push program.
Returns the string representation of this push program.
Determines the top level difference between this program and otherProgram. This is calculated by comparing each element of the program against the corresponding element of otherProgram, with every mismatch counting as one point of difference. Sublists are not considered; each element in the top level list is treated as an atomic element.
This method is well suited for comparing lists produced as output of push programs. Because it does not consider sublists or order, it is not well suited for determining the true level of similarity between two programs as one might with to do with evolved code. For that type of functionality, see the method get-discrepancy.
Returns the "top-level" size of this push program, meaning that sublists are counted as one item, and not counted recursively.
Makes a random push program of length size. Size is an optional argument with a default value of 100. The size may also be equal to -1, which indicates that the MAX-POINTS-IN-RANDOM-EXPRESSION value from the Push configuration file should be used. The interpreter provided specifies the instruction set used to generate the random code.
Mutates this code object by adding a new subtree. The maximum size of the subtree is specified in the optional argument treeSize, which has a default value of 50. The size may also be equal to -1 (the default), indicating that the MAX-POINTS-IN-RANDOM-EXPRESSION value from the Push configuration file should be used. The interpreter argument determines the instruction set used to generate the random code.
Mutation is implemented as "fair" mutation with a range of +/- 30% of the mutated subtree.
The max-new-code-size argument is ignored, but included for backwards compatibility.
Sets the content of this code to the newly parsed string. The with-interpreter keyword is no longer required.
Reads a push program from a text file.
Swaps the positions of the top level sublists x and y.
Writes this push program to a text file.