Browse Source

removed some dependencies

adaptedStrategy0
Andrea Bellandi 9 years ago
parent
commit
787cc8789c
5 changed files with 13 additions and 15 deletions
  1. +3
    -3
      src/JSONDeser.hs
  2. +1
    -1
      src/LCG.hs
  3. +1
    -1
      src/Main.hs
  4. +5
    -5
      src/PowerPhrases.hs
  5. +3
    -5
      src/StrategyManager.hs

+ 3
- 3
src/JSONDeser.hs View File

@ -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


+ 1
- 1
src/LCG.hs View File

@ -1,6 +1,6 @@
module LCG where
import Data.Bits
import Data.Bits(shiftR,(.&.))
modulus = 2^32
multiplier = 1103515245


+ 1
- 1
src/Main.hs View File

@ -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)]


+ 5
- 5
src/PowerPhrases.hs View File

@ -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

+ 3
- 5
src/StrategyManager.hs View File

@ -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


Loading…
Cancel
Save