Example #1
0
def get_field(data):
    result = {}
    p = Program(data, [], pause_on_output=True)
    while not p.halted:
        p.outputs.clear()
        p.run_times(3)
        if not p.halted:
            x, y, tile = p.outputs
            result[(x, y)] = tile
    return result
Example #2
0
def run_robot(data, start_with_white):
    p = Program(data, [], pause_on_output=True)
    r = Robot()
    if start_with_white:
        r.painted[0j] = 1
    while True:
        p.inputs = [r.get_camera()]
        p.outputs.clear()
        p.run_times(2)
        if p.halted:
            break
        color, turn = p.outputs
        r.step(color, turn)
    return r