(board, agent_positions)
return positions
Return inaccessible passages on this board.
Return inaccessible passages on this board.
Return inaccessible passages on this board .
def inaccessible_passages(board, agent_positions):
    """Return inaccessible passages on this board."""
    seen = set()
    agent_position = agent_positions.pop()
    passage_positions = np.where(board == constants.Item.Passage.value)
    positions = list(zip(passage_positions[0], passage_positions[1]))

    Q = [agent_position]
    while Q:
        row, col = Q.pop()
        for (i, j) in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            next_position = (row + i, col + j)
            if next_position in seen:
                continue
            if not position_on_board(board, next_position):
                continue
            if position_is_rigid(board, next_position):
                continue

            if next_position in positions:
                positions.pop(positions.index(next_position))
                if not len(positions):
                    return []

            seen.add(next_position)
            Q.append(next_position)
    return positions
def inaccessible_passages ( board , agent_positions ) : seen = set ( ) agent_position = agent_positions . pop ( ) passage_positions = np . where ( board == constants . Item . Passage . value ) positions = list ( zip ( passage_positions [ 0 ] , passage_positions [ 1 ] ) ) Q = [ agent_position ] while Q : row , col = Q . pop ( ) for ( i , j ) in [ ( 1 , 0 ) , ( - 1 , 0 ) , ( 0 , 1 ) , ( 0 , - 1 ) ] : next_position = ( row + i , col + j ) if next_position in seen : continue if not position_on_board ( board , next_position ) : continue if position_is_rigid ( board , next_position ) : continue if next_position in positions : positions . pop ( positions . index ( next_position ) ) if not len ( positions ) : return [ ] seen . add ( next_position ) Q . append ( next_position ) return positions