def valid_position(grid, state):
    """Checking to make sure that the state is still in the grid and that it is not an obstacle.

    :param grid: Used to make sure the state is within the the grid and the state is not 0 (an obstacle)
    :param state: The possible state to validate
    :return: boolean, true if state is a valid
    """

    # Checking that <i>,<j> from this state are in the grid and that the value is not a obstacle(value of 0)
    if state[0] in range(0, grid.shape[0]) and state[1] in range(0, grid.shape[1]) and grid[state] != 0:
        return True
    else:
        return False