-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
82 lines (75 loc) · 2.07 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{-# LANGUAGE RecordWildCards #-}
module Main where
import Options.Applicative
import System.Environment (getArgs)
import qualified Data.ByteString.Char8 as BS
import Crossed (printClues, printGrid, run)
data Options =
Options
{ visualize :: Bool
, batchSize :: Int
, gridSize :: Int
, minStart :: Int
, words :: Int
, gas :: Int
}
options :: Parser Options
options = Options
<$> switch
( long "visualize"
<> short 'v'
<> help "Print intermediate grids during generation."
)
<*> option auto
( long "batchSize"
<> short 'b'
<> help "Control the available word pool. Taken from a random shuffle of ~283,000 words. Increases generation time."
<> showDefault
<> value 1000
<> metavar "INT"
)
<*> option auto
( long "gridSize"
<> short 'g'
<> help "Length and width of the grid."
<> showDefault
<> value 15
<> metavar "INT"
)
<*> option auto
( long "minStart"
<> short 's'
<> help "Minimum length for starting word."
<> showDefault
<> value 5
<> metavar "INT"
)
<*> option auto
( long "words"
<> short 'w'
<> help "Number of words needed for a solution. Increases generation time."
<> showDefault
<> value 35
<> metavar "INT"
)
<*> option auto
( long "checkLimit"
<> short 'l'
<> help "Number of word placement attempts made before returning a solution."
<> showDefault
<> value 100000
<> metavar "INT"
)
optionsInfo :: ParserInfo Options
optionsInfo =
info (options <**> helper)
( fullDesc
<> progDesc "Generate a sparse crossword puzzle, i.e. given a list of dictionary words and their clues, find a populated grid that solves for the given constraints."
)
main :: IO ()
main = do
Options{..} <- execParser optionsInfo
lines <- BS.lines <$> BS.readFile "clues-desc.tsv"
grid <- run visualize lines batchSize gridSize minStart words gas
printGrid gridSize grid
printClues grid