Exemple #1
0
def dar_features(policy, state: GameState):
    if not policy.use_image:
        posicion_pacman = state.getPacmanPosition()
        posicion_fantasma = state.getGhostPosition(1)
        temp = np.nonzero(np.array(state.getFood().data))
        if state.data._win:
            posicion_comida = posicion_pacman
        else:
            posicion_comida = (int(temp[0]), int(temp[1]))
        distancia_a_comida = np.linalg.norm(
            np.array(posicion_pacman) - np.array(posicion_comida))
        res = [distancia_a_comida
               ] + list(posicion_pacman) + list(posicion_fantasma)
        return res
    else:
        return np.array(policy.mapeo_fn(str(state))).reshape(
            policy.height, policy.width, 1)