From 38060c54f9f923d49b019fcf90f3494fd5469b74 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Thu, 5 Dec 2019 10:23:42 -0800 Subject: Bugfix, add debug function, add dots 2 --- Source/Randomizer2.cpp | 58 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 10 deletions(-) (limited to 'Source/Randomizer2.cpp') diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index 0628414..421ce69 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp @@ -412,27 +412,65 @@ void Randomizer2::RandomizeSymmetryIsland() { else edges.emplace_back(Pos{x, y}); } } + edges.insert(edges.end(), corners.begin(), corners.end()); + std::vector dots; for (int j=0;; j++) { - std::vector dots = Random::SelectFromSet(edges, 1); - std::vector dots2 = Random::SelectFromSet(corners, 2); - dots.insert(dots.end(), dots2.begin(), dots2.end()); + dots = Random::SelectFromSet(edges, 3); for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK; auto solutions = Solver::Solve(p); - 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; - } + if (solutions.size() == 2) break; for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::NONE; } + for (Pos pos : dots) { + Pos sym = p.GetSymmetricalPos(pos.x, pos.y); + p.grid[sym.x][sym.y].dot = Cell::Dot::BLACK; + } + _serializer.WritePuzzle(p, 0x22); } + { // Dots 2 + 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 corners; + std::vector cells; + std::vector edges; + for (int x=0; x dots; + for (int j=0;; j++) { + dots = Random::SelectFromSet(edges, 3); + for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK; + + auto solutions = Solver::Solve(p); + if (solutions.size() == 2) break; + + for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::NONE; + } + + Pos pos = dots[1]; + Pos sym = p.GetSymmetricalPos(pos.x, pos.y); + p.grid[pos.x][pos.y].dot = Cell::Dot::NONE; + p.grid[sym.x][sym.y].dot = Cell::Dot::BLACK; + + _serializer.WritePuzzle(p, 0x23); + } } void Randomizer2::RandomizeKeep() { -- cgit 1.4.1