Paste: halting problem
Author: | sucks |
Mode: | haskell |
Date: | Sat, 20 Feb 2010 03:50:04 |
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 return 0
else do
putTraceMsg "e"
randGame walls width (otherPlayer pid) (us+direction) them
New Annotation