Parallelize next guess calculation
This commit is contained in:
parent
a97a4cfa08
commit
2a9f7c6f6b
2 changed files with 6 additions and 4 deletions
|
|
@ -23,6 +23,7 @@ dependencies:
|
|||
- base >= 4.7 && < 5
|
||||
- containers
|
||||
- haskeline
|
||||
- parallel
|
||||
- text
|
||||
- transformers
|
||||
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ module Jotto
|
|||
, nextGuesses
|
||||
) where
|
||||
|
||||
import Data.List
|
||||
import Data.Char
|
||||
import Data.List
|
||||
|
||||
import Control.Parallel.Strategies
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.Set as S
|
||||
|
||||
|
|
@ -160,7 +161,7 @@ nextGuesses g =
|
|||
lpwords = M.map length $ pwords
|
||||
pclasses = M.keysSet pwords
|
||||
options1 = M.assocs $ allWords g
|
||||
options2 = map (\(set, w) -> (set, worstCase set lpwords, w)) options1
|
||||
options2 = parMap rdeepseq (\(set, w) -> (set, worstCase set lpwords, w)) options1
|
||||
options3 = sortOn (\(_,_,w) -> length w) options2
|
||||
options4 = sortOn (\(s,_,_) -> S.member s pclasses) options3
|
||||
options5 = sortOn (\(_,c,_) -> c) options4
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue