list<POINT> Exploration::getNeighbors(int x, int y, const MAP &map) { list<POINT> neighbours; if(!map.isInside(x, y)) //validate coordinates of the given cell return neighbours; if (map.isInside(x - 1, y - 1)) //top left neighbours.push_back(POINT(x - 1, y - 1)); if (map.isInside(x - 1, y)) //top neighbours.push_back(POINT(x - 1, y)); if (map.isInside(x - 1, y + 1)) //top right neighbours.push_back(POINT(x - 1, y + 1)); if (map.isInside(x, y - 1)) //left neighbours.push_back(POINT(x, y - 1)); if (map.isInside(x, y + 1)) //right neighbours.push_back(POINT(x, y + 1)); if (map.isInside(x + 1, y - 1)) //bottom left neighbours.push_back(POINT(x + 1, y - 1)); if (map.isInside(x + 1, y)) //bottom neighbours.push_back(POINT(x + 1, y)); if (map.isInside(x + 1, y + 1)) //bottom right neighbours.push_back(POINT(x + 1, y + 1)); return neighbours; }