Browse Source

Import main init function

DricomDragon 5 years ago
parent
commit
7ef19988d6
1 changed files with 19 additions and 0 deletions
  1. 19 0
      tp/mine-sweeper/main.hs

+ 19 - 0
tp/mine-sweeper/main.hs

@@ -11,6 +11,8 @@ import Data.Universe.Helpers ( cartesianProduct ) -- Need to be installed : `cab
 
 import Data.List ( foldl1' )
 
+import Systeme.IO
+
 -- Types
 
 data Cell   = Covered Int Bool Bool -- number of bombs around ; has bomb ; has flag
@@ -145,6 +147,23 @@ loop i j n b@(Grid xs)
             'u' -> loop i j n (uncover (i, j) b) -- uncover tile
             otherwise -> loop i j n b -- do nothing
 
+main::IO()
+main = do
+    hSetBuffering stdin NoBuffering -- disable the need to press enter
+    hSetEcho stdin False -- dont print input in terminal
+
+    -- random sequences
+    sg <- newStdGen
+    sg' <- newStdGen
+
+    -- parameters
+    let nmines = 5
+    let h = 7
+    let w = 10
+
+    ... -- create grid, add mines, update neighbours
+    loop ... -- start loop
+
 
 -- Testing data