You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(ok, m) <- generateGame rows columns ratio difficulty tout
38
+
39
+
if ok thendo
40
+
writeFile path (show m)
41
+
print m
42
+
elsedo
43
+
putStrLn"The generator could not generate a hidato with the indicated arguments and the indicated time."
44
+
45
+
46
+
commandGenerate::Command
47
+
commandGenerate =
48
+
Command
49
+
{
50
+
cmdName ="generate",
51
+
cmdDescription ="Command to generate a hidato. The board is save to a file.\nDifficulty: [Easy, Normal, Hard]\nDefault timeout: 60000000 microseconds = 1 minute",
maybeMatrix <- timeout to $ generateRandomGame rn cn ratio
100
109
if isNothing maybeMatrix thendo
101
-
return$error"Game not found"
110
+
return(False, blankMatrix 11)
102
111
elsedo
103
112
let solution =maybe (blankMatrix rn cn) (\x -> x) maybeMatrix
104
113
let setForRemove =Set.filter (\x ->let v = value x in v >1&& v < rn * cn) (matrix solution) ::SetCell
@@ -109,11 +118,13 @@ generateGame rn cn ratio dif = do
109
118
let gen = mkStdGen seed
110
119
let seeds = randoms gen :: [Int]
111
120
let game = removeCells solution randomCells 0 cant_empty seeds
112
-
return game
121
+
return (True, game)
122
+
113
123
114
124
generate::Matrix
115
125
generate =read"{. x x x x x x x x \n . 8 x x x x x x x \n . . 11 x x x x x x \n 29 . 10 . x x x x x \n 30 . . . . x x x x \n . 31 1 38 . . x x x \n . 32 . . 39 41 . x x \n . . . 22 . . 42 . x \n . . . . . . . 44 45}"::Matrix
0 commit comments