Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1.     public static int Negamax_AlphaBeta(Node node, int d, int alpha, int beta){
  2.        
  3.         int value;
  4.         int count = 0;
  5.        
  6.         if(d==0 || node.equals(null)){
  7.             return node.getScore();
  8.         }
  9.        
  10.         int bestValue = -Integer.MAX_VALUE;
  11.        
  12.         for(Node child: node.childNode){
  13.             value = -Negamax_AlphaBeta(child, d-1, -alpha, -beta);
  14.             bestValue = Math.max(bestValue, value);
  15.             alpha = Math.max(alpha, value);
  16.             count++;
  17.             if(alpha >= beta){
  18.                 break;
  19.             }
  20.         }
  21.         node.setCount(count);
  22.         return bestValue;
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement