Paste: halt more
Author: | damn it |
Mode: | haskell |
Date: | Sat, 20 Feb 2010 03:56:39 |
Plain Text |
randGame :: IOUArray Pos Bool -> Pos -> Int -> Player -> Player -> IO Int
randGame walls width pid them us =
let
otherPlayer 1 = 2
otherPlayer 2 = 1
in do
putTraceMsg "a"
writeArray walls us False
directions <- movesIO walls width us
putTraceMsg "b"
if (directions==[]) then return (otherPlayer pid) else do
gen <- getStdGen
putTraceMsg "c"
let (choice,gen) = randomR (0, length directions - 1) gen
direction = directions !! choice
setStdGen gen
putTraceMsg "d"
if (us+direction==them) then do
putTraceMsg "f"
return 0
else do
putTraceMsg "e"
randGame walls width (otherPlayer pid) (us+direction) them
New Annotation