mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
- Moved evaluateBoardState to ComputerUtil from ComputerUtilCard
This commit is contained in:
@@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
import forge.card.ability.SpellAbilityAi;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
import forge.game.player.Player;
|
||||
|
||||
public class ChoosePlayerAi extends SpellAbilityAi {
|
||||
@@ -50,7 +50,7 @@ public class ChoosePlayerAi extends SpellAbilityAi {
|
||||
List<Player> prefChoices = choices;
|
||||
prefChoices.removeAll(ai.getOpponents());
|
||||
if (!prefChoices.isEmpty()) {
|
||||
chosen = ComputerUtilCard.evaluateBoardPosition(prefChoices);
|
||||
chosen = ComputerUtil.evaluateBoardPosition(prefChoices);
|
||||
}
|
||||
if (chosen == null) {
|
||||
System.out.println("No good curse choices. Picking first available: " + choices.get(0));
|
||||
|
||||
@@ -1685,4 +1685,40 @@ public class ComputerUtil {
|
||||
|| type == CounterType.PARALYZATION || type == CounterType.SHELL || type == CounterType.SLEEP
|
||||
|| type == CounterType.SLEIGHT || (type == CounterType.TIME && !c.isInPlay()) || type == CounterType.WAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* evaluateBoardPosition.
|
||||
* </p>
|
||||
*
|
||||
* @param listToEvaluate
|
||||
* a list of players to evaluate.
|
||||
* @return a Player.
|
||||
*/
|
||||
public static Player evaluateBoardPosition(final List<Player> listToEvaluate) {
|
||||
Player bestBoardPosition = listToEvaluate.get(0);
|
||||
int bestBoardRating = 0;
|
||||
|
||||
for (final Player p : listToEvaluate) {
|
||||
int pRating = p.getLife() * 3;
|
||||
pRating += p.getLandsInPlay().size() * 2;
|
||||
|
||||
for (final Card c : p.getCardsIn(ZoneType.Battlefield)) {
|
||||
pRating += ComputerUtilCard.evaluateCreature(c) / 3;
|
||||
}
|
||||
|
||||
if (p.getCardsIn(ZoneType.Library).size() < 3) {
|
||||
pRating /= 5;
|
||||
}
|
||||
|
||||
System.out.println("Board position evaluation for " + p + ": " + pRating);
|
||||
|
||||
if (pRating > bestBoardRating) {
|
||||
bestBoardRating = pRating;
|
||||
bestBoardPosition = p;
|
||||
}
|
||||
}
|
||||
|
||||
return bestBoardPosition;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
@@ -822,40 +821,4 @@ public class ComputerUtilCard {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* evaluateBoardPosition.
|
||||
* </p>
|
||||
*
|
||||
* @param listToEvaluate
|
||||
* a list of players to evaluate.
|
||||
* @return a Player.
|
||||
*/
|
||||
public static Player evaluateBoardPosition(final List<Player> listToEvaluate) {
|
||||
Player bestBoardPosition = listToEvaluate.get(0);
|
||||
int bestBoardRating = 0;
|
||||
|
||||
for (final Player p : listToEvaluate) {
|
||||
int pRating = p.getLife() * 3;
|
||||
pRating += p.getLandsInPlay().size() * 2;
|
||||
|
||||
for (final Card c : p.getCardsIn(ZoneType.Battlefield)) {
|
||||
pRating += ComputerUtilCard.evaluateCreature(c) / 3;
|
||||
}
|
||||
|
||||
if (p.getCardsIn(ZoneType.Library).size() < 3) {
|
||||
pRating /= 5;
|
||||
}
|
||||
|
||||
System.out.println("Board position evaluation for " + p + ": " + pRating);
|
||||
|
||||
if (pRating > bestBoardRating) {
|
||||
bestBoardRating = pRating;
|
||||
bestBoardPosition = p;
|
||||
}
|
||||
}
|
||||
|
||||
return bestBoardPosition;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user