def update_location_4way(self, env, loc):
    '\n        Samples a valid four-way action and updates location \n        '
    length = env.shape[0]
    valid = False
    while (not valid):
        action = np.random.randint(0, 4)
        if (action == 0):
            if ((loc[0] - 1) >= 0):
                loc[0] -= 1
                valid = True
        elif (action == 1):
            if ((loc[1] + 1) < length):
                loc[1] += 1
                valid = True
        elif (action == 2):
            if ((loc[0] + 1) < length):
                loc[0] += 1
                valid = True
        elif (action == 3):
            if ((loc[1] - 1) >= 0):
                loc[1] -= 1
                valid = True
    act = np.zeros(4)
    act[action] = 1
    return (act, loc)
Samples a valid four-way action and updates location
def update_location_4way(self, env, loc):
    '\n         \n        '
    length = env.shape[0]
    valid = False
    while (not valid):
        action = np.random.randint(0, 4)
        if (action == 0):
            if ((loc[0] - 1) >= 0):
                loc[0] -= 1
                valid = True
        elif (action == 1):
            if ((loc[1] + 1) < length):
                loc[1] += 1
                valid = True
        elif (action == 2):
            if ((loc[0] + 1) < length):
                loc[0] += 1
                valid = True
        elif (action == 3):
            if ((loc[1] - 1) >= 0):
                loc[1] -= 1
                valid = True
    act = np.zeros(4)
    act[action] = 1
    return (act, loc)