コード例 #1
0
def agent():
    env = RemoteEnv(IN_PORT=8081, OUT_PORT=7071)
    env.open(0)
    for i in range(10000000):
        state = env.step("restart")
        done = state['done']
        print('new episode')
        while not done:
            frame = image_from_str(state['state'], 10, 10)
            print(frame)
            action = int(input('action'))
            state = env.step("move", action)
            done = state['done']
            print(state)
    env.close()
コード例 #2
0
def prepare_data(data):
    img = image_from_str(data['state'], 10, 10)
    img = img.reshape(1, 10, 10)
    img = np.moveaxis(img, 0, -1)
    img = np.array([img])
    return tf.convert_to_tensor(img, dtype=tf.float32)
コード例 #3
0
def get_frame_from_fields(fields):
    imgdata = image_from_str(fields['frame'], 40, 40)
    return imgdata
コード例 #4
0
def get_frame_from_fields(fields):
    imgdata = image_from_str(fields['state'], 10, 10)
    return imgdata