Exemplo n.º 1
0
  /**
   * Generates a random Push program of a given size.
   *
   * @param inSize The requested size for the program to be generated.
   * @return A random Push program of the given size.
   */
  public Program RandomCode(int inSize) {
    Program p = new Program();

    List<Integer> distribution = RandomCodeDistribution(inSize - 1, inSize - 1);

    for (int i = 0; i < distribution.size(); i++) {
      int count = distribution.get(i);

      if (count == 1) {
        p.push(RandomAtom());
      } else {
        p.push(RandomCode(count));
      }
    }

    return p;
  }