This code is a puzzle solver that generates a Boolean formula in DIMACS-CNF (Conjunctive Normal Form) format from a puzzle input and uses a SAT (Boolean Satisfiability) solver to find a solution to the puzzle.
To use the puzzle solver, define the puzzle input and pass it as an argument to the generate_cnf function, along with the value of n:
puzzle = { "n": 3, "black": [(0, 0), (1, 1)], "white": [(2, 0)] }
cnf = generate_cnf(puzzle, puzzle["n"])
This code requires Python 3.x and the Pygame module to run. To install Pygame, run the following command:
pip install pygame