diff options
| author | jbzdarkid <jbzdarkid@gmail.com> | 2019-12-05 09:43:23 -0800 |
|---|---|---|
| committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-12-05 09:43:23 -0800 |
| commit | 9f4ea5694ec32507db1d28000fa52665e0e84323 (patch) | |
| tree | 4947148cc16394197e220f979e53d3b1e504155d /Source | |
| parent | 1ccd3488a0c946b2ad4c0e525d91dcf96d1ca707 (diff) | |
| download | witness-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')
| -rw-r--r-- | Source/PuzzleSerializer.cpp | 40 | ||||
| -rw-r--r-- | Source/Randomizer2.cpp | 57 |
2 files changed, 64 insertions, 33 deletions
| diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index 29bd648..8faede9 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp | |||
| @@ -493,25 +493,31 @@ void PuzzleSerializer::WriteSymmetry(const Puzzle& p, int id) { | |||
| 493 | for (int x=0; x<p.width; x++) { | 493 | for (int x=0; x<p.width; x++) { |
| 494 | for (int y=0; y<p.height; y++) { | 494 | for (int y=0; y<p.height; y++) { |
| 495 | if (x%2 == y%2) continue; | 495 | if (x%2 == y%2) continue; |
| 496 | if (p.grid[x][y].gap != Cell::Gap::BREAK) continue; | 496 | if (p.grid[x][y].gap == Cell::Gap::BREAK) { |
| 497 | 497 | Pos sym = p.GetSymmetricalPos(x, y); | |
| 498 | Pos sym = p.GetSymmetricalPos(x, y); | 498 | int location = extra_xy_to_loc(p, x, y); |
| 499 | int location = extra_xy_to_loc(p, x, y); | 499 | int symLocation = extra_xy_to_loc(p, sym.x, sym.y); |
| 500 | int symLocation = extra_xy_to_loc(p, sym.x, sym.y); | 500 | // Each gap results in two intersections, @Assume they're written consecutively |
| 501 | // Each gap results in two intersections, @Assume they're written consecutively | 501 | |
| 502 | 502 | if ((x%2 != 0 && p.symmetry & Puzzle::Symmetry::X) || | |
| 503 | if ((x%2 != 0 && p.symmetry & Puzzle::Symmetry::X) || | 503 | (y%2 != 0 && p.symmetry & Puzzle::Symmetry::Y)) { |
| 504 | (y%2 != 0 && p.symmetry & Puzzle::Symmetry::Y)) { | 504 | // Write data inverted, because it's being reflected |
| 505 | // Write data inverted, because it's being reflected | 505 | reflectionData[location] = symLocation-1; |
| 506 | reflectionData[location] = symLocation-1; | 506 | reflectionData[location-1] = symLocation; |
| 507 | reflectionData[location-1] = symLocation; | 507 | reflectionData[symLocation] = location-1; |
| 508 | reflectionData[symLocation] = location-1; | 508 | reflectionData[symLocation-1] = location; |
| 509 | reflectionData[symLocation-1] = location; | 509 | } else { // Write data normally |
| 510 | } else { // Write data normally | 510 | reflectionData[location] = symLocation; |
| 511 | reflectionData[location-1] = symLocation-1; | ||
| 512 | reflectionData[symLocation] = location; | ||
| 513 | reflectionData[symLocation-1] = location-1; | ||
| 514 | } | ||
| 515 | } else if (p.grid[x][y].dot == Cell::Dot::BLACK) { | ||
| 516 | Pos sym = p.GetSymmetricalPos(x, y); | ||
| 517 | int location = extra_xy_to_loc(p, x, y); | ||
| 518 | int symLocation = extra_xy_to_loc(p, sym.x, sym.y); | ||
| 511 | reflectionData[location] = symLocation; | 519 | reflectionData[location] = symLocation; |
| 512 | reflectionData[location-1] = symLocation-1; | ||
| 513 | reflectionData[symLocation] = location; | 520 | reflectionData[symLocation] = location; |
| 514 | reflectionData[symLocation-1] = location-1; | ||
| 515 | } | 521 | } |
| 516 | } | 522 | } |
| 517 | } | 523 | } |
| 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 | ||
