From 9f4ea5694ec32507db1d28000fa52665e0e84323 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Thu, 5 Dec 2019 09:43:23 -0800 Subject: Just forgot to write this section, I guess --- Source/Randomizer2.cpp | 57 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 16 deletions(-) (limited to 'Source/Randomizer2.cpp') 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 dots = Random::SelectFromSet(edges, 4); + for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK; - std::vector dots; - for (int i=0; i<4; i++) { - int edge = Random::RandInt(0, static_cast(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 corners; + std::vector cells; + std::vector edges; + for (int x=0; x dots = Random::SelectFromSet(edges, 1); + std::vector 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