use of mage.constants.PhaseStep in project mage by magefree.
the class ComputerPlayerMCTS method calculateThinkTime.
// try to ensure that there are at least THINK_MIN_RATIO simulations per node at all times
private int calculateThinkTime(Game game, NextAction action) {
int thinkTime;
int nodeSizeRatio = 0;
if (root.getNumChildren() > 0)
nodeSizeRatio = root.getVisits() / root.getNumChildren();
// logger.info("Ratio: " + nodeSizeRatio);
PhaseStep curStep = game.getStep().getType();
if (action == NextAction.SELECT_ATTACKERS || action == NextAction.SELECT_BLOCKERS) {
if (nodeSizeRatio < THINK_MIN_RATIO) {
thinkTime = maxThinkTime;
} else if (nodeSizeRatio >= THINK_MAX_RATIO) {
thinkTime = 0;
} else {
thinkTime = maxThinkTime / 2;
}
} else if (game.isActivePlayer(playerId) && (curStep == PhaseStep.PRECOMBAT_MAIN || curStep == PhaseStep.POSTCOMBAT_MAIN) && game.getStack().isEmpty()) {
if (nodeSizeRatio < THINK_MIN_RATIO) {
thinkTime = maxThinkTime;
} else if (nodeSizeRatio >= THINK_MAX_RATIO) {
thinkTime = 0;
} else {
thinkTime = maxThinkTime / 2;
}
} else {
if (nodeSizeRatio < THINK_MIN_RATIO) {
thinkTime = maxThinkTime / 2;
} else {
thinkTime = 0;
}
}
return thinkTime;
}
Aggregations