From 2222a8ce5de5f46b762473001101aa10a0884bc1 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Mon, 25 Nov 2019 18:19:04 -0800 Subject: Fix bug, finalize symmetry wall --- Source/PuzzleSerializer.cpp | 10 ++++++---- Source/PuzzleSerializer.h | 2 +- Source/Randomizer2.cpp | 4 ++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index 8165fe8..be2d857 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp @@ -49,10 +49,12 @@ void PuzzleSerializer::WritePuzzle(const Puzzle& p, int id) { if (p.height > p.width) { INTERVAL = (MAX - MIN) / (p.height - (p.height%2)); + GAP_SIZE = (MAX - MIN) / (2 * p.width); X_OFF = (p.height - p.width) / 2; Y_OFF = 0; } else { INTERVAL = (MAX - MIN) / (p.width - (p.width%2)); + GAP_SIZE = (MAX - MIN) / (2 * p.height); X_OFF = 0; Y_OFF = (p.width - p.height) / 2; } @@ -411,22 +413,22 @@ void PuzzleSerializer::WriteGaps(const Puzzle& p) { gap1Location = static_cast(_intersectionFlags.size()); _connectionsA[connectionLocation] = xy_to_loc(p, x, y-1); _connectionsB[connectionLocation] = gap1Location; - AddIntersection(p, x, y, xPos, yPos + INTERVAL / 4, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); + AddIntersection(p, x, y, xPos, yPos + GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); gap2Location = static_cast(_intersectionFlags.size()); _connectionsA.push_back(xy_to_loc(p, x, y+1)); _connectionsB.push_back(gap2Location); - AddIntersection(p, x, y, xPos, yPos - INTERVAL / 4, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); + AddIntersection(p, x, y, xPos, yPos - GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); } else if (y%2 == 0) { // Horizontal gap gap1Location = static_cast(_intersectionFlags.size()); _connectionsA[connectionLocation] = xy_to_loc(p, x-1, y); _connectionsB[connectionLocation] = gap1Location; - AddIntersection(p, x, y, xPos - INTERVAL / 4, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); + AddIntersection(p, x, y, xPos - GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); gap2Location = static_cast(_intersectionFlags.size()); _connectionsA.push_back(xy_to_loc(p, x+1, y)); _connectionsB.push_back(gap2Location); - AddIntersection(p, x, y, xPos + INTERVAL / 4, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); + AddIntersection(p, x, y, xPos + GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); } if (p.symmetry != Puzzle::Symmetry::NONE) { if (p.grid[x][y].gap == Cell::Gap::NONE) { diff --git a/Source/PuzzleSerializer.h b/Source/PuzzleSerializer.h index 4ccd383..391f5c0 100644 --- a/Source/PuzzleSerializer.h +++ b/Source/PuzzleSerializer.h @@ -65,6 +65,6 @@ private: // Locations of non-grid points, i.e. dots, gaps, and endpoints std::unordered_map _extraLocations; - float MIN, MAX, INTERVAL; + float MIN, MAX, INTERVAL, GAP_SIZE; int X_OFF, Y_OFF; }; diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index d2046bb..f93e4fd 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp @@ -253,6 +253,10 @@ void Randomizer2::RandomizeSymmetry() { p.grid[pos.x + 12][pos.y].gap = Cell::Gap::BREAK; } + for (int y=0; y