parent
d98b696baa
commit
5a92adbc39
|
@ -10,7 +10,7 @@ public class MonteCarloTreeSearch {
|
||||||
|
|
||||||
private static final int WIN_SCORE = 10;
|
private static final int WIN_SCORE = 10;
|
||||||
private int level;
|
private int level;
|
||||||
private int oponent;
|
private int opponent;
|
||||||
|
|
||||||
public MonteCarloTreeSearch() {
|
public MonteCarloTreeSearch() {
|
||||||
this.level = 3;
|
this.level = 3;
|
||||||
|
@ -32,11 +32,11 @@ public class MonteCarloTreeSearch {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
long end = start + 60 * getMillisForCurrentLevel();
|
long end = start + 60 * getMillisForCurrentLevel();
|
||||||
|
|
||||||
oponent = 3 - playerNo;
|
opponent = 3 - playerNo;
|
||||||
Tree tree = new Tree();
|
Tree tree = new Tree();
|
||||||
Node rootNode = tree.getRoot();
|
Node rootNode = tree.getRoot();
|
||||||
rootNode.getState().setBoard(board);
|
rootNode.getState().setBoard(board);
|
||||||
rootNode.getState().setPlayerNo(oponent);
|
rootNode.getState().setPlayerNo(opponent);
|
||||||
|
|
||||||
while (System.currentTimeMillis() < end) {
|
while (System.currentTimeMillis() < end) {
|
||||||
// Phase 1 - Selection
|
// Phase 1 - Selection
|
||||||
|
@ -93,7 +93,7 @@ public class MonteCarloTreeSearch {
|
||||||
State tempState = tempNode.getState();
|
State tempState = tempNode.getState();
|
||||||
int boardStatus = tempState.getBoard().checkStatus();
|
int boardStatus = tempState.getBoard().checkStatus();
|
||||||
|
|
||||||
if (boardStatus == oponent) {
|
if (boardStatus == opponent) {
|
||||||
tempNode.getParent().getState().setWinScore(Integer.MIN_VALUE);
|
tempNode.getParent().getState().setWinScore(Integer.MIN_VALUE);
|
||||||
return boardStatus;
|
return boardStatus;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue