Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private double calculateUCB(Node node) {
- // TODO Auto-generated method stub
- double score=0;
- int currentPlayer=(initialPlayer+node.getTreeDepth())%players.size();
- if (currentPlayer==initialPlayer){
- if(node.getNumberOfSimulations()==0){
- score=Double.MAX_VALUE;
- }else{
- double c=Math.sqrt(2);
- score=(node.getScore()*1.0/node.getNumberOfSimulations())+(c*Math.sqrt(Math.log(totalSimulations/node.getNumberOfSimulations())));
- }
- System.out.println("[depth " + node.getTreeDepth() + "] num of sim = "+node.getNumberOfSimulations() +"\n" + "node score = " +node.getScore()+ " UCB score is " + score);
- }
- else{
- if(node.getNumberOfSimulations()==0){
- score=-Double.MAX_VALUE;
- }else{
- double c=Math.sqrt(2);
- score=-(node.getScore()*1.0/node.getNumberOfSimulations())+(c*Math.sqrt(Math.log(totalSimulations/node.getNumberOfSimulations())));
- }
- System.out.println("[depth " + node.getTreeDepth() + "] num of sim = "+node.getNumberOfSimulations() +"\n" + "node score = " +node.getScore()+ " UCB score is " + score);
- }
- return score;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement