private static final int PERMANENT_FACTOR = Config.evaluatorPermanentFactor;
private static final int CREATURE_FACTOR = Config.evaluatorCreatureFactor;
private static final int HAND_FACTOR = Config.evaluatorHandFactor;
public static int evaluate(UUID playerId, Game game) {
Player player = game.getPlayer(playerId);
Player opponent = game.getPlayer(game.getOpponents(playerId).iterator().next());
if (game.isGameOver()) {
if (player.hasLost() || opponent.hasWon())
return Integer.MIN_VALUE;
if (opponent.hasLost() || player.hasWon())
return Integer.MAX_VALUE;
}
int lifeScore = (player.getLife() - opponent.getLife()) * LIFE_FACTOR;
int permanentScore = 0;
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(playerId)) {
permanentScore += evaluatePermanent(permanent, game);
}
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(opponent.getId())) {
permanentScore -= evaluatePermanent(permanent, game);
}
permanentScore *= PERMANENT_FACTOR;
int handScore = 0;
handScore = 7 - opponent.getHand().size();
handScore += Math.min(7, player.getHand().size());
handScore *= HAND_FACTOR;
int score = lifeScore + permanentScore + handScore;
if (logger.isLoggable(Level.FINE))