From an AI perspective, there are at least two substantially different ways to frame the Flow Free puzzle:
The former is the domain of SAT solvers and Knuth’s DLX, whereas the latter is the domain of Dijkstra’s algorithm and A* search.
At first, the blush, considering Flow Free as a CSP seems like a simpler formulation, because the constraints are so simple to state:
Each free space must be filled in by color.
Each filled-in cell must be adjacent to exactly two cells of the same color.
Each dot must be adjacent to exactly one filled-in cell of the same color.
Although we could use a breadth-first search to solve the puzzle, I found that it’s significantly faster to go with the best-first search instead. The method I ended up using is kind of a poor man’s A* search in that it computes two quantities for each state x
a cost-to-come g(x), g(x) that considers all of the moves made to get to this state; and
a cost-to-go estimate h(x), h(x) that estimates the remaining “distance” to a goal state.
For a better understanding of the approach, you can refer the following link:
https://mzucker.github.io/2016/08/28/flow-solver.html
If you want to make your career in Artificial Intelligence then go through this video:
For the best of career growth, check out Artificial Intelligence Course and get certified.