|
@ -23,13 +23,22 @@ main = do args <- getArgs |
|
|
file <- return ((optFile opt) !! 0) |
|
|
file <- return ((optFile opt) !! 0) |
|
|
str <- BS.readFile file |
|
|
str <- BS.readFile file |
|
|
(id, gmseed) <- return (readInput str) |
|
|
(id, gmseed) <- return (readInput str) |
|
|
commands <- return (map (\(seed,game) -> strat0 game) gmseed) |
|
|
|
|
|
|
|
|
commandspoints <- return (map (\(seed,game) -> strat0 game) gmseed) |
|
|
|
|
|
(commands,points) <- return $ unzip commandspoints |
|
|
seeds <- return ((map (\(seed, _) -> seed)) gmseed) |
|
|
seeds <- return ((map (\(seed, _) -> seed)) gmseed) |
|
|
putStrLn . encodeJSON $ (packAll id seeds commands) |
|
|
putStrLn . encodeJSON $ (packAll id seeds commands) |
|
|
|
|
|
writeFile (file ++ ".output") (scoredata id (fst $ unzip gmseed) points) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
packAll :: Int -> [Int] -> [[Command]] -> [JSONSer] |
|
|
packAll :: Int -> [Int] -> [[Command]] -> [JSONSer] |
|
|
packAll id seeds commandLists = zipWith (\x y -> JSONSer id x "lilik0" y) seeds commandStrings |
|
|
packAll id seeds commandLists = zipWith (\x y -> JSONSer id x "lilik0" y) seeds commandStrings |
|
|
where |
|
|
where |
|
|
commandStrings = map cmdToString commandLists |
|
|
commandStrings = map cmdToString commandLists |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scoredata :: Int -> [Int] -> [Int] -> String |
|
|
|
|
|
scoredata id seeds points = pretty |
|
|
|
|
|
where |
|
|
|
|
|
pretty = foldl (\x (a,b,c) -> (show a) ++ " " ++ (show b) ++ " " ++ (show c) ++ "\n" ++ x) "" zipdata |
|
|
|
|
|
zipdata = zip3 ids seeds points |
|
|
|
|
|
ids = replicate (length seeds) id |
|
|
|
|
|
|