diff options
-rw-r--r-- | board.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -160,15 +160,13 @@ const vector<int>& Board::getEdgeCells() const { Bounds Board::computeBounds() const { Bounds bounds; - for (int y = 1; y < BSZ - 1; y++) { - for (int x = 1; x < BSZ - 1; x++) { - int idx = BSZ * y + x; - if (bd[idx] != 0 || checkEdge(idx)) { - bounds.left = min(bounds.left, x); - bounds.right = max(bounds.right, x); - bounds.top = min(bounds.top, y); - bounds.bottom = max(bounds.bottom, y); - } + for (int idx : edgeCells) { + int x = idx % BSZ, y = idx / BSZ; + if (bd[idx] != 0 || checkEdge(idx)) { + bounds.left = min(bounds.left, x); + bounds.right = max(bounds.right, x); + bounds.top = min(bounds.top, y); + bounds.bottom = max(bounds.bottom, y); } } |