10
10
import java .util .stream .Collectors ;
11
11
import org .xxdc .oss .example .GameState ;
12
12
13
+ /**
14
+ * Implements the Monte Carlo Tree Search (MCTS) algorithm for a game bot strategy. The MCTS
15
+ * algorithm is used to select the best move for the current game state by simulating random game
16
+ * play and backpropagating the results to update the search tree. The algorithm can be configured
17
+ * with a maximum time limit and maximum number of iterations.
18
+ */
13
19
public final class MonteCarloTreeSearch implements BotStrategy {
14
20
15
21
private static final Logger log = System .getLogger (MonteCarloTreeSearch .class .getName ());
@@ -21,10 +27,23 @@ public final class MonteCarloTreeSearch implements BotStrategy {
21
27
private static final double MAX_SCORE = 1.0 ;
22
28
private static final double DRAW_SCORE = 0.0 ;
23
29
30
+ /**
31
+ * Constructs a new instance of the {@link MonteCarloTreeSearch} class with the given initial game
32
+ * state and a default configuration (max time limit of 1 second).
33
+ *
34
+ * @param state the initial game state to use for the Monte Carlo tree search
35
+ */
24
36
public MonteCarloTreeSearch (GameState state ) {
25
37
this (state , BotStrategyConfig .newBuilder ().maxTimeMillis (TimeUnit .SECONDS , 1 ).build ());
26
38
}
27
39
40
+ /**
41
+ * Constructs a new instance of the {@link MonteCarloTreeSearch} class with the given initial game
42
+ * state and configuration.
43
+ *
44
+ * @param state the initial game state to use for the Monte Carlo tree search
45
+ * @param config the configuration settings for the Monte Carlo tree search
46
+ */
28
47
public MonteCarloTreeSearch (GameState state , BotStrategyConfig config ) {
29
48
this .initialState = state ;
30
49
this .config = config ;
0 commit comments