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.

35 lines
1.0 KiB

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