From 1ccd3488a0c946b2ad4c0e525d91dcf96d1ca707 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Wed, 4 Dec 2019 17:44:38 -0800 Subject: helper func + bug fix --- Source/Solver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Solver.cpp') 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 Solver::Solve(Puzzle& p) { } void Solver::SolveLoop(Puzzle& p, int x, int y, std::vector& solutions) { - // Stop trying to solve once we reach our goal + // Stop trying to solve once we reach our goal if (solutions.size() >= MAX_SOLUTIONS) return; Cell cell = p.GetCell(x, y); if (cell.undefined) return; @@ -30,7 +30,6 @@ void Solver::SolveLoop(Puzzle& p, int x, int y, std::vector& solutions) if (p.symmetry == Puzzle::Symmetry::NONE) { if (cell.color != Cell::Color::NONE) return; // Collided with ourselves p.grid[x][y].color = Cell::Color::BLACK; // Otherwise, mark this cell as visited - p.sequence.emplace_back(x, y); } else { // Get the symmetrical position, and try coloring it auto sym = p.GetSymmetricalPos(x, y); @@ -44,6 +43,7 @@ void Solver::SolveLoop(Puzzle& p, int x, int y, std::vector& solutions) } p.grid[x][y].color = Cell::Color::BLUE; // Otherwise, mark this cell as visited } + p.sequence.emplace_back(x, y); if (cell.end != Cell::Dir::NONE) { // Reached an endpoint, validate solution and keep going -- there may be other endpoints -- cgit 1.4.1