diff options
| -rw-r--r-- | Source/PuzzleSerializer.cpp | 10 | ||||
| -rw-r--r-- | Source/PuzzleSerializer.h | 2 | ||||
| -rw-r--r-- | 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) { | |||
| 49 | 49 | ||
| 50 | if (p.height > p.width) { | 50 | if (p.height > p.width) { |
| 51 | INTERVAL = (MAX - MIN) / (p.height - (p.height%2)); | 51 | INTERVAL = (MAX - MIN) / (p.height - (p.height%2)); |
| 52 | GAP_SIZE = (MAX - MIN) / (2 * p.width); | ||
| 52 | X_OFF = (p.height - p.width) / 2; | 53 | X_OFF = (p.height - p.width) / 2; |
| 53 | Y_OFF = 0; | 54 | Y_OFF = 0; |
| 54 | } else { | 55 | } else { |
| 55 | INTERVAL = (MAX - MIN) / (p.width - (p.width%2)); | 56 | INTERVAL = (MAX - MIN) / (p.width - (p.width%2)); |
| 57 | GAP_SIZE = (MAX - MIN) / (2 * p.height); | ||
| 56 | X_OFF = 0; | 58 | X_OFF = 0; |
| 57 | Y_OFF = (p.width - p.height) / 2; | 59 | Y_OFF = (p.width - p.height) / 2; |
| 58 | } | 60 | } |
| @@ -411,22 +413,22 @@ void PuzzleSerializer::WriteGaps(const Puzzle& p) { | |||
| 411 | gap1Location = static_cast<int>(_intersectionFlags.size()); | 413 | gap1Location = static_cast<int>(_intersectionFlags.size()); |
| 412 | _connectionsA[connectionLocation] = xy_to_loc(p, x, y-1); | 414 | _connectionsA[connectionLocation] = xy_to_loc(p, x, y-1); |
| 413 | _connectionsB[connectionLocation] = gap1Location; | 415 | _connectionsB[connectionLocation] = gap1Location; |
| 414 | AddIntersection(p, x, y, xPos, yPos + INTERVAL / 4, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); | 416 | AddIntersection(p, x, y, xPos, yPos + GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); |
| 415 | 417 | ||
| 416 | gap2Location = static_cast<int>(_intersectionFlags.size()); | 418 | gap2Location = static_cast<int>(_intersectionFlags.size()); |
| 417 | _connectionsA.push_back(xy_to_loc(p, x, y+1)); | 419 | _connectionsA.push_back(xy_to_loc(p, x, y+1)); |
| 418 | _connectionsB.push_back(gap2Location); | 420 | _connectionsB.push_back(gap2Location); |
| 419 | AddIntersection(p, x, y, xPos, yPos - INTERVAL / 4, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); | 421 | AddIntersection(p, x, y, xPos, yPos - GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); |
| 420 | } else if (y%2 == 0) { // Horizontal gap | 422 | } else if (y%2 == 0) { // Horizontal gap |
| 421 | gap1Location = static_cast<int>(_intersectionFlags.size()); | 423 | gap1Location = static_cast<int>(_intersectionFlags.size()); |
| 422 | _connectionsA[connectionLocation] = xy_to_loc(p, x-1, y); | 424 | _connectionsA[connectionLocation] = xy_to_loc(p, x-1, y); |
| 423 | _connectionsB[connectionLocation] = gap1Location; | 425 | _connectionsB[connectionLocation] = gap1Location; |
| 424 | AddIntersection(p, x, y, xPos - INTERVAL / 4, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); | 426 | AddIntersection(p, x, y, xPos - GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); |
| 425 | 427 | ||
| 426 | gap2Location = static_cast<int>(_intersectionFlags.size()); | 428 | gap2Location = static_cast<int>(_intersectionFlags.size()); |
| 427 | _connectionsA.push_back(xy_to_loc(p, x+1, y)); | 429 | _connectionsA.push_back(xy_to_loc(p, x+1, y)); |
| 428 | _connectionsB.push_back(gap2Location); | 430 | _connectionsB.push_back(gap2Location); |
| 429 | AddIntersection(p, x, y, xPos + INTERVAL / 4, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); | 431 | AddIntersection(p, x, y, xPos + GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); |
| 430 | } | 432 | } |
| 431 | if (p.symmetry != Puzzle::Symmetry::NONE) { | 433 | if (p.symmetry != Puzzle::Symmetry::NONE) { |
| 432 | if (p.grid[x][y].gap == Cell::Gap::NONE) { | 434 | 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: | |||
| 65 | // Locations of non-grid points, i.e. dots, gaps, and endpoints | 65 | // Locations of non-grid points, i.e. dots, gaps, and endpoints |
| 66 | std::unordered_map<int, int> _extraLocations; | 66 | std::unordered_map<int, int> _extraLocations; |
| 67 | 67 | ||
| 68 | float MIN, MAX, INTERVAL; | 68 | float MIN, MAX, INTERVAL, GAP_SIZE; |
| 69 | int X_OFF, Y_OFF; | 69 | int X_OFF, Y_OFF; |
| 70 | }; | 70 | }; |
| 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() { | |||
| 253 | p.grid[pos.x + 12][pos.y].gap = Cell::Gap::BREAK; | 253 | p.grid[pos.x + 12][pos.y].gap = Cell::Gap::BREAK; |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | for (int y=0; y<p.height; y+=2) { | ||
| 257 | p.grid[5][y].gap = Cell::Gap::BREAK; | ||
| 258 | } | ||
| 259 | |||
| 256 | _serializer.WritePuzzle(p, 0x5C); | 260 | _serializer.WritePuzzle(p, 0x5C); |
| 257 | } | 261 | } |
| 258 | } | 262 | } |
