Add automatic linter (#4214)

This commit is contained in:
acbin
2023-06-09 20:05:14 +08:00
committed by GitHub
parent 00282efd8b
commit 415a04ea7f
188 changed files with 661 additions and 1133 deletions

View File

@ -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);
}
}
}