haga/src/Main.hs

28 lines
668 B
Haskell
Raw Normal View History

{-# LANGUAGE FlexibleContexts #-}
2019-05-30 12:40:32 +02:00
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
2019-05-30 12:40:32 +02:00
import Pipes
import Pretty
import Protolude hiding (for)
import System.IO
2020-01-07 07:48:57 +01:00
import Szenario191
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