slightly clean up day21p2
This commit is contained in:
parent
46154a9a1b
commit
56c3fded10
|
|
@ -26,16 +26,11 @@ put x = NdState $ const [((), x)]
|
||||||
get :: NdState a a
|
get :: NdState a a
|
||||||
get = NdState (\s -> [(s,s)])
|
get = NdState (\s -> [(s,s)])
|
||||||
|
|
||||||
putMany :: [a] -> NdState a ()
|
|
||||||
putMany xs = NdState $ const $ map (\x -> ((), x)) xs
|
|
||||||
|
|
||||||
returnMany :: [b] -> NdState a b
|
returnMany :: [b] -> NdState a b
|
||||||
returnMany xs = NdState (\s -> map (\x -> (x,s)) xs)
|
returnMany xs = NdState (\s -> map (\x -> (x,s)) xs)
|
||||||
|
|
||||||
data PlayerState = PS {score :: Integer, field :: Int} deriving Show
|
data PlayerState = PS {score :: Integer, field :: Int} deriving Show
|
||||||
data GameState = P1 PlayerState PlayerState | P2 PlayerState PlayerState deriving Show
|
data GameState = P1 PlayerState PlayerState | P2 PlayerState PlayerState deriving Show
|
||||||
-- type Game = State (GameState, DiceState)
|
|
||||||
|
|
||||||
|
|
||||||
type Game = NdState GameState
|
type Game = NdState GameState
|
||||||
|
|
||||||
|
|
@ -85,7 +80,7 @@ move = do
|
||||||
(_,_) -> Nothing
|
(_,_) -> Nothing
|
||||||
|
|
||||||
runGame :: GameState -> (Integer, Integer)
|
runGame :: GameState -> (Integer, Integer)
|
||||||
runGame gs = rgA ! (gsTuple gs) where
|
runGame = runGame' where
|
||||||
rgA = array ((False,0,1,0,1), (True,30,10,30,10))
|
rgA = array ((False,0,1,0,1), (True,30,10,30,10))
|
||||||
[let key = (p,s1,f1,s2,f2) in (key, runGame' $ tupleGs key) |
|
[let key = (p,s1,f1,s2,f2) in (key, runGame' $ tupleGs key) |
|
||||||
p <- [False, True], s1 <- [0..30], s2 <- [0..30], f1 <- [1..10], f2 <- [1..10]]
|
p <- [False, True], s1 <- [0..30], s2 <- [0..30], f1 <- [1..10], f2 <- [1..10]]
|
||||||
|
|
@ -108,6 +103,3 @@ main = do
|
||||||
print (p1pos, p2pos)
|
print (p1pos, p2pos)
|
||||||
|
|
||||||
print $ part2 p1pos p2pos
|
print $ part2 p1pos p2pos
|
||||||
|
|
||||||
|
|
||||||
print "Bye"
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue