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.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/Source/Randomizer2Core.cpp b/Source/Randomizer2Core.cpp index dcb9fd2..8ef2301 100644 --- a/Source/Randomizer2Core.cpp +++ b/Source/Randomizer2Core.cpp
@@ -15,9 +15,16 @@ std::vector<Pos> Randomizer2Core::CutInsideEdges(const Puzzle& p, size_t numEdge
15} 15}
16 16
17std::vector<Pos> Randomizer2Core::CutSymmetricalEdgePairs(const Puzzle& p, size_t numEdges) { 17std::vector<Pos> Randomizer2Core::CutSymmetricalEdgePairs(const Puzzle& p, size_t numEdges) {
18 Puzzle copy = p;
18 assert(p.symmetry != Puzzle::Symmetry::NONE); 19 assert(p.symmetry != Puzzle::Symmetry::NONE);
19 if (p.symmetry == Puzzle::Symmetry::X) { 20 if (p.symmetry == Puzzle::Symmetry::X) {
20 return CutEdgesInternal(p, 0, (p.width-1)/2, 0, p.height, numEdges); 21 if (p.width%4 == 1) { // Puzzle is even, so we need to prevent cutting the centerline
22 for (int y=0; y<p.height; y++) {
23 copy.grid[p.width/2][y].gap = Cell::Gap::FULL;
24 }
25 }
26
27 return CutEdgesInternal(copy, 0, (p.width-1)/2, 0, p.height, numEdges);
21 } 28 }
22 assert(false); 29 assert(false);
23 return {}; 30 return {};
@@ -93,10 +100,11 @@ std::vector<Pos> Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, in
93 100
94void Randomizer2Core::DebugColorGrid(const std::vector<std::vector<int>>& colorGrid) { 101void Randomizer2Core::DebugColorGrid(const std::vector<std::vector<int>>& colorGrid) {
95#ifndef NDEBUG 102#ifndef NDEBUG
103 static std::string colors = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
96 for (int y=0; y<colorGrid[0].size(); y++) { 104 for (int y=0; y<colorGrid[0].size(); y++) {
97 std::string row; 105 std::string row;
98 for (int x=0; x<colorGrid.size(); x++) { 106 for (int x=0; x<colorGrid.size(); x++) {
99 row += std::to_string(colorGrid[x][y]); 107 row += colors[colorGrid[x][y]];
100 } 108 }
101 row += "\n"; 109 row += "\n";
102 OutputDebugStringA(row.c_str()); 110 OutputDebugStringA(row.c_str());
@@ -128,13 +136,10 @@ void Randomizer2Core::FloodFillOutside(const Puzzle& p, std::vector<std::vector<
128 FloodFillOutside(p, colorGrid, x-1, y); 136 FloodFillOutside(p, colorGrid, x-1, y);
129} 137}
130 138
131/* 139// Color key:
132 undefined -> 1 (color of outside) or * (any colored cell) or -1 (edge/intersection not part of any region) 140// 0 (default): Uncolored
133 141// 1: Outside color and separator color
134 0 -> {} (this is a special edge case, which I don't need right now) 142// 2+: Flood-filled region color
135 1 -> 0 (uncolored / ready to color)
136 2 ->
137*/
138std::tuple<std::vector<std::vector<int>>, int> Randomizer2Core::CreateColorGrid(const Puzzle& p) { 143std::tuple<std::vector<std::vector<int>>, int> Randomizer2Core::CreateColorGrid(const Puzzle& p) {
139 std::vector<std::vector<int>> colorGrid; 144 std::vector<std::vector<int>> colorGrid;
140 colorGrid.resize(p.width); 145 colorGrid.resize(p.width);