An instance of the Yashi game is specified by a n×n integer grid for some n > 2, on which p > 2 nodes are placed. A solution of the game consists in drawing horizontal and vertical segments, satisfying the following conditions:
- Every segment connects two and only two nodes.
- No two segments overlap.
- No two segments cross each other.
- You can connect any two nodes by using a single horizontal or single vertical line.
- The segments form a tree, i.e., they form a graph without cycles. Put differently still, for everytwo nodes a and b there is exactly one path between a and b.
- An optimal solution is that which satisfies constraints 1-5 and has the minimum total segment length of the possible solutions.
This program encodes the Yashi Game in propositional logic to obtain an optimal solution, it takes an input file of the points for the game or generates them randomly.
Some examples of valid commands using points given as a file:
$ python main.py --grid-size 5 --sat-mode maxsat --points-mode file --file-path data\solvable.csv
$ python main.py --grid-size 5 --sat-mode maxsat --points-mode file --file-path data\crossings.csv
$ python main.py --grid-size 5 --sat-mode maxsat --points-mode file --file-path data\unconnected.csv
Points being randomly generated:
$ python main.py --grid-size 5 --sat-mode maxsat --points-mode random --num-points 12
$ python main.py --grid-size 5 --sat-mode sat --points-mode random --num-points 12
$ pip install -r requirements.txt
Recommended: Python 3.10