about summary refs log tree commit diff stats
path: root/Source/Randomizer2.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-12-05 09:43:23 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-12-05 09:43:23 -0800
commit9f4ea5694ec32507db1d28000fa52665e0e84323 (patch)
tree4947148cc16394197e220f979e53d3b1e504155d /Source/Randomizer2.cpp
parent1ccd3488a0c946b2ad4c0e525d91dcf96d1ca707 (diff)
downloadwitness-tutorializer-9f4ea5694ec32507db1d28000fa52665e0e84323.tar.gz
witness-tutorializer-9f4ea5694ec32507db1d28000fa52665e0e84323.tar.bz2
witness-tutorializer-9f4ea5694ec32507db1d28000fa52665e0e84323.zip
Just forgot to write this section, I guess
Diffstat (limited to 'Source/Randomizer2.cpp')
-rw-r--r--Source/Randomizer2.cpp57
1 files changed, 41 insertions, 16 deletions
diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index e1b1712..0628414 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp
@@ -381,32 +381,57 @@ void Randomizer2::RandomizeSymmetryIsland() {
381 } 381 }
382 382
383 for (int j=0;; j++) { 383 for (int j=0;; j++) {
384 auto edgesCopy = edges; 384 std::vector<Pos> dots = Random::SelectFromSet(edges, 4);
385 for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK;
385 386
386 std::vector<Pos> dots; 387 auto solutions = Solver::Solve(p);
387 for (int i=0; i<4; i++) { 388 if (solutions.size() > 0 && solutions.size() < 10) break;
388 int edge = Random::RandInt(0, static_cast<int>(edgesCopy.size() - 1)); 389
389 dots.emplace_back(edgesCopy[edge]); 390 for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::NONE;
390 edgesCopy.erase(edgesCopy.begin() + edge); 391 }
391 }
392 392
393 for (Pos pos : dots) { 393 _serializer.WritePuzzle(p, 0xB0);
394 p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK; 394 }
395
396 { // Dots 1
397 Puzzle p;
398 p.NewGrid(3, 3);
399 p.symmetry = Puzzle::Symmetry::Y;
400 p.grid[0][2].start = true;
401 p.grid[0][4].start = true;
402 p.grid[6][2].end = Cell::Dir::RIGHT;
403 p.grid[6][4].end = Cell::Dir::RIGHT;
404
405 std::vector<Pos> corners;
406 std::vector<Pos> cells;
407 std::vector<Pos> edges;
408 for (int x=0; x<p.width; x++) {
409 for (int y=0; y<p.height/2; y++) {
410 if (x%2 == 0 && y%2 == 0) corners.emplace_back(Pos{x, y});
411 else if (x%2 == 1 && y%2 == 1) cells.emplace_back(Pos{x, y});
412 else edges.emplace_back(Pos{x, y});
395 } 413 }
414 }
415
416 for (int j=0;; j++) {
417 std::vector<Pos> dots = Random::SelectFromSet(edges, 1);
418 std::vector<Pos> dots2 = Random::SelectFromSet(corners, 2);
419 dots.insert(dots.end(), dots2.begin(), dots2.end());
420 for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK;
396 421
397 auto solutions = Solver::Solve(p); 422 auto solutions = Solver::Solve(p);
398 if (solutions.size() > 0 && solutions.size() < 10) { 423 if (solutions.size() == 2) {
399 std::string text = std::to_string(solutions.size()) + "\n"; 424 for (Pos pos : dots) {
400 OutputDebugStringA(text.c_str()); 425 Pos sym = p.GetSymmetricalPos(pos.x, pos.y);
426 p.grid[sym.x][sym.y].dot = Cell::Dot::BLACK;
427 }
401 break; 428 break;
402 } 429 }
403 430
404 for (Pos pos : dots) { 431 for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::NONE;
405 p.grid[pos.x][pos.y].dot = Cell::Dot::NONE;
406 }
407 } 432 }
408 433
409 _serializer.WritePuzzle(p, 0xB0); 434 _serializer.WritePuzzle(p, 0x22);
410 } 435 }
411} 436}
412 437