All MoveGenerators default to 1 move lookahead.
Made MoveGenerators protected for unit testing. Added unit test for some analysis of MoveGenerator speeds. Fixed MDP to consider all states where #turns = maxTurns terminal.
This commit is contained in:
@@ -10,7 +10,7 @@ import model.SearchResult;
|
||||
|
||||
public class AlphaBetaMoveGenerator implements MoveGenerator {
|
||||
private static final int DEFAULT_RECURSIVE_PLAYS = 1;
|
||||
|
||||
private int lookahead = DEFAULT_RECURSIVE_PLAYS;
|
||||
private final BoardScorer scorer = new BoardScorer();
|
||||
private final ValidMoveGenerator validMoveGenerator = new ValidMoveGenerator();
|
||||
|
||||
@@ -18,10 +18,10 @@ public class AlphaBetaMoveGenerator implements MoveGenerator {
|
||||
public Move genMove(Board board, boolean asHuman) {
|
||||
|
||||
if (!asHuman) {
|
||||
return getMaxValue(board, asHuman, DEFAULT_RECURSIVE_PLAYS * 2,
|
||||
return getMaxValue(board, asHuman, lookahead * 2,
|
||||
Integer.MIN_VALUE, Integer.MAX_VALUE).move;
|
||||
} else {
|
||||
return getMinValue(board, asHuman, DEFAULT_RECURSIVE_PLAYS * 2,
|
||||
return getMinValue(board, asHuman, lookahead * 2,
|
||||
Integer.MIN_VALUE, Integer.MAX_VALUE).move;
|
||||
}
|
||||
}
|
||||
@@ -114,4 +114,9 @@ public class AlphaBetaMoveGenerator implements MoveGenerator {
|
||||
|
||||
return bestResult;
|
||||
}
|
||||
@Override
|
||||
public boolean setLookahead(int lookahead) {
|
||||
this.lookahead = lookahead;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user