Advertisement
SebastianLague

Minimax pseudocode

Apr 20th, 2018
15,167
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 1 0
  1. function minimax(position, depth, maximizingPlayer)
  2. if depth == 0 or game over in position
  3. return static evaluation of position
  4.  
  5. if maximizingPlayer
  6. maxEval = -infinity
  7. for each child of position
  8. eval = minimax(child, depth - 1, false)
  9. maxEval = max(maxEval, eval)
  10. return maxEval
  11.  
  12. else
  13. minEval = +infinity
  14. for each child of position
  15. eval = minimax(child, depth - 1, true)
  16. minEval = min(minEval, eval)
  17. return minEval
  18.  
  19.  
  20. // initial call
  21. minimax(currentPosition, 3, true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement