summary refs log tree commit diff stats
path: root/Source/Randomizer2Core.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Randomizer2Core.cpp')
-rw-r--r--Source/Randomizer2Core.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/Source/Randomizer2Core.cpp b/Source/Randomizer2Core.cpp index eaefa9a..89294ef 100644 --- a/Source/Randomizer2Core.cpp +++ b/Source/Randomizer2Core.cpp
@@ -1,11 +1,8 @@
1#include "pch.h"
1#include "Randomizer2Core.h" 2#include "Randomizer2Core.h"
2#include "Puzzle.h" 3#include "Puzzle.h"
3#include "Random.h" 4#include "Random.h"
4 5
5#include <string>
6#include <iostream>
7#include <cassert>
8
9std::vector<Pos> Randomizer2Core::CutEdges(const Puzzle& p, size_t numEdges) { 6std::vector<Pos> Randomizer2Core::CutEdges(const Puzzle& p, size_t numEdges) {
10 return CutEdgesInternal(p, 0, p.width, 0, p.height, numEdges); 7 return CutEdgesInternal(p, 0, p.width, 0, p.height, numEdges);
11} 8}
@@ -16,17 +13,20 @@ std::vector<Pos> Randomizer2Core::CutInsideEdges(const Puzzle& p, size_t numEdge
16 13
17std::vector<Pos> Randomizer2Core::CutSymmetricalEdgePairs(const Puzzle& p, size_t numEdges) { 14std::vector<Pos> Randomizer2Core::CutSymmetricalEdgePairs(const Puzzle& p, size_t numEdges) {
18 Puzzle copy = p; 15 Puzzle copy = p;
19 assert(p.symmetry != Puzzle::Symmetry::NONE); 16 // Prevent cuts from landing on the midline
20 if (p.symmetry == Puzzle::Symmetry::X) { 17 if (p.symmetry == Puzzle::Symmetry::X) {
21 // Prevent cuts from landing on the midline
22 for (int y=0; y<p.height; y++) { 18 for (int y=0; y<p.height; y++) {
23 copy.grid[p.width/2][y].gap = Cell::Gap::FULL; 19 copy.grid[p.width/2][y].gap = Cell::Gap::FULL;
24 } 20 }
25 21 } else if (p.symmetry == Puzzle::Symmetry::Y) {
26 return CutEdgesInternal(copy, 0, (p.width-1)/2, 0, p.height, numEdges); 22 for (int x=0; x<p.width; x++) {
23 copy.grid[x][p.height/2].gap = Cell::Gap::FULL;
24 }
25 } else {
26 assert(p.symmetry == Puzzle::Symmetry::XY);
27 // Pass, I think? Maybe this matters for odd numbers.
27 } 28 }
28 assert(false); 29 return CutEdgesInternal(copy, 0, (p.width-1)/2, 0, p.height, numEdges);
29 return {};
30} 30}
31 31
32std::vector<Pos> Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, int xMax, int yMin, int yMax, size_t numEdges) { 32std::vector<Pos> Randomizer2Core::CutEdgesInternal(const Puzzle& p, int xMin, int xMax, int yMin, int yMax, size_t numEdges) {