From 859cfdb86d57bb230f1200c3a4c76c55ca920199 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Thu, 21 Nov 2019 10:03:34 -0800 Subject: Well, got started on randomization anyways --- Source/Randomizer2Core.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'Source/Randomizer2Core.cpp') diff --git a/Source/Randomizer2Core.cpp b/Source/Randomizer2Core.cpp index f8d1312..dcb9fd2 100644 --- a/Source/Randomizer2Core.cpp +++ b/Source/Randomizer2Core.cpp @@ -6,13 +6,25 @@ #include #include -std::vector Randomizer2Core::CutEdges(const Puzzle& p, size_t numEdges, bool allowEdges) { - std::vector edges; - int xMin = allowEdges ? 0 : 1; - int xMax = allowEdges ? p.width : p.width-1; - int yMin = allowEdges ? 0 : 1; - int yMax = allowEdges ? p.height : p.height-1; +std::vector Randomizer2Core::CutEdges(const Puzzle& p, size_t numEdges) { + return CutEdgesInternal(p, 0, p.width, 0, p.height, numEdges); +} +std::vector Randomizer2Core::CutInsideEdges(const Puzzle& p, size_t numEdges) { + return CutEdgesInternal(p, 1, p.width-1, 1, p.height-1, numEdges); +} + +std::vector Randomizer2Core::CutSymmetricalEdgePairs(const Puzzle& p, size_t numEdges) { + assert(p.symmetry != Puzzle::Symmetry::NONE); + if (p.symmetry == Puzzle::Symmetry::X) { + return CutEdgesInternal(p, 0, (p.width-1)/2, 0, p.height, numEdges); + } + assert(false); + return {}; +} + +std::vector Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, int xMax, int yMin, int yMax, size_t numEdges) { + std::vector edges; for (int x=xMin; x Randomizer2Core::CutEdges(const Puzzle& p, size_t numEdges, boo edges.emplace_back(x, y); } } - return CutEdgesInternal(p, edges, numEdges); -} + assert(numEdges <= edges.size()); -std::vector Randomizer2Core::CutEdgesInternal(const Puzzle& p, std::vector& edges, size_t numEdges) { auto [colorGrid, numColors] = CreateColorGrid(p); assert(numEdges <= numColors); -- cgit 1.4.1