From 787cc8789c42750d3ffed2743e2d594b665a51c3 Mon Sep 17 00:00:00 2001 From: Andrea Bellandi Date: Mon, 10 Aug 2015 00:50:39 +0200 Subject: [PATCH] removed some dependencies --- src/JSONDeser.hs | 6 +++--- src/LCG.hs | 2 +- src/Main.hs | 2 +- src/PowerPhrases.hs | 10 +++++----- src/StrategyManager.hs | 8 +++----- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/JSONDeser.hs b/src/JSONDeser.hs index b85fded..353e8a9 100644 --- a/src/JSONDeser.hs +++ b/src/JSONDeser.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DeriveGeneric #-} module JSONDeser where -import qualified Data.Set as Set +import Data.Set(fromList) import Data.Maybe import qualified Data.ByteString.Lazy as BS 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))) where gameFromSeed seed = DT.Game.new board (seedUnits seed input) - board = DT.Board w h filledel + board = DT.Board w h filledelement w = width input h = height input - filledel = Set.fromList (map cellConvVM (filled input)) + filledelement = Set.fromList (map cellConvVM (filled input)) seedUnits :: Int -> Input -> [DT.Unit] seedUnits s input = map (\x -> uinput !! x ) unit_index diff --git a/src/LCG.hs b/src/LCG.hs index 98a413d..ea005dc 100644 --- a/src/LCG.hs +++ b/src/LCG.hs @@ -1,6 +1,6 @@ module LCG where -import Data.Bits +import Data.Bits(shiftR,(.&.)) modulus = 2^32 multiplier = 1103515245 diff --git a/src/Main.hs b/src/Main.hs index cefcad5..337f7c0 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -50,7 +50,7 @@ type Id = Int type Seed = Int strategies :: Game -> StdGen -> Maybe [Command] -> GameComputation -strategies g sgen cmd = [MkStrategyWrapper (initst g sgen cmd :: Strategy0)] +strategies g sgen cmd = [MkStrategyWrapper (initst g sgen cmd :: NullStrategy1)] -- = [MkStrategyWrapper (initst g sgen cmd :: NullStrategy1), -- MkStrategyWrapper (initst g sgen cmd :: NullStrategy2)] diff --git a/src/PowerPhrases.hs b/src/PowerPhrases.hs index 94ac0d7..6c59930 100644 --- a/src/PowerPhrases.hs +++ b/src/PowerPhrases.hs @@ -1,8 +1,11 @@ +{-# OPTIONS -Wall #-} module PowerPhrases where -import Data.Maybe +import Data.Maybe(mapMaybe) import Datatypes.Game (Command(..)) +listToCommand :: String -> [Command] +listToCommand str = mapMaybe charToCommand str charToCommand :: Char -> Maybe Command @@ -48,8 +51,5 @@ charToCommand 'u' = Just RotateCounterclockwise charToCommand 'w' = Just RotateCounterclockwise charToCommand 'x' = Just RotateCounterclockwise -charToCommand '\t' = Nothing -charToCommand '\n' = Nothing -charToCommand '\r' = Nothing - +charToCommand _ = Nothing diff --git a/src/StrategyManager.hs b/src/StrategyManager.hs index f9583d9..915d779 100644 --- a/src/StrategyManager.hs +++ b/src/StrategyManager.hs @@ -2,16 +2,14 @@ {-# OPTIONS -Wall #-} module StrategyManager where -import System.Random - -import Datatypes -import Datatypes.Game +import System.Random(StdGen) +import Datatypes.Game(Game,Command) type GameComputation = [StrategyWrapper] data StrategyWrapper = forall a . Strategy a => MkStrategyWrapper a | FinishedGame ([Command], Int) - + data NullStrategy1 = NullS1