Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added debug logging for AI move choices #37

Merged
merged 1 commit into from
Oct 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void searchMoves(GS currentGameState, int allottedTimeMs) {
++numSimulations;
}
LOGGER.info("Performed {} simulations in {} ms", numSimulations, allottedTimeMs);
logMoveChoices(currentGameState);
}

private <GS extends GameState<GM, ? extends GameResult>> void performPlayoutSimulation(GS playoutGameState) {
Expand Down Expand Up @@ -68,4 +69,19 @@ public GM selectMove() {
public void applyMove(GM move, GameState<GM, ? extends GameResult> resultingGameState) {
searchTree.advanceTree(move, resultingGameState);
}

public void logMoveChoices(GameState<GM, ? extends GameResult> rootGameState) {
String evaluatingPlayerName = rootGameState.getNextPlayerName();
LOGGER.debug("Top level moves considered by the AIService from {}'s perspective:", evaluatingPlayerName);
SearchTreeIterator<GM,NR> iterator = searchTree.iterator();
while (iterator.hasNextChild()) {
iterator.advanceChildNode();
String moveString = rootGameState.getHumanReadableMoveString(iterator.getCurrentChildMove());
NR nodeResults = iterator.getCurrentChildIterator().getCurrentNodeResults();
LOGGER.debug("Move {} was visited in {} simulations and has score {}",
moveString,
nodeResults.getNumSimulations(),
nodeResults.getValue(evaluatingPlayerName));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void searchMoves(GS currentGameState, int allottedTimeMs) {
++numSimulations;
}
LOGGER.info("Performed {} simulations in {} ms", numSimulations, allottedTimeMs);
logMoveChoices(currentGameState);
}

private <GS extends GameState<GM, ? extends GameResult>> void performPlayoutSimulation(GS playoutGameState) {
Expand Down Expand Up @@ -74,4 +75,19 @@ public GM selectMove() {
public void applyMove(GM move, GameState<GM, ? extends GameResult> resultingGameState) {
searchTree.advanceTree(move, resultingGameState);
}

public void logMoveChoices(GameState<GM, ? extends GameResult> rootGameState) {
String evaluatingPlayerName = rootGameState.getNextPlayerName();
LOGGER.debug("Top level moves considered by the AIService from {}'s perspective:", evaluatingPlayerName);
SearchTreeIterator<GM,NR> iterator = searchTree.iterator();
while (iterator.hasNextChild()) {
iterator.advanceChildNode();
String moveString = rootGameState.getHumanReadableMoveString(iterator.getCurrentChildMove());
NR nodeResults = iterator.getCurrentChildIterator().getCurrentNodeResults();
LOGGER.debug("Move {} was visited in {} simulations and has score {}",
moveString,
nodeResults.getNumSimulations(),
nodeResults.getValue(evaluatingPlayerName));
}
}
}