From 42d4067a16d826f0941d72df885111ef06ed3d7a Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Mon, 2 Dec 2019 10:01:28 -0800 Subject: Glass factory... done! --- Source/Randomizer2Core.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'Source/Randomizer2Core.cpp') diff --git a/Source/Randomizer2Core.cpp b/Source/Randomizer2Core.cpp index 2a2c6ff..867fa5a 100644 --- a/Source/Randomizer2Core.cpp +++ b/Source/Randomizer2Core.cpp @@ -25,17 +25,17 @@ std::vector Randomizer2Core::CutSymmetricalEdgePairs(const Puzzle& p, size_ return CutEdgesInternal(copy, 0, p.width, 0, (p.height-1)/2, numEdges); } else { assert(p.symmetry == Puzzle::Symmetry::XY); - if (p.width%4 == 1) { - assert(p.width == 9); - copy.grid[2][3]; - copy.grid[3][4]; - copy.grid[3][6]; - copy.grid[4][3]; - // For odd grids, cut the center out. - // for (int x=0; x Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, in if (p.grid[x][y].gap != Cell::Gap::NONE) continue; if (p.grid[x][y].start) continue; if (p.grid[x][y].end != Cell::Dir::NONE) continue; - if (p.symmetry == Puzzle::Symmetry::XY && x > y) continue; // Only allow cuts bottom-left of the diagonal + + if (p.symmetry == Puzzle::Symmetry::XY) { + assert(p.width == p.height); // TODO: This solution only supports square rotational symmetry. + if (x > y) continue; // Only allow cuts bottom-left of the diagonal + } // If the puzzle already has a sequence, don't cut along it. bool inSequence = false; @@ -63,6 +67,16 @@ std::vector Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, in auto [colorGrid, numColors] = CreateColorGrid(p); assert(numEdges <= numColors); + // @Hack... sort of. I couldn't think of a better way to do this. + if (p.symmetry == Puzzle::Symmetry::XY) { + // Recolor the diagonal so that opposite cells share a color. This is because we're only cutting along half their edges, + // so they are in fact two sides of the same cell. + for (int x=1; x cutEdges; for (int i=0; i 0) { -- cgit 1.4.1