diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2019-12-05 10:23:42 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-12-05 10:23:42 -0800 |
commit | 38060c54f9f923d49b019fcf90f3494fd5469b74 (patch) | |
tree | 64a13b0453a78e3064374b9b7b1e3cb515f14dda /Source/Randomizer2.cpp | |
parent | 9f4ea5694ec32507db1d28000fa52665e0e84323 (diff) | |
download | witness-tutorializer-38060c54f9f923d49b019fcf90f3494fd5469b74.tar.gz witness-tutorializer-38060c54f9f923d49b019fcf90f3494fd5469b74.tar.bz2 witness-tutorializer-38060c54f9f923d49b019fcf90f3494fd5469b74.zip |
Bugfix, add debug function, add dots 2
Diffstat (limited to 'Source/Randomizer2.cpp')
-rw-r--r-- | Source/Randomizer2.cpp | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index 0628414..421ce69 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp | |||
@@ -412,27 +412,65 @@ void Randomizer2::RandomizeSymmetryIsland() { | |||
412 | else edges.emplace_back(Pos{x, y}); | 412 | else edges.emplace_back(Pos{x, y}); |
413 | } | 413 | } |
414 | } | 414 | } |
415 | edges.insert(edges.end(), corners.begin(), corners.end()); | ||
415 | 416 | ||
417 | std::vector<Pos> dots; | ||
416 | for (int j=0;; j++) { | 418 | for (int j=0;; j++) { |
417 | std::vector<Pos> dots = Random::SelectFromSet(edges, 1); | 419 | dots = Random::SelectFromSet(edges, 3); |
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; | 420 | for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK; |
421 | 421 | ||
422 | auto solutions = Solver::Solve(p); | 422 | auto solutions = Solver::Solve(p); |
423 | if (solutions.size() == 2) { | 423 | if (solutions.size() == 2) break; |
424 | for (Pos pos : dots) { | ||
425 | Pos sym = p.GetSymmetricalPos(pos.x, pos.y); | ||
426 | p.grid[sym.x][sym.y].dot = Cell::Dot::BLACK; | ||
427 | } | ||
428 | break; | ||
429 | } | ||
430 | 424 | ||
431 | for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::NONE; | 425 | for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::NONE; |
432 | } | 426 | } |
433 | 427 | ||
428 | for (Pos pos : dots) { | ||
429 | Pos sym = p.GetSymmetricalPos(pos.x, pos.y); | ||
430 | p.grid[sym.x][sym.y].dot = Cell::Dot::BLACK; | ||
431 | } | ||
432 | |||
434 | _serializer.WritePuzzle(p, 0x22); | 433 | _serializer.WritePuzzle(p, 0x22); |
435 | } | 434 | } |
435 | { // Dots 2 | ||
436 | Puzzle p; | ||
437 | p.NewGrid(3, 3); | ||
438 | p.symmetry = Puzzle::Symmetry::Y; | ||
439 | p.grid[0][2].start = true; | ||
440 | p.grid[0][4].start = true; | ||
441 | p.grid[6][2].end = Cell::Dir::RIGHT; | ||
442 | p.grid[6][4].end = Cell::Dir::RIGHT; | ||
443 | |||
444 | std::vector<Pos> corners; | ||
445 | std::vector<Pos> cells; | ||
446 | std::vector<Pos> edges; | ||
447 | for (int x=0; x<p.width; x++) { | ||
448 | for (int y=0; y<p.height/2; y++) { | ||
449 | if (x%2 == 0 && y%2 == 0) corners.emplace_back(Pos{x, y}); | ||
450 | else if (x%2 == 1 && y%2 == 1) cells.emplace_back(Pos{x, y}); | ||
451 | else edges.emplace_back(Pos{x, y}); | ||
452 | } | ||
453 | } | ||
454 | edges.insert(edges.end(), corners.begin(), corners.end()); | ||
455 | |||
456 | std::vector<Pos> dots; | ||
457 | for (int j=0;; j++) { | ||
458 | dots = Random::SelectFromSet(edges, 3); | ||
459 | for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK; | ||
460 | |||
461 | auto solutions = Solver::Solve(p); | ||
462 | if (solutions.size() == 2) break; | ||
463 | |||
464 | for (Pos pos : dots) p.grid[pos.x][pos.y].dot = Cell::Dot::NONE; | ||
465 | } | ||
466 | |||
467 | Pos pos = dots[1]; | ||
468 | Pos sym = p.GetSymmetricalPos(pos.x, pos.y); | ||
469 | p.grid[pos.x][pos.y].dot = Cell::Dot::NONE; | ||
470 | p.grid[sym.x][sym.y].dot = Cell::Dot::BLACK; | ||
471 | |||
472 | _serializer.WritePuzzle(p, 0x23); | ||
473 | } | ||
436 | } | 474 | } |
437 | 475 | ||
438 | void Randomizer2::RandomizeKeep() { | 476 | void Randomizer2::RandomizeKeep() { |