module Configuration ( Configuration ( Configuration , tableConfig , strategy , deathProbRange ) , TableConfig , tConfig , size , mines , numOfSolutions , Strategy (..) , Probability , defaultConfiguration , showConfiguration ) where import Core.Square import Core.SquareConstraints import Data.Data --import Control.Monad ---------------------------------- data TableConfig = TableConfig { tsize :: BoardSize , tmines :: Int , numOfSolutions_ :: Integer -- cached } deriving (Eq, Ord, Show, Typeable, Data) tConfig :: BoardSize -> Int -> TableConfig tConfig s m = TableConfig s m (solutions $ initConstraints s m) ----------------- data Configuration = Configuration { tableConfig :: TableConfig , strategy :: Strategy , deathProbRange :: (Probability, Probability) -- (a, b): ha p valséggel halnánk meg, akkor p>a esetén meghalunk, p Integer numOfSolutions = numOfSolutions_ . tableConfig size :: Configuration -> BoardSize size = tsize . tableConfig mines :: Configuration -> Int mines = tmines . tableConfig ------------------------ defaultConfiguration :: Configuration defaultConfiguration = Configuration { tableConfig = tConfig (boardSize 10 10) 20 , strategy = Random , deathProbRange = (1,1) } ------------------------- showConfiguration c = unlines $ filter (not . null) [ unwords [show (xSize s) ++ "×" ++ show (ySize s), "table,", show $ mines c, "mines"] , showStrategy $ strategy c , showDPR $ deathProbRange c ] where s = size c showStrategy Random = "" showStrategy HighestProb = "least information game" showDPR (0,1) = "" showDPR (1,1) = "lucky game" showDPR _ = "" -- (a, b): ha p valséggel halnánk meg, akkor p>a esetén meghalunk, p