Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
A simple number-guessing game implementation via queries. Clearly an SMT solver is hardly needed for this problem, but it is a nice demo for the interactive-query programming.
Documentation
guess :: Integer -> Symbolic [Integer] Source #
Use the backend solver to guess the number given as argument.
The number is assumed to be between 0
and 1000
, and we use a simple
binary search. Returns the sequence of guesses we performed during
the search process.
Play a round of the game, making the solver guess the secret number 42. Note that you can generate a random-number and make the solver guess it too! We have:
>>>
play
Current bounds: (0,1000) Current bounds: (21,1000) Current bounds: (31,1000) Current bounds: (36,1000) Current bounds: (39,1000) Current bounds: (40,1000) Current bounds: (41,1000) Current bounds: (42,1000) Solved in: 8 guesses: 8 21 31 36 39 40 41 42