|
@ -1,7 +1,7 @@ |
|
|
{-# LANGUAGE DeriveGeneric #-} |
|
|
{-# LANGUAGE DeriveGeneric #-} |
|
|
module JSONDeser where |
|
|
module JSONDeser where |
|
|
|
|
|
|
|
|
import qualified Data.Set as Set |
|
|
|
|
|
|
|
|
import Data.Set(fromList) |
|
|
import Data.Maybe |
|
|
import Data.Maybe |
|
|
import qualified Data.ByteString.Lazy as BS |
|
|
import qualified Data.ByteString.Lazy as BS |
|
|
import Data.Aeson |
|
|
import Data.Aeson |
|
@ -52,10 +52,10 @@ newGame :: Input -> (Int,[(Int,DT.Game)]) |
|
|
newGame input = (JSONDeser.id input, zip (sourceSeeds input) (map gameFromSeed (sourceSeeds input))) |
|
|
newGame input = (JSONDeser.id input, zip (sourceSeeds input) (map gameFromSeed (sourceSeeds input))) |
|
|
where |
|
|
where |
|
|
gameFromSeed seed = DT.Game.new board (seedUnits seed input) |
|
|
gameFromSeed seed = DT.Game.new board (seedUnits seed input) |
|
|
board = DT.Board w h filledel |
|
|
|
|
|
|
|
|
board = DT.Board w h filledelement |
|
|
w = width input |
|
|
w = width input |
|
|
h = height input |
|
|
h = height input |
|
|
filledel = Set.fromList (map cellConvVM (filled input)) |
|
|
|
|
|
|
|
|
filledelement = Set.fromList (map cellConvVM (filled input)) |
|
|
|
|
|
|
|
|
seedUnits :: Int -> Input -> [DT.Unit] |
|
|
seedUnits :: Int -> Input -> [DT.Unit] |
|
|
seedUnits s input = map (\x -> uinput !! x ) unit_index |
|
|
seedUnits s input = map (\x -> uinput !! x ) unit_index |
|
|