diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Randomizer2.cpp | 25 | ||||
-rw-r--r-- | Source/Randomizer2Core.cpp | 5 |
2 files changed, 27 insertions, 3 deletions
diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index 993e7cc..107950d 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp | |||
@@ -175,20 +175,39 @@ void Randomizer2::RandomizeSymmetry() { | |||
175 | p.grid[2][0].end = Cell::Dir::UP; | 175 | p.grid[2][0].end = Cell::Dir::UP; |
176 | p.grid[6][0].end = Cell::Dir::UP; | 176 | p.grid[6][0].end = Cell::Dir::UP; |
177 | std::vector<Pos> cutEdges = Randomizer2Core::CutSymmetricalEdgePairs(p, 4); | 177 | std::vector<Pos> cutEdges = Randomizer2Core::CutSymmetricalEdgePairs(p, 4); |
178 | bool alternate = false; | ||
179 | for (int i=0; i<cutEdges.size(); i++) { | 178 | for (int i=0; i<cutEdges.size(); i++) { |
180 | Pos pos = cutEdges[i]; | 179 | Pos pos = cutEdges[i]; |
181 | if (alternate) { | 180 | if (i%2 == 0) { |
182 | p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK; | 181 | p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK; |
183 | } else { | 182 | } else { |
184 | Pos sym = p.GetSymmetricalPos(pos.x, pos.y); | 183 | Pos sym = p.GetSymmetricalPos(pos.x, pos.y); |
185 | p.grid[sym.x][sym.y].gap = Cell::Gap::BREAK; | 184 | p.grid[sym.x][sym.y].gap = Cell::Gap::BREAK; |
186 | } | 185 | } |
187 | alternate = !alternate; | ||
188 | } | 186 | } |
189 | 187 | ||
190 | _serializer.WritePuzzle(p, 0x87); | 188 | _serializer.WritePuzzle(p, 0x87); |
191 | } | 189 | } |
190 | { // Back wall 3 | ||
191 | Puzzle p; | ||
192 | p.NewGrid(5, 6); | ||
193 | p.symmetry = Puzzle::Symmetry::X; | ||
194 | p.grid[2][10].start = true; | ||
195 | p.grid[8][10].start = true; | ||
196 | p.grid[4][0].end = Cell::Dir::UP; | ||
197 | p.grid[6][0].end = Cell::Dir::UP; | ||
198 | std::vector<Pos> cutEdges = Randomizer2Core::CutSymmetricalEdgePairs(p, 10); | ||
199 | for (int i=0; i<cutEdges.size(); i++) { | ||
200 | Pos pos = cutEdges[i]; | ||
201 | if (i%2 == 0) { | ||
202 | p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK; | ||
203 | } else { | ||
204 | Pos sym = p.GetSymmetricalPos(pos.x, pos.y); | ||
205 | p.grid[sym.x][sym.y].gap = Cell::Gap::BREAK; | ||
206 | } | ||
207 | } | ||
208 | |||
209 | _serializer.WritePuzzle(p, 0x59); | ||
210 | } | ||
192 | } | 211 | } |
193 | 212 | ||
194 | void Randomizer2::RandomizeKeep() { | 213 | void Randomizer2::RandomizeKeep() { |
diff --git a/Source/Randomizer2Core.cpp b/Source/Randomizer2Core.cpp index 5cae049..ceb726b 100644 --- a/Source/Randomizer2Core.cpp +++ b/Source/Randomizer2Core.cpp | |||
@@ -24,6 +24,11 @@ std::vector<Pos> Randomizer2Core::CutSymmetricalEdgePairs(const Puzzle& p, size_ | |||
24 | for (int y=0; y<p.height; y++) { | 24 | for (int y=0; y<p.height; y++) { |
25 | copy.grid[p.width/2][y].gap = Cell::Gap::FULL; | 25 | copy.grid[p.width/2][y].gap = Cell::Gap::FULL; |
26 | } | 26 | } |
27 | } else { | ||
28 | // The puzzle has an odd width (e.g. 3x3), but we still need to cut the midline. | ||
29 | for (int y=0; y<p.height; y++) { | ||
30 | copy.grid[p.width/2][y].gap = Cell::Gap::FULL; | ||
31 | } | ||
27 | } | 32 | } |
28 | 33 | ||
29 | return CutEdgesInternal(copy, 0, (p.width-1)/2, 0, p.height, numEdges); | 34 | return CutEdgesInternal(copy, 0, (p.width-1)/2, 0, p.height, numEdges); |