haga/src/Main.hs
David Pätzel bcf11d61e1 Implement bestsBy properly
Only needs something in O(n) now instead of a lot more. Also, returns the
complement.
2019-10-22 14:33:19 +02:00

28 lines
659 B
Haskell

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
import Protolude hiding (for)
import Pretty
import WS19
import Pipes
import System.IO
mkPop = population 100 (I prios [])
main :: IO ()
main = do
args <- getArgs
let t = fromMaybe 100 $ headMay args >>= readMaybe
hSetBuffering stdout NoBuffering
pop <- mkPop
pop' <- runEffect $ for (run 2 1 (5/100) pop (steps t)) log
(res, _) <- bests 5 pop'
sequence_ $ format <$> res
where
format s = do
f <- liftIO $ fitness s
putErrText $ show f <> "\n" <> pretty s
log = putText . csv
csv (t, f) = show t <> " " <> show f