16 karma · joined Mar 5, 2017 (9y ago) · 2 submissions
comment 9y ago · link · parent
Here's a great resource for those interested in constraint programming: http://www.hakank.org
Sudoku examples: SABR: http://www.hakank.org/sabr/sudoku.tb
ASP: http://www.hakank.org/answer_set_programming/sudoku.lp
There's the built in construct of transitions which isn't in this example that is preloaded into SABR, but one could easily enough write the restraints required for this in clasp.
SABR envisions the universe as the "Board" and it has a given size consisting of elements and each element can have a specific state as defined by "Symbols". Then you can build on that to say what is legal for a theoretical set of elements, and how that set can transform over time, then you can define which of the Board elements correspond to the defined theoretical set.
Its way more opinionated than most other constraint programming languages, which can be mind bendy.
comment 9y ago · link · parent
It basically translates the somewhat more complex rules into the simpler SAT rules using minisat. However sometimes needed a generator in python to make the rules :/. But still kinda nice to see it more visually, language looks like this in the end: http://sabrlang.org/code/mine/source.txt. It basically lists the requirements for middle, edge and corner blocks, than says where those blocks are on the "board."
Kinda fun, though arguably somewhat restrictive. One of the more fun ones I think is the rubiks cube: http://sabrlang.org/rubik/.