
18 Mar
2009
18 Mar
'09
6:06 a.m.
The code of the following routine is intended to indicate how long it takes for the computer to make a move. However the time is printed (as very close to zero) long before the move is made. I must be missing something about sequencing actions in the IO monad. play_move :: IORef Game_state -> IO () play_move game_state_ior = do (_, state, _) <- readIORef game_state_ior putStr "Playing AI: " start_time <- getCurrentTime let move = recommended_move state modifyIORef game_state_ior (update_interactive_from_move move) end_time <- getCurrentTime putStrLn $ show $ (diffUTCTime end_time start_time) -- Colin Adams Preston Lancashire