a peak at the edge of the grid is not a peak
An optimisation over a bounded grid returns the best point it visited. If that point sits at the boundary of the search, the result is not an optimum; it is a statement that the search ran out of room, and the two are indistinguishable…