Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. private double calculateUCB(Node node) {
  2. // TODO Auto-generated method stub
  3. double score=0;
  4. int currentPlayer=(initialPlayer+node.getTreeDepth())%players.size();
  5. if (currentPlayer==initialPlayer){
  6. if(node.getNumberOfSimulations()==0){
  7. score=Double.MAX_VALUE;
  8.  
  9. }else{
  10. double c=Math.sqrt(2);
  11.  
  12. score=(node.getScore()*1.0/node.getNumberOfSimulations())+(c*Math.sqrt(Math.log(totalSimulations/node.getNumberOfSimulations())));
  13.  
  14. }
  15. System.out.println("[depth " + node.getTreeDepth() + "] num of sim = "+node.getNumberOfSimulations() +"\n" + "node score = " +node.getScore()+ " UCB score is " + score);
  16. }
  17. else{
  18.  
  19. if(node.getNumberOfSimulations()==0){
  20. score=-Double.MAX_VALUE;
  21.  
  22. }else{
  23. double c=Math.sqrt(2);
  24.  
  25. score=-(node.getScore()*1.0/node.getNumberOfSimulations())+(c*Math.sqrt(Math.log(totalSimulations/node.getNumberOfSimulations())));
  26.  
  27. }
  28. System.out.println("[depth " + node.getTreeDepth() + "] num of sim = "+node.getNumberOfSimulations() +"\n" + "node score = " +node.getScore()+ " UCB score is " + score);
  29. }
  30.  
  31. return score;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement