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/Randomizer2.cpp | 47 ++++++++++++++++++++++++++++++++++++---------- Source/Randomizer2Core.cpp | 38 +++++++++++++++++++++++++------------ 2 files changed, 63 insertions(+), 22 deletions(-) (limited to 'Source') diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index b1cdc1f..db90f4c 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp @@ -307,15 +307,12 @@ void Randomizer2::RandomizeSymmetry() { Puzzle p; p.NewGrid(4, 4); p.symmetry = Puzzle::Symmetry::XY; - p.grid[6][0].start = true; - p.grid[0][6].start = true; - p.grid[4][0].end = Cell::Dir::UP; - p.grid[2][6].end = Cell::Dir::DOWN; - - p.grid[5][0].gap = Cell::Gap::BREAK; - p.grid[1][6].gap = Cell::Gap::BREAK; + p.grid[8][0].start = true; + p.grid[0][8].start = true; + p.grid[0][0].end = Cell::Dir::LEFT; + p.grid[8][8].end = Cell::Dir::RIGHT; - std::vector cutEdges = Randomizer2Core::CutSymmetricalEdgePairs(p, 3); + std::vector cutEdges = Randomizer2Core::CutSymmetricalEdgePairs(p, 7); for (int i=0; i cutEdges = Randomizer2Core::CutSymmetricalEdgePairs(p, 15); + for (int i=0; i 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