Advertisement
Coriic

Untitled

Jun 4th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. minmaxAlfa [] color level maxLevel alfa beta = alfa
  2. minmaxAlfa (x:xs) color level maxLevel alfa beta
  3.     | (newAlfa>=beta) = beta
  4.     | otherwise  = minmaxAlfa xs color level maxLevel newAlfa beta
  5.     where
  6.         newAlfa = max alfa (exploreTree x color level maxLevel alfa beta)
  7.  
  8. minmaxBeta [] color level maxLevel alfa beta = beta
  9. minmaxBeta (x:xs) color level maxLevel alfa beta
  10.     | (alfa >= newBeta) = alfa
  11.     | otherwise = minmaxBeta xs color level maxLevel alfa newBeta
  12.     where
  13.         newBeta = min beta (exploreTree x color level maxLevel alfa beta)
  14.  
  15. exploreTree (Node node children) color level maxLevel alfa beta
  16.     | Prelude.null children = rateBoard node color
  17.     | level>maxLevel = if (level `mod` 2 == 0) then maximum (rateBoards children color) else minimum (rateBoards children color)
  18.     | level `mod` 2 == 0 = minmaxBeta children color (level+1) maxLevel alfa beta
  19.     | otherwise = minmaxAlfa children color (level+1) maxLevel alfa beta
  20.  
  21. minmax (Node node children) color maxLevel = exploreTree (Node node children) color 0 maxLevel (-1000) 1000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement