protected int getNeighbor(int cellId, Directions dir) {
        if (cellId > countCells() - 1) {
            return countCells() - 1;
        }
        if (cellId < 0) {
            return 0;
        }
        Vector<Integer> sortedNeighbors = getSortedNeighbors(cellId);
        if (dir == Directions.none) {
            return cellId;
        } else {
            return sortedNeighbors.get(dir.getValue() % 6);
        }
    }