entailmodule I posted earlier. The
entailmodule contains a propositional logic inference algorithm: it lets one determine whether any given expression of binary variables follows logically from a set of assumptions:
>>> s = AssumptionSet(['a => b => c <=> a'])It is rather uncanny how complicated mathematical relationships can be derived ex nihilo using only the
>>> s.implies('a <=> b')
entailmodule. For the Minesweeper game, when the user chooses "Suggest Move," I add only the knowledge that the player possesses to an
AssumptionSet, and then suggest a move if the logic algorithm can deduce that any given square is free of a mine. The result is a perfect deterministic minesweeper AI: if any given move on the board can be made safely, then the AI will suggest that square. If no move can be made safely, then no suggestion will be made. Note that this is also an experiment with using HTML widgets in lieu of using a widget toolkit such as wxPython, so bear with the strange appearance of the window.
(Screenshot) (EXE) (Source) (Module entail) (All public domain).