about summary refs log tree commit diff stats
path: root/Source/Randomizer2Core.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Randomizer2Core.cpp')
-rw-r--r--Source/Randomizer2Core.cpp30
1 files changed, 9 insertions, 21 deletions
diff --git a/Source/Randomizer2Core.cpp b/Source/Randomizer2Core.cpp index 8bd5765..0310ae2 100644 --- a/Source/Randomizer2Core.cpp +++ b/Source/Randomizer2Core.cpp
@@ -6,31 +6,19 @@
6#include <iostream> 6#include <iostream>
7#include <cassert> 7#include <cassert>
8 8
9// @Cutnpaste 9std::vector<Pos> Randomizer2Core::CutEdges(const Puzzle& p, size_t numEdges, bool allowEdges) {
10std::vector<Pos> Randomizer2Core::CutEdges(const Puzzle& p, size_t numEdges) {
11 std::vector<Pos> edges; 10 std::vector<Pos> edges;
12 for (int x=0; x<p.width; x++) { 11 int xMin = allowEdges ? 0 : 1;
13 for (int y=0; y<p.height; y++) { 12 int xMax = allowEdges ? p.width : p.width-1;
14 if (x%2 == y%2) continue; 13 int yMin = allowEdges ? 0 : 1;
15 if (p.grid[x][y].gap != Cell::Gap::NONE) continue; 14 int yMax = allowEdges ? p.height : p.height-1;
16 15
17 // If the puzzle already has a sequence, don't cut along it. 16 for (int x=xMin; x<xMax; x++) {
18 bool inSequence = false; 17 for (int y=yMin; y<yMax; y++) {
19 for (Pos pos : p.sequence) inSequence |= (pos.x == x && pos.y == y);
20 if (inSequence) continue;
21 edges.emplace_back(Pos{x, y});
22 }
23 }
24 return CutEdgesInternal(p, edges, numEdges);
25}
26
27std::vector<Pos> Randomizer2Core::CutEdges2(const Puzzle& p, size_t numEdges) {
28 std::vector<Pos> edges;
29 // Note the iterator bounds; we skip the outer edges.
30 for (int x=1; x<p.width-1; x++) {
31 for (int y=1; y<p.height-1; y++) {
32 if (x%2 == y%2) continue; 18 if (x%2 == y%2) continue;
33 if (p.grid[x][y].gap != Cell::Gap::NONE) continue; 19 if (p.grid[x][y].gap != Cell::Gap::NONE) continue;
20 if (p.grid[x][y].start) continue;
21 if (p.grid[x][y].end != Cell::Dir::NONE) continue;
34 22
35 // If the puzzle already has a sequence, don't cut along it. 23 // If the puzzle already has a sequence, don't cut along it.
36 bool inSequence = false; 24 bool inSequence = false;