{-# LANGUAGE DeriveDataTypeable #-}
|
|
module Main where
|
|
|
|
import System.Environment
|
|
import qualified Data.ByteString.Lazy as BS
|
|
import System.IO
|
|
import Text.JSON.Generic
|
|
import Datatypes
|
|
import Opt
|
|
import JSONDeser
|
|
import Strategy0
|
|
|
|
data JSONSer = JSONSer { problemId :: Int,
|
|
seed :: Int,
|
|
tag :: String,
|
|
solution :: String
|
|
} deriving (Show, Data, Typeable)
|
|
|
|
main :: IO ()
|
|
main = do args <- getArgs
|
|
opt <- parseArgs args
|
|
file <- return ((optFile opt) !! 0)
|
|
str <- BS.readFile file
|
|
(id, gmseed) <- return (readInput str)
|
|
commands <- return (map (\(seed,game) -> strat0 game) gmseed)
|
|
seeds <- return ((map (\(seed, _) -> seed)) gmseed)
|
|
putStrLn . encodeJSON $ (packAll id seeds commands)
|
|
|
|
packAll :: Int -> [Int] -> [[Command]] -> [JSONSer]
|
|
packAll id seeds commandLists = zipWith (\x y -> JSONSer id x "cazziammolla" y) seeds commandStrings
|
|
where
|
|
commandStrings = map cmdToString commandLists
|
|
|
|
|