Implemented naive Monte Carlo move generator (simulates 10 random moves for 3 turns by each player).
Consequently, it performs strictly worse than Alpha-Beta, but usually avoids setting players up for an easy capture, unlike Alpha-Beta.
This commit is contained in:
@@ -29,22 +29,6 @@ public class AlphaBetaMoveGenerator implements MoveGenerator {
|
||||
Integer.MAX_VALUE).move;
|
||||
}
|
||||
}
|
||||
|
||||
private SearchResult getMax(SearchResult sr1, SearchResult sr2) {
|
||||
if (sr1.score >= sr2.score) {
|
||||
return sr1;
|
||||
} else {
|
||||
return sr2;
|
||||
}
|
||||
}
|
||||
|
||||
private SearchResult getMin(SearchResult sr1, SearchResult sr2) {
|
||||
if (sr1.score <= sr2.score) {
|
||||
return sr1;
|
||||
} else {
|
||||
return sr2;
|
||||
}
|
||||
}
|
||||
|
||||
private SearchResult getMaxValue(Board board, boolean asHuman, int recursionLevel,
|
||||
int alpha, int beta) {
|
||||
@@ -72,7 +56,9 @@ public class AlphaBetaMoveGenerator implements MoveGenerator {
|
||||
SearchResult searchResult = new SearchResult(nextMove,getMinValue(nextBoard, !asHuman, recursionLevel - 1,
|
||||
alpha, beta).score);
|
||||
|
||||
bestResult = getMax(bestResult,searchResult);
|
||||
if (searchResult.compareTo(bestResult) > 0) {
|
||||
bestResult = searchResult;
|
||||
}
|
||||
|
||||
if (bestResult.score >= beta) {
|
||||
return bestResult;
|
||||
@@ -110,7 +96,9 @@ public class AlphaBetaMoveGenerator implements MoveGenerator {
|
||||
SearchResult searchResult = new SearchResult(nextMove,getMaxValue(nextBoard, !asHuman, recursionLevel - 1,
|
||||
alpha, beta).score);
|
||||
|
||||
bestResult = getMin(bestResult,searchResult);
|
||||
if (searchResult.compareTo(bestResult) < 0) {
|
||||
bestResult = searchResult;
|
||||
}
|
||||
|
||||
if (bestResult.score <= alpha) {
|
||||
return bestResult;
|
||||
|
||||
Reference in New Issue
Block a user