mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-21 02:53:15 +08:00
Add automatic linter (#4214)
This commit is contained in:
@ -78,8 +78,7 @@ public class MonteCarloTreeSearch {
|
||||
|
||||
winnerNode = getWinnerNode(rootNode);
|
||||
printScores(rootNode);
|
||||
System.out.format(
|
||||
"\nThe optimal node is: %02d\n", rootNode.childNodes.indexOf(winnerNode) + 1);
|
||||
System.out.format("\nThe optimal node is: %02d\n", rootNode.childNodes.indexOf(winnerNode) + 1);
|
||||
|
||||
return winnerNode;
|
||||
}
|
||||
@ -119,10 +118,7 @@ public class MonteCarloTreeSearch {
|
||||
break;
|
||||
}
|
||||
|
||||
uctTemp = ((double) childNode.score / childNode.visitCount)
|
||||
+ 1.41
|
||||
* Math.sqrt(
|
||||
Math.log(promisingNode.visitCount) / (double) childNode.visitCount);
|
||||
uctTemp = ((double) childNode.score / childNode.visitCount) + 1.41 * Math.sqrt(Math.log(promisingNode.visitCount) / (double) childNode.visitCount);
|
||||
|
||||
if (uctTemp > uctIndex) {
|
||||
uctIndex = uctTemp;
|
||||
@ -161,8 +157,7 @@ public class MonteCarloTreeSearch {
|
||||
tempNode.visitCount++;
|
||||
|
||||
// Add wining scores to bouth player and opponent depending on the turn.
|
||||
if ((tempNode.isPlayersTurn && isPlayerWinner)
|
||||
|| (!tempNode.isPlayersTurn && !isPlayerWinner)) {
|
||||
if ((tempNode.isPlayersTurn && isPlayerWinner) || (!tempNode.isPlayersTurn && !isPlayerWinner)) {
|
||||
tempNode.score += WIN_SCORE;
|
||||
}
|
||||
|
||||
@ -178,8 +173,7 @@ public class MonteCarloTreeSearch {
|
||||
System.out.println("N.\tScore\t\tVisits");
|
||||
|
||||
for (int i = 0; i < rootNode.childNodes.size(); i++) {
|
||||
System.out.printf("%02d\t%d\t\t%d%n", i + 1, rootNode.childNodes.get(i).score,
|
||||
rootNode.childNodes.get(i).visitCount);
|
||||
System.out.printf("%02d\t%d\t\t%d%n", i + 1, rootNode.childNodes.get(i).score, rootNode.childNodes.get(i).visitCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user