Using SAT solvers to generate solutions for Flow levels. Can solve selected level on device automatically using MonkeyRunner.
www.youtube.com/watch?v=NxKmFT4qsQM
The code is quite messy and slow, but it works.
For a fully autonomous solving of a level on screen run
python solve_monkey.py
This will perform the following steps:
- Use MonkeyRunner to take a screenshot.
- Extract the level from the screenshot.
- Setup SAT clauses and write them to file.
- Run a SAT solver on the file to generate a solution.
- Display the solution.
- Finally, use MonkeyRunner to send a series of drag events to execute the solution on the device.
These are old examples using MiniSAT. By using glucose you can achieve much better speeds.
Level 8x8, #150 2,688 variables, 58,603 clauses, solved instantaneously
Level 14x14, #1 20,580 variables, 1,095,960 clauses, approx. 3 minutes to solve
Level 14x14, #30, with cycle breaking 59,388 variables, 12,256,516 clauses, approx. 4 minutes to solve
Level 14x14, #30, without cycle breaking 20,580 variables, 1,096,306 clauses, approx. 1 minutes to solve