You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.0 KiB

  1. {-# LANGUAGE DeriveDataTypeable #-}
  2. module Main where
  3. import System.Environment
  4. import qualified Data.ByteString.Lazy as BS
  5. import System.IO
  6. import Text.JSON.Generic
  7. import Datatypes
  8. import Opt
  9. import JSONDeser
  10. import Strategy0
  11. data JSONSer = JSONSer { problemId :: Int,
  12. seed :: Int,
  13. tag :: String,
  14. solution :: String
  15. } deriving (Show, Data, Typeable)
  16. main :: IO ()
  17. main = do args <- getArgs
  18. opt <- parseArgs args
  19. file <- return ((optFile opt) !! 0)
  20. str <- BS.readFile file
  21. (id, gmseed) <- return (readInput str)
  22. commands <- return (map (\(seed,game) -> strat0 game) gmseed)
  23. seeds <- return ((map (\(seed, _) -> seed)) gmseed)
  24. putStrLn . encodeJSON $ (packAll id seeds commands)
  25. packAll :: Int -> [Int] -> [[Command]] -> [JSONSer]
  26. packAll id seeds commandLists = zipWith (\x y -> JSONSer id x "cazziammolla" y) seeds commandStrings
  27. where
  28. commandStrings = map cmdToString commandLists