about summary refs log tree commit diff stats
path: root/Source/Solver.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-12-04 17:44:38 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-12-04 17:44:38 -0800
commit1ccd3488a0c946b2ad4c0e525d91dcf96d1ca707 (patch)
treea559a553ce9886d42bb4584113bb2c9bd445c4d9 /Source/Solver.cpp
parent39644676e2716a285fcea6bb81e07f326bda2f68 (diff)
downloadwitness-tutorializer-1ccd3488a0c946b2ad4c0e525d91dcf96d1ca707.tar.gz
witness-tutorializer-1ccd3488a0c946b2ad4c0e525d91dcf96d1ca707.tar.bz2
witness-tutorializer-1ccd3488a0c946b2ad4c0e525d91dcf96d1ca707.zip
helper func + bug fix
Diffstat (limited to 'Source/Solver.cpp')
-rw-r--r--Source/Solver.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Source/Solver.cpp b/Source/Solver.cpp index 2813027..74fa099 100644 --- a/Source/Solver.cpp +++ b/Source/Solver.cpp
@@ -21,7 +21,7 @@ std::vector<Puzzle> Solver::Solve(Puzzle& p) {
21} 21}
22 22
23void Solver::SolveLoop(Puzzle& p, int x, int y, std::vector<Puzzle>& solutions) { 23void Solver::SolveLoop(Puzzle& p, int x, int y, std::vector<Puzzle>& solutions) {
24 // Stop trying to solve once we reach our goal 24 // Stop trying to solve once we reach our goal
25 if (solutions.size() >= MAX_SOLUTIONS) return; 25 if (solutions.size() >= MAX_SOLUTIONS) return;
26 Cell cell = p.GetCell(x, y); 26 Cell cell = p.GetCell(x, y);
27 if (cell.undefined) return; 27 if (cell.undefined) return;
@@ -30,7 +30,6 @@ void Solver::SolveLoop(Puzzle& p, int x, int y, std::vector<Puzzle>& solutions)
30 if (p.symmetry == Puzzle::Symmetry::NONE) { 30 if (p.symmetry == Puzzle::Symmetry::NONE) {
31 if (cell.color != Cell::Color::NONE) return; // Collided with ourselves 31 if (cell.color != Cell::Color::NONE) return; // Collided with ourselves
32 p.grid[x][y].color = Cell::Color::BLACK; // Otherwise, mark this cell as visited 32 p.grid[x][y].color = Cell::Color::BLACK; // Otherwise, mark this cell as visited
33 p.sequence.emplace_back(x, y);
34 } else { 33 } else {
35 // Get the symmetrical position, and try coloring it 34 // Get the symmetrical position, and try coloring it
36 auto sym = p.GetSymmetricalPos(x, y); 35 auto sym = p.GetSymmetricalPos(x, y);
@@ -44,6 +43,7 @@ void Solver::SolveLoop(Puzzle& p, int x, int y, std::vector<Puzzle>& solutions)
44 } 43 }
45 p.grid[x][y].color = Cell::Color::BLUE; // Otherwise, mark this cell as visited 44 p.grid[x][y].color = Cell::Color::BLUE; // Otherwise, mark this cell as visited
46 } 45 }
46 p.sequence.emplace_back(x, y);
47 47
48 if (cell.end != Cell::Dir::NONE) { 48 if (cell.end != Cell::Dir::NONE) {
49 // Reached an endpoint, validate solution and keep going -- there may be other endpoints 49 // Reached an endpoint, validate solution and keep going -- there may be other endpoints