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/PuzzleSerializer.cpp | 40 +++++++++++++++++-------------- Source/Randomizer2.cpp | 57 ++++++++++++++++++++++++++++++++------------- 2 files changed, 64 insertions(+), 33 deletions(-) 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 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