about summary refs log tree commit diff stats
path: root/Source/Randomizer2Core.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-11-26 10:06:47 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-11-26 10:06:47 -0800
commitda6dcacf4314463e33c29a0a2831fb3bf80f4d4c (patch)
tree6ae737be53c8be2f306e769cc3dc9853e180cee0 /Source/Randomizer2Core.cpp
parenta0e7ec171d68a17f8bcaeb5d8f4af881c3510280 (diff)
downloadwitness-tutorializer-da6dcacf4314463e33c29a0a2831fb3bf80f4d4c.tar.gz
witness-tutorializer-da6dcacf4314463e33c29a0a2831fb3bf80f4d4c.tar.bz2
witness-tutorializer-da6dcacf4314463e33c29a0a2831fb3bf80f4d4c.zip
WIP on end of glass factory
Diffstat (limited to 'Source/Randomizer2Core.cpp')
-rw-r--r--Source/Randomizer2Core.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/Source/Randomizer2Core.cpp b/Source/Randomizer2Core.cpp index 401743f..2a2c6ff 100644 --- a/Source/Randomizer2Core.cpp +++ b/Source/Randomizer2Core.cpp
@@ -17,15 +17,28 @@ std::vector<Pos> Randomizer2Core::CutSymmetricalEdgePairs(const Puzzle& p, size_
17 for (int y=0; y<p.height; y++) { 17 for (int y=0; y<p.height; y++) {
18 copy.grid[p.width/2][y].gap = Cell::Gap::FULL; 18 copy.grid[p.width/2][y].gap = Cell::Gap::FULL;
19 } 19 }
20 return CutEdgesInternal(copy, 0, (p.width-1)/2, 0, p.height, numEdges);
20 } else if (p.symmetry == Puzzle::Symmetry::Y) { 21 } else if (p.symmetry == Puzzle::Symmetry::Y) {
21 for (int x=0; x<p.width; x++) { 22 for (int x=0; x<p.width; x++) {
22 copy.grid[x][p.height/2].gap = Cell::Gap::FULL; 23 copy.grid[x][p.height/2].gap = Cell::Gap::FULL;
23 } 24 }
25 return CutEdgesInternal(copy, 0, p.width, 0, (p.height-1)/2, numEdges);
24 } else { 26 } else {
25 assert(p.symmetry == Puzzle::Symmetry::XY); 27 assert(p.symmetry == Puzzle::Symmetry::XY);
26 // Pass, I think? Maybe this matters for odd numbers. 28 if (p.width%4 == 1) {
29 assert(p.width == 9);
30 copy.grid[2][3];
31 copy.grid[3][4];
32 copy.grid[3][6];
33 copy.grid[4][3];
34 // For odd grids, cut the center out.
35 // for (int x=0; x<p.width; x++) {
36 // copy.grid[x][p.height/2].gap = Cell::Gap::FULL;
37 // }
38
39 }
40 return CutEdgesInternal(copy, 0, p.width, 0, p.height, numEdges);
27 } 41 }
28 return CutEdgesInternal(copy, 0, (p.width-1)/2, 0, p.height, numEdges);
29} 42}
30 43
31std::vector<Pos> Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, int xMax, int yMin, int yMax, size_t numEdges) { 44std::vector<Pos> Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, int xMax, int yMin, int yMax, size_t numEdges) {
@@ -36,6 +49,7 @@ std::vector<Pos> Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, in
36 if (p.grid[x][y].gap != Cell::Gap::NONE) continue; 49 if (p.grid[x][y].gap != Cell::Gap::NONE) continue;
37 if (p.grid[x][y].start) continue; 50 if (p.grid[x][y].start) continue;
38 if (p.grid[x][y].end != Cell::Dir::NONE) continue; 51 if (p.grid[x][y].end != Cell::Dir::NONE) continue;
52 if (p.symmetry == Puzzle::Symmetry::XY && x > y) continue; // Only allow cuts bottom-left of the diagonal
39 53
40 // If the puzzle already has a sequence, don't cut along it. 54 // If the puzzle already has a sequence, don't cut along it.
41 bool inSequence = false; 55 bool inSequence = false;
@@ -51,7 +65,7 @@ std::vector<Pos> Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, in
51 65
52 std::vector<Pos> cutEdges; 66 std::vector<Pos> cutEdges;
53 for (int i=0; i<numEdges; i++) { 67 for (int i=0; i<numEdges; i++) {
54 for (int j=0; j<edges.size(); j++) { 68 while (edges.size() > 0) {
55 int edge = Random::RandInt(0, static_cast<int>(edges.size() - 1)); 69 int edge = Random::RandInt(0, static_cast<int>(edges.size() - 1));
56 Pos pos = edges[edge]; 70 Pos pos = edges[edge];
57 edges.erase(edges.begin() + edge); 71 edges.erase(edges.begin() + edge);