about summary refs log tree commit diff stats
path: root/Source/Randomizer2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Randomizer2.cpp')
-rw-r--r--Source/Randomizer2.cpp41
1 files changed, 17 insertions, 24 deletions
diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index 782e248..993e7cc 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp
@@ -35,7 +35,6 @@ void Randomizer2::RandomizeTutorial() {
35 Puzzle p; 35 Puzzle p;
36 p.NewGrid(6, 6); 36 p.NewGrid(6, 6);
37 37
38 // @Bug: Mid-segment endpoints are not yet supported.
39 int x = Random::RandInt(0, (p.width-1)/2)*2; 38 int x = Random::RandInt(0, (p.width-1)/2)*2;
40 int y = Random::RandInt(0, (p.height-1)/2)*2; 39 int y = Random::RandInt(0, (p.height-1)/2)*2;
41 int rng = Random::RandInt(1, 4); 40 int rng = Random::RandInt(1, 4);
@@ -94,29 +93,24 @@ void Randomizer2::RandomizeTutorial() {
94 bool toTheRight; 93 bool toTheRight;
95 // Start by generating a cut line, to ensure one of the two startpoints is inaccessible 94 // Start by generating a cut line, to ensure one of the two startpoints is inaccessible
96 int x, y; 95 int x, y;
97 switch (Random::RandInt(1, 4)) 96 switch (Random::RandInt(1, 4)) {
98 {
99 case 1: 97 case 1:
100 x = 1; 98 x = 1; y = 1;
101 y = 1;
102 toTheRight = true; 99 toTheRight = true;
103 cuts.emplace_back(0, 1); 100 cuts.emplace_back(0, 1);
104 break; 101 break;
105 case 2: 102 case 2:
106 x = 1; 103 x = 1; y = 1;
107 y = 1;
108 toTheRight = true; 104 toTheRight = true;
109 cuts.emplace_back(1, 0); 105 cuts.emplace_back(1, 0);
110 break; 106 break;
111 case 3: 107 case 3:
112 x = 11; 108 x = 11; y = 1;
113 y = 1;
114 toTheRight = false; 109 toTheRight = false;
115 cuts.emplace_back(12, 1); 110 cuts.emplace_back(12, 1);
116 break; 111 break;
117 case 4: 112 case 4:
118 x = 11; 113 x = 11; y = 1;
119 y = 1;
120 toTheRight = false; 114 toTheRight = false;
121 cuts.emplace_back(11, 0); 115 cuts.emplace_back(11, 0);
122 break; 116 break;
@@ -136,7 +130,7 @@ void Randomizer2::RandomizeTutorial() {
136 } 130 }
137 break; 131 break;
138 case 3: 132 case 3:
139 case 4: // Go down (biased) 133 case 4: // Go down (biased x2)
140 cuts.emplace_back(x, y+1); 134 cuts.emplace_back(x, y+1);
141 y += 2; 135 y += 2;
142 break; 136 break;
@@ -155,8 +149,7 @@ void Randomizer2::RandomizeTutorial() {
155} 149}
156 150
157void Randomizer2::RandomizeSymmetry() { 151void Randomizer2::RandomizeSymmetry() {
158 // Back wall 152 { // Back wall 1
159 {
160 Puzzle p; 153 Puzzle p;
161 p.NewGrid(3, 3); 154 p.NewGrid(3, 3);
162 p.symmetry = Puzzle::Symmetry::X; 155 p.symmetry = Puzzle::Symmetry::X;
@@ -173,7 +166,7 @@ void Randomizer2::RandomizeSymmetry() {
173 } 166 }
174 _serializer.WritePuzzle(p, 0x86); 167 _serializer.WritePuzzle(p, 0x86);
175 } 168 }
176 { 169 { // Back wall 2
177 Puzzle p; 170 Puzzle p;
178 p.NewGrid(4, 4); 171 p.NewGrid(4, 4);
179 p.symmetry = Puzzle::Symmetry::X; 172 p.symmetry = Puzzle::Symmetry::X;
@@ -181,17 +174,17 @@ void Randomizer2::RandomizeSymmetry() {
181 p.grid[8][8].start = true; 174 p.grid[8][8].start = true;
182 p.grid[2][0].end = Cell::Dir::UP; 175 p.grid[2][0].end = Cell::Dir::UP;
183 p.grid[6][0].end = Cell::Dir::UP; 176 p.grid[6][0].end = Cell::Dir::UP;
184 // @Bug: This can still make the puzzle unsolvable, if it leaves the centerline free -- even though two lines can't pass through the centerline.
185 // ^ Try seed = 13710
186 std::vector<Pos> cutEdges = Randomizer2Core::CutSymmetricalEdgePairs(p, 4); 177 std::vector<Pos> cutEdges = Randomizer2Core::CutSymmetricalEdgePairs(p, 4);
187 for (int i=0; i<2; i++) { 178 bool alternate = false;
188 Pos pos = cutEdges[i]; 179 for (int i=0; i<cutEdges.size(); i++) {
189 p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK;
190 }
191 for (int i=2; i<4; i++) {
192 Pos pos = cutEdges[i]; 180 Pos pos = cutEdges[i];
193 Pos sym = p.GetSymmetricalPos(pos.x, pos.y); 181 if (alternate) {
194 p.grid[sym.x][sym.y].gap = Cell::Gap::BREAK; 182 p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK;
183 } else {
184 Pos sym = p.GetSymmetricalPos(pos.x, pos.y);
185 p.grid[sym.x][sym.y].gap = Cell::Gap::BREAK;
186 }
187 alternate = !alternate;
195 } 188 }
196 189
197 _serializer.WritePuzzle(p, 0x87); 190 _serializer.WritePuzzle(p, 0x87);