Commit Graph

7 Commits

Author SHA1 Message Date
da22e1dfbb fmt 2021-12-07 20:56:04 +04:00
74ea9c497f Edition 2021 2021-12-07 20:49:40 +04:00
David Wang
035a8fc8a4 Clean up: candidate manipulation returns a Result.
Functions to manipulate candidates during the solution search now
always return a Result instead of sometimes returning a bool, and
other times returning an Option.

We opted to use Result over Option mainly to (ab)use the try! macro.
In addition, it also makes it emit a warning when we forget to handle
the result.  (We tend to assume people don't just ignore the result
and continue as normal, instead of putting the puzzle in a special
contradiction detected state.)
2017-03-11 09:40:20 +11:00
David Wang
5bb52b03f2 Add simple variable substitution for constraints.
Constraints must now implement the substitution of "from" with "to".
The implementations can be sanity checked when we come to build the
list of constraints that each variable wakes up.

In the future, we would like to make the more general substitution:
from -> scale * to + constant.
2017-03-09 07:52:08 +11:00
David Wang
ddf425efe0 Automatically box constraints.
Puzzle.add_constraint() now takes a generic (unboxed) constraint,
making it more pleasant to use when adding custom constraints.
2017-03-08 07:57:19 +11:00
David Wang
0477a5bbb0 Only wake affected constraints. 2017-02-25 08:17:07 +11:00
David Wang
6eb25f6af0 Add test: N-queens problem.
queens_4x4: 8 guesses.
queens_5x5: 21 guesses.
queens_6x6: 66 guesses.
queens_7x7: 179 guesses.
queens_8x8: 662 guesses.
2017-02-24 07:40:33 +11:00