Example #1
0
def test_interpreter_constraints(push_config: PushConfig, instr_set: InstructionSet):
    name = "infinite_growth"
    sig = ProgramSignature(arity=0, output_stacks=["int"], push_config=push_config)
    interpreter = PushInterpreter(instr_set)
    cb = load_code(name, interpreter)
    program = Program(code=cb, signature=sig)
    output = interpreter.run(program, [0], print_trace=True)
    assert output[0] == int(push_config.numeric_magnitude_limit)
    assert interpreter.status == PushInterpreterStatus.step_limit_exceeded
Example #2
0
def get_program(name: str, sig: ProgramSignature,
                interpreter: PushInterpreter):
    cb = load_code(name, interpreter)
    return Program(code=cb, signature=sig)
Example #3
0
def simple_program(simple_genome, simple_program_signature):
    return Program(code=genome_to_code(simple_genome), signature=simple_program_signature)
Example #4
0
 def _errors_of_genome(self, genome: Genome) -> np.ndarray:
     cb = genome_to_code(genome)
     program = Program(code=cb, signature=self.program_signature)
     return self.evaluator.evaluate(program)
Example #5
0
 def program(self) -> Program:
     """Push program associated with this Individual. Taken from Plush genome."""
     if self._program is None:
         cb = genome_to_code(self.genome)
         self._program = Program(code=cb, signature=self.signature)
     return self._program