Skip to content

Commit

Permalink
uniformize predictive step
Browse files Browse the repository at this point in the history
  • Loading branch information
yoni-madlan committed Jun 27, 2019
1 parent 306dc3b commit 174d2f7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions MCTS.hs
Expand Up @@ -112,15 +112,16 @@ mkTrunk !first !testval !xs = maybeTrunk $! partition f xs where
advanceuntil :: MCSolvedGame -> IO (IO MCSolvedGame)
advanceuntil mgs = if background $ params mgs then do
mfinish <- newMVar False
let maxsim' = fromIntegral $ maxsim $ params mgs
let mgs' = mgs {params = (params mgs) {uniform=True}}
maxsim' = fromIntegral $ maxsim $ params mgs
internal cgs = do
hFlush stdout
rand <- newStdGen
finish <- readMVar mfinish
if finish || simulations cgs > maxsim'
then return cgs
else internal $! multiadvance 1000 cgs rand
solver <- async $ internal mgs
solver <- async $ internal mgs'
return $ do
swapMVar mfinish True
wait solver
Expand Down Expand Up @@ -173,7 +174,7 @@ advanceNode !mgs@(MCSolvedGame {simulations=s, wins=w, gameState,
(mgs {simulations = s', wins = w+val, children = f children', params = p'}, rand', val) where
(MCAction (_, (!str, !child)), !queue) = fromJust $ PQ.extract nonterminals
!p' = p {uniform = False}
!evalfunc' = if uniform then (\_ _ n _ -> n) else evalfunc
!evalfunc' = if uniform then (\_ _ n _ -> s-n) else evalfunc
!first = firstplayer gameState
!objective = if first then maximum else minimum
!s' = s+1
Expand Down

0 comments on commit 174d2f7

Please sign in to comment.