https://github.com/adriacabeza/flowfreesolver
🤯 Solver of Flow Free puzzles
https://github.com/adriacabeza/flowfreesolver
flowfree logic-programming prolog puzzle
Last synced: 7 months ago
JSON representation
🤯 Solver of Flow Free puzzles
- Host: GitHub
- URL: https://github.com/adriacabeza/flowfreesolver
- Owner: adriacabeza
- Created: 2020-04-22T09:20:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:13:28.000Z (over 5 years ago)
- Last Synced: 2025-01-11T03:41:49.203Z (9 months ago)
- Topics: flowfree, logic-programming, prolog, puzzle
- Language: Prolog
- Homepage:
- Size: 135 KB
- Stars: 1
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FlowFreeSolver
[](http://commonmark.org)[](https://GitHub.com/adriacabeza/FlowFreeSolver/stargazers/)Flow Free is a puzzle game that consists in pairing all colors and cover the entire board. Remember that no empty cells can be left, there can not be intersecting or non-finished paths.
![]()
This solution consists in writing all the restrictions as a SAT problem using Prolog, letting **picosat** (SAT solver) solve it and then retrieving the model to display the solution.
### Input
The input structure is the following:
```prolog
% size of the grid
size(9).
% initial points
c(blue, 9,1,2,2).
c(brown, 3,1,8,4).
c(red, 3,4,1,7).
c(cyan, 1,8,4,4).
c(green, 1,9,5,2).
c(yellow,7,7,7,9).
c(pink, 6,5,8,7).
c(violet,8,9,9,6).
c(orange,5,8,8,8).
```### Output
From the previous input, we would get the following output:
## Usage
To use it, remember to change the input problem to the one desired ot solve, compile it using the Makefile and then run the executable to see the solution:
1- Change this line from *flow.pl*:
```prolog
:-include(NAMEOFINPUT).
```
2- Compile and run it:
```bash
make flow
./flow
```
> If you need to make a solution with more colors, look at the displaySol function because u'll need to define the code for more colors to show up in the terminal.### Requirements
In the case that you do not want to install any Prolog programming environment, like SWI-Prolog, you can use the Dockerfile:
```
docker build -t prolog . &&
docker run -it -d -v PATH_TO_REPOSITORY:/workspace prolog &&
docker exec -it name_of_container zsh
swipl
```