From 9f4ea5694ec32507db1d28000fa52665e0e84323 Mon Sep 17 00:00:00 2001
From: jbzdarkid <jbzdarkid@gmail.com>
Date: Thu, 5 Dec 2019 09:43:23 -0800
Subject: Just forgot to write this section, I guess

---
 Source/PuzzleSerializer.cpp | 40 +++++++++++++++++--------------
 Source/Randomizer2.cpp      | 57 ++++++++++++++++++++++++++++++++-------------
 2 files changed, 64 insertions(+), 33 deletions(-)

(limited to 'Source')

diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp
index 29bd648..8faede9 100644
--- a/Source/PuzzleSerializer.cpp
+++ b/Source/PuzzleSerializer.cpp
@@ -493,25 +493,31 @@ void PuzzleSerializer::WriteSymmetry(const Puzzle& p, int id) {
     for (int x=0; x<p.width; x++) {
         for (int y=0; y<p.height; y++) {
             if (x%2 == y%2) continue;
-            if (p.grid[x][y].gap != Cell::Gap::BREAK) continue;
-
-            Pos sym = p.GetSymmetricalPos(x, y);
-            int location = extra_xy_to_loc(p, x, y);
-            int symLocation = extra_xy_to_loc(p, sym.x, sym.y);
-            // Each gap results in two intersections, @Assume they're written consecutively
-
-            if ((x%2 != 0 && p.symmetry & Puzzle::Symmetry::X) || 
-                (y%2 != 0 && p.symmetry & Puzzle::Symmetry::Y)) {
-                // Write data inverted, because it's being reflected
-                reflectionData[location] = symLocation-1;
-                reflectionData[location-1] = symLocation;
-                reflectionData[symLocation] = location-1;
-                reflectionData[symLocation-1] = location;
-            } else { // Write data normally
+            if (p.grid[x][y].gap == Cell::Gap::BREAK) {
+                Pos sym = p.GetSymmetricalPos(x, y);
+                int location = extra_xy_to_loc(p, x, y);
+                int symLocation = extra_xy_to_loc(p, sym.x, sym.y);
+                // Each gap results in two intersections, @Assume they're written consecutively
+
+                if ((x%2 != 0 && p.symmetry & Puzzle::Symmetry::X) || 
+                    (y%2 != 0 && p.symmetry & Puzzle::Symmetry::Y)) {
+                    // Write data inverted, because it's being reflected
+                    reflectionData[location] = symLocation-1;
+                    reflectionData[location-1] = symLocation;
+                    reflectionData[symLocation] = location-1;
+                    reflectionData[symLocation-1] = location;
+                } else { // Write data normally
+                    reflectionData[location] = symLocation;
+                    reflectionData[location-1] = symLocation-1;
+                    reflectionData[symLocation] = location;
+                    reflectionData[symLocation-1] = location-1;
+                }
+            } else if (p.grid[x][y].dot == Cell::Dot::BLACK) {
+                Pos sym = p.GetSymmetricalPos(x, y);
+                int location = extra_xy_to_loc(p, x, y);
+                int symLocation = extra_xy_to_loc(p, sym.x, sym.y);
                 reflectionData[location] = symLocation;
-                reflectionData[location-1] = symLocation-1;
                 reflectionData[symLocation] = location;
-                reflectionData[symLocation-1] = location-1;
             }
         }
     }
diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp
index e1b1712..0628414 100644
--- a/Source/Randomizer2.cpp
+++ b/Source/Randomizer2.cpp
@@ -381,32 +381,57 @@ void Randomizer2::RandomizeSymmetryIsland() {
         }
 
         for (int j=0;; j++) {
-            auto edgesCopy = edges;
+            std::vector<Pos> dots = Random::SelectFromSet(edges, 4);
+            for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK;
 
-            std::vector<Pos> dots;
-            for (int i=0; i<4; i++) {
-                int edge = Random::RandInt(0, static_cast<int>(edgesCopy.size() - 1));
-                dots.emplace_back(edgesCopy[edge]);
-                edgesCopy.erase(edgesCopy.begin() + edge);
-            }
+            auto solutions = Solver::Solve(p);
+            if (solutions.size() > 0 && solutions.size() < 10) break;
+
+            for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::NONE;
+        }
 
-            for (Pos pos : dots) {
-                p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK;
+        _serializer.WritePuzzle(p, 0xB0);
+    }
+
+    { // Dots 1
+        Puzzle p;
+        p.NewGrid(3, 3);
+        p.symmetry = Puzzle::Symmetry::Y;
+        p.grid[0][2].start = true;
+        p.grid[0][4].start = true;
+        p.grid[6][2].end = Cell::Dir::RIGHT;
+        p.grid[6][4].end = Cell::Dir::RIGHT;
+
+        std::vector<Pos> corners;
+        std::vector<Pos> cells;
+        std::vector<Pos> edges;
+        for (int x=0; x<p.width; x++) {
+            for (int y=0; y<p.height/2; y++) {
+                if (x%2 == 0 && y%2 == 0) corners.emplace_back(Pos{x, y});
+                else if (x%2 == 1 && y%2 == 1) cells.emplace_back(Pos{x, y});
+                else edges.emplace_back(Pos{x, y});
             }
+        }
+
+        for (int j=0;; j++) {
+            std::vector<Pos> dots = Random::SelectFromSet(edges, 1);
+            std::vector<Pos> dots2 = Random::SelectFromSet(corners, 2);
+            dots.insert(dots.end(), dots2.begin(), dots2.end());
+            for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK;
 
             auto solutions = Solver::Solve(p);
-            if (solutions.size() > 0 && solutions.size() < 10) {
-                std::string text = std::to_string(solutions.size()) + "\n";
-                OutputDebugStringA(text.c_str());
+            if (solutions.size() == 2) {
+                for (Pos pos : dots) {
+                    Pos sym = p.GetSymmetricalPos(pos.x, pos.y);
+                    p.grid[sym.x][sym.y].dot = Cell::Dot::BLACK;
+                }
                 break;
             }
 
-            for (Pos pos : dots) {
-                p.grid[pos.x][pos.y].dot = Cell::Dot::NONE;
-            }
+            for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::NONE;
         }
 
-        _serializer.WritePuzzle(p, 0xB0);
+        _serializer.WritePuzzle(p, 0x22);
     }
 }
 
-- 
cgit 1.4.1