mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
[ai-ma] renamed classes (otherwise classloader uses another classes), added additional logging.
This commit is contained in:
parent
f7ffbb4773
commit
f36254445a
13 changed files with 166 additions and 157 deletions
|
@ -4,4 +4,4 @@ evaluatorLifeFactor=2
|
|||
evaluatorPermanentFactor=1
|
||||
evaluatorCreatureFactor=1
|
||||
evaluatorHandFactor=1
|
||||
maxThinkSeconds=30
|
||||
maxThinkSeconds=10
|
|
@ -37,7 +37,7 @@ import mage.game.permanent.Permanent;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Attackers extends TreeMap<Integer, List<Permanent>> {
|
||||
public class Attackers2 extends TreeMap<Integer, List<Permanent>> {
|
||||
|
||||
public List<Permanent> getAttackers() {
|
||||
List<Permanent> attackers = new ArrayList<Permanent>();
|
|
@ -96,12 +96,12 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
protected List<String> choices = new ArrayList<String>();
|
||||
protected Combat combat;
|
||||
protected int currentScore;
|
||||
protected SimulationNode root;
|
||||
protected SimulationNode2 root;
|
||||
|
||||
public ComputerPlayer4(String name, RangeOfInfluence range) {
|
||||
super(name, range);
|
||||
maxDepth = Config.maxDepth;
|
||||
maxNodes = Config.maxNodes;
|
||||
maxDepth = Config2.maxDepth;
|
||||
maxNodes = Config2.maxNodes;
|
||||
}
|
||||
|
||||
public ComputerPlayer4(final ComputerPlayer4 player) {
|
||||
|
@ -172,12 +172,12 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
}
|
||||
|
||||
protected void calculateActions(Game game) {
|
||||
currentScore = GameStateEvaluator.evaluate(playerId, game);
|
||||
currentScore = GameStateEvaluator2.evaluate(playerId, game);
|
||||
if (!getNextAction(game)) {
|
||||
Game sim = createSimulation(game);
|
||||
SimulationNode.resetCount();
|
||||
root = new SimulationNode(sim, maxDepth, playerId);
|
||||
logger.fine("simulating actions");
|
||||
SimulationNode2.resetCount();
|
||||
root = new SimulationNode2(sim, maxDepth, playerId);
|
||||
logger.info("simulating actions");
|
||||
addActionsTimed(new FilterAbility());
|
||||
if (root.children.size() > 0) {
|
||||
root = root.children.get(0);
|
||||
|
@ -189,15 +189,15 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
|
||||
protected boolean getNextAction(Game game) {
|
||||
if (root != null && root.children.size() > 0) {
|
||||
SimulationNode test = root;
|
||||
SimulationNode2 test = root;
|
||||
root = root.children.get(0);
|
||||
while (root.children.size() > 0 && !root.playerId.equals(playerId)) {
|
||||
test = root;
|
||||
root = root.children.get(0);
|
||||
}
|
||||
logger.fine("simlating -- game value:" + game.getState().getValue() + " test value:" + test.gameValue);
|
||||
logger.info("simlating -- game value:" + game.getState().getValue() + " test value:" + test.gameValue);
|
||||
if (root.playerId.equals(playerId) && root.abilities != null && game.getState().getValue() == test.gameValue) {
|
||||
logger.fine("simulating -- continuing previous action chain");
|
||||
logger.info("simulating -- continuing previous action chain");
|
||||
actions = new LinkedList<Ability>(root.abilities);
|
||||
combat = root.combat;
|
||||
return true;
|
||||
|
@ -209,16 +209,16 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
return false;
|
||||
}
|
||||
|
||||
protected int minimaxAB(SimulationNode node, FilterAbility filter, int depth, int alpha, int beta) {
|
||||
protected int minimaxAB(SimulationNode2 node, FilterAbility filter, int depth, int alpha, int beta) {
|
||||
UUID currentPlayerId = node.getGame().getPlayerList().get();
|
||||
SimulationNode bestChild = null;
|
||||
for (SimulationNode child: node.getChildren()) {
|
||||
SimulationNode2 bestChild = null;
|
||||
for (SimulationNode2 child: node.getChildren()) {
|
||||
if (alpha >= beta) {
|
||||
logger.fine("alpha beta pruning");
|
||||
logger.info("alpha beta pruning");
|
||||
break;
|
||||
}
|
||||
if (SimulationNode.nodeCount > maxNodes) {
|
||||
logger.fine("simulating -- reached end-state");
|
||||
if (SimulationNode2.nodeCount > maxNodes) {
|
||||
logger.info("simulating -- reached end-state, count=" + SimulationNode2.nodeCount);
|
||||
break;
|
||||
}
|
||||
int val = addActions(child, filter, depth-1, alpha, beta);
|
||||
|
@ -243,11 +243,11 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
if (bestChild != null)
|
||||
node.children.add(bestChild);
|
||||
if (!currentPlayerId.equals(playerId)) {
|
||||
logger.fine("returning minimax beta: " + beta);
|
||||
logger.info("returning minimax beta: " + beta);
|
||||
return beta;
|
||||
}
|
||||
else {
|
||||
logger.fine("returning minimax alpha: " + alpha);
|
||||
logger.info("returning minimax alpha: " + alpha);
|
||||
return alpha;
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
return null;
|
||||
}
|
||||
|
||||
protected void resolve(SimulationNode node, int depth, Game game) {
|
||||
protected void resolve(SimulationNode2 node, int depth, Game game) {
|
||||
StackObject ability = game.getStack().pop();
|
||||
if (ability instanceof StackAbility) {
|
||||
SearchEffect effect = getSearchEffect((StackAbility) ability);
|
||||
|
@ -274,16 +274,16 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
SearchEffect newEffect = getSearchEffect((StackAbility) newAbility);
|
||||
newEffect.getTarget().addTarget(targetId, newAbility, sim);
|
||||
sim.getStack().push(newAbility);
|
||||
SimulationNode newNode = new SimulationNode(sim, depth, ability.getControllerId());
|
||||
SimulationNode2 newNode = new SimulationNode2(sim, depth, ability.getControllerId());
|
||||
node.children.add(newNode);
|
||||
newNode.getTargets().add(targetId);
|
||||
logger.fine("simulating search -- node#: " + SimulationNode.getCount() + "for player: " + sim.getPlayer(ability.getControllerId()).getName());
|
||||
logger.fine("simulating search -- node#: " + SimulationNode2.getCount() + "for player: " + sim.getPlayer(ability.getControllerId()).getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.fine("simulating resolve ");
|
||||
//logger.info("simulating resolve ");
|
||||
ability.resolve(game);
|
||||
game.applyEffects();
|
||||
game.getPlayers().resetPassed();
|
||||
|
@ -299,9 +299,9 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
});
|
||||
pool.execute(task);
|
||||
try {
|
||||
task.get(Config.maxThinkSeconds, TimeUnit.SECONDS);
|
||||
task.get(Config2.maxThinkSeconds, TimeUnit.SECONDS);
|
||||
} catch (TimeoutException e) {
|
||||
logger.fine("simulating - timed out");
|
||||
logger.info("simulating - timed out");
|
||||
task.cancel(true);
|
||||
} catch (ExecutionException e) {
|
||||
|
||||
|
@ -310,25 +310,26 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
}
|
||||
}
|
||||
|
||||
protected int addActions(SimulationNode node, FilterAbility filter, int depth, int alpha, int beta) {
|
||||
protected int addActions(SimulationNode2 node, FilterAbility filter, int depth, int alpha, int beta) {
|
||||
logger.info("addActions: " + depth + ", alpha=" + alpha + ", beta=" + beta);
|
||||
Game game = node.getGame();
|
||||
int val;
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
logger.fine("interrupted");
|
||||
return GameStateEvaluator.evaluate(playerId, game);
|
||||
logger.info("interrupted");
|
||||
return GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
if (depth <= 0 || SimulationNode.nodeCount > maxNodes || game.isGameOver()) {
|
||||
logger.fine("simulating -- reached end state");
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
if (depth <= 0 || SimulationNode2.nodeCount > maxNodes || game.isGameOver()) {
|
||||
logger.info("simulating -- reached end state, node count="+ SimulationNode2.nodeCount + ", depth="+depth);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
else if (node.getChildren().size() > 0) {
|
||||
logger.fine("simulating -- somthing added children:" + node.getChildren().size());
|
||||
logger.info("simulating -- somthing added children:" + node.getChildren().size());
|
||||
val = minimaxAB(node, filter, depth-1, alpha, beta);
|
||||
}
|
||||
else {
|
||||
if (logger.isLoggable(Level.FINE))
|
||||
logger.fine("simulating -- alpha: " + alpha + " beta: " + beta + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + (node.getPlayerId().equals(playerId)?"yes":"no"));
|
||||
logger.info("simulating -- alpha: " + alpha + " beta: " + beta + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + (node.getPlayerId().equals(playerId)?"yes":"no"));
|
||||
if (allPassed(game)) {
|
||||
if (!game.getStack().isEmpty()) {
|
||||
resolve(node, depth, game);
|
||||
|
@ -337,7 +338,7 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
// int testScore = GameStateEvaluator.evaluate(playerId, game);
|
||||
// if (testScore < currentScore) {
|
||||
// // if score at end of step is worse than original score don't check any further
|
||||
// logger.fine("simulating -- abandoning current check, no immediate benefit");
|
||||
// logger.info("simulating -- abandoning current check, no immediate benefit");
|
||||
// return testScore;
|
||||
// }
|
||||
game.getPlayers().resetPassed();
|
||||
|
@ -346,12 +347,13 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
}
|
||||
|
||||
if (game.isGameOver()) {
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
else if (node.getChildren().size() > 0) {
|
||||
throw new RuntimeException("This shouldn't happen.");
|
||||
//declared attackers or blockers or triggered abilities
|
||||
logger.fine("simulating -- attack/block/trigger added children:" + node.getChildren().size());
|
||||
val = minimaxAB(node, filter, depth-1, alpha, beta);
|
||||
///logger.info("simulating -- attack/block/trigger added children:" + node.getChildren().size());
|
||||
///val = minimaxAB(node, filter, depth-1, alpha, beta);
|
||||
}
|
||||
else {
|
||||
val = simulatePriority(node, game, filter, depth, alpha, beta);
|
||||
|
@ -359,24 +361,24 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
}
|
||||
|
||||
if (logger.isLoggable(Level.FINE))
|
||||
logger.fine("returning -- score: " + val + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + game.getPlayer(node.getPlayerId()).getName());
|
||||
logger.info("returning -- score: " + val + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + game.getPlayer(node.getPlayerId()).getName());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
protected int simulatePriority(SimulationNode node, Game game, FilterAbility filter, int depth, int alpha, int beta) {
|
||||
protected int simulatePriority(SimulationNode2 node, Game game, FilterAbility filter, int depth, int alpha, int beta) {
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
logger.fine("interrupted");
|
||||
return GameStateEvaluator.evaluate(playerId, game);
|
||||
logger.info("interrupted");
|
||||
return GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
node.setGameValue(game.getState().getValue());
|
||||
SimulatedPlayer currentPlayer = (SimulatedPlayer) game.getPlayer(game.getPlayerList().get());
|
||||
logger.fine("simulating -- player " + currentPlayer.getName());
|
||||
SimulationNode bestNode = null;
|
||||
SimulatedPlayer2 currentPlayer = (SimulatedPlayer2) game.getPlayer(game.getPlayerList().get());
|
||||
//logger.info("simulating -- player " + currentPlayer.getName());
|
||||
SimulationNode2 bestNode = null;
|
||||
List<Ability> allActions = currentPlayer.simulatePriority(game, filter);
|
||||
if (logger.isLoggable(Level.FINE))
|
||||
logger.fine("simulating -- adding " + allActions.size() + " children:" + allActions);
|
||||
logger.info("simulating -- adding " + allActions.size() + " children:" + allActions);
|
||||
for (Ability action: allActions) {
|
||||
Game sim = game.copy();
|
||||
if (sim.getPlayer(currentPlayer.getId()).activateAbility((ActivatedAbility) action.copy(), sim)) {
|
||||
|
@ -386,9 +388,9 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
sim.getPlayer(currentPlayer.getId()).pass();
|
||||
sim.getPlayerList().getNext();
|
||||
}
|
||||
SimulationNode newNode = new SimulationNode(sim, action, depth, currentPlayer.getId());
|
||||
SimulationNode2 newNode = new SimulationNode2(sim, action, depth, currentPlayer.getId());
|
||||
if (logger.isLoggable(Level.FINE))
|
||||
logger.fine("simulating -- node #:" + SimulationNode.getCount() + " actions:" + action);
|
||||
logger.info("simulating -- node #:" + SimulationNode2.getCount() + " actions:" + action);
|
||||
sim.checkStateAndTriggered();
|
||||
int val = addActions(newNode, filter, depth-1, alpha, beta);
|
||||
if (!currentPlayer.getId().equals(playerId)) {
|
||||
|
@ -410,11 +412,11 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
}
|
||||
}
|
||||
if (alpha >= beta) {
|
||||
logger.fine("simulating -- pruning");
|
||||
//logger.info("simulating -- pruning");
|
||||
break;
|
||||
}
|
||||
if (SimulationNode.nodeCount > maxNodes) {
|
||||
logger.fine("simulating -- reached end-state");
|
||||
if (SimulationNode2.nodeCount > maxNodes) {
|
||||
logger.info("simulating -- reached end-state");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -424,11 +426,11 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
node.children.add(bestNode);
|
||||
}
|
||||
if (!currentPlayer.getId().equals(playerId)) {
|
||||
logger.fine("returning priority beta: " + beta);
|
||||
//logger.info("returning priority beta: " + beta);
|
||||
return beta;
|
||||
}
|
||||
else {
|
||||
logger.fine("returning priority alpha: " + alpha);
|
||||
//logger.info("returning priority alpha: " + alpha);
|
||||
return alpha;
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +494,7 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
return true;
|
||||
}
|
||||
|
||||
public void playNext(Game game, UUID activePlayerId, SimulationNode node) {
|
||||
public void playNext(Game game, UUID activePlayerId, SimulationNode2 node) {
|
||||
boolean skip = false;
|
||||
while (true) {
|
||||
Phase currentPhase = game.getPhase();
|
||||
|
@ -552,7 +554,7 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
if (game.getTurn().getStepType() == PhaseStep.DECLARE_ATTACKERS) {
|
||||
game.fireEvent(new GameEvent(GameEvent.EventType.DECLARE_ATTACKERS_STEP_PRE, null, null, activePlayerId));
|
||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS, activePlayerId, activePlayerId))) {
|
||||
for (Combat engagement: ((SimulatedPlayer)game.getPlayer(activePlayerId)).addAttackers(game)) {
|
||||
for (Combat engagement: ((SimulatedPlayer2)game.getPlayer(activePlayerId)).addAttackers(game)) {
|
||||
Game sim = game.copy();
|
||||
UUID defenderId = game.getOpponents(playerId).iterator().next();
|
||||
for (CombatGroup group: engagement.getGroups()) {
|
||||
|
@ -561,8 +563,8 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
}
|
||||
}
|
||||
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, playerId, playerId));
|
||||
SimulationNode newNode = new SimulationNode(sim, node.getDepth()-1, activePlayerId);
|
||||
logger.fine("simulating -- node #:" + SimulationNode.getCount() + " declare attakers");
|
||||
SimulationNode2 newNode = new SimulationNode2(sim, node.getDepth()-1, activePlayerId);
|
||||
logger.info("simulating -- node #:" + SimulationNode2.getCount() + " declare attakers");
|
||||
newNode.setCombat(sim.getCombat());
|
||||
node.children.add(newNode);
|
||||
}
|
||||
|
@ -574,7 +576,7 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
for (UUID defenderId: game.getCombat().getDefenders()) {
|
||||
//check if defender is being attacked
|
||||
if (game.getCombat().isAttacked(defenderId, game)) {
|
||||
for (Combat engagement: ((SimulatedPlayer)game.getPlayer(defenderId)).addBlockers(game)) {
|
||||
for (Combat engagement: ((SimulatedPlayer2)game.getPlayer(defenderId)).addBlockers(game)) {
|
||||
Game sim = game.copy();
|
||||
for (CombatGroup group: engagement.getGroups()) {
|
||||
for (UUID blockerId: group.getBlockers()) {
|
||||
|
@ -582,8 +584,8 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
}
|
||||
}
|
||||
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, playerId, playerId));
|
||||
SimulationNode newNode = new SimulationNode(sim, node.getDepth()-1, defenderId);
|
||||
logger.fine("simulating -- node #:" + SimulationNode.getCount() + " declare blockers");
|
||||
SimulationNode2 newNode = new SimulationNode2(sim, node.getDepth()-1, defenderId);
|
||||
logger.info("simulating -- node #:" + SimulationNode2.getCount() + " declare blockers");
|
||||
newNode.setCombat(sim.getCombat());
|
||||
node.children.add(newNode);
|
||||
}
|
||||
|
@ -606,10 +608,11 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
|
||||
@Override
|
||||
public void selectAttackers(Game game) {
|
||||
logger.fine("selectAttackers");
|
||||
logger.info("selectAttackers");
|
||||
if (combat != null) {
|
||||
UUID opponentId = game.getCombat().getDefenders().iterator().next();
|
||||
for (UUID attackerId: combat.getAttackers()) {
|
||||
logger.info("declare attacker: " + game.getCard(attackerId).getName());
|
||||
this.declareAttacker(attackerId, opponentId, game);
|
||||
}
|
||||
}
|
||||
|
@ -617,7 +620,7 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
|
||||
@Override
|
||||
public void selectBlockers(Game game) {
|
||||
logger.fine("selectBlockers");
|
||||
logger.info("selectBlockers");
|
||||
if (combat != null && combat.getGroups().size() > 0) {
|
||||
List<CombatGroup> groups = game.getCombat().getGroups();
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
|
@ -641,7 +644,7 @@ public class ComputerPlayer4 extends ComputerPlayer<ComputerPlayer4> implements
|
|||
|
||||
for (Player copyPlayer: sim.getState().getPlayers().values()) {
|
||||
Player origPlayer = game.getState().getPlayers().get(copyPlayer.getId());
|
||||
SimulatedPlayer newPlayer = new SimulatedPlayer(copyPlayer.getId(), copyPlayer.getId().equals(playerId));
|
||||
SimulatedPlayer2 newPlayer = new SimulatedPlayer2(copyPlayer.getId(), copyPlayer.getId().equals(playerId));
|
||||
newPlayer.restore(origPlayer);
|
||||
sim.getState().getPlayers().put(copyPlayer.getId(), newPlayer);
|
||||
}
|
||||
|
|
|
@ -37,11 +37,13 @@ import mage.Constants.PhaseStep;
|
|||
import mage.Constants.RangeOfInfluence;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.filter.FilterAbility;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.turn.BeginCombatStep;
|
||||
import mage.game.turn.BeginningPhase;
|
||||
import mage.game.turn.CleanupStep;
|
||||
|
@ -80,12 +82,13 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
filterNotLand.setZone(Zone.HAND);
|
||||
filterNotLand.setNotFilter(true);
|
||||
|
||||
logger.setLevel(Level.ALL);
|
||||
}
|
||||
|
||||
public ComputerPlayer5(String name, RangeOfInfluence range) {
|
||||
super(name, range);
|
||||
maxDepth = Config.maxDepth;
|
||||
maxNodes = Config.maxNodes;
|
||||
maxDepth = Config2.maxDepth;
|
||||
maxNodes = Config2.maxNodes;
|
||||
}
|
||||
|
||||
public ComputerPlayer5(final ComputerPlayer5 player) {
|
||||
|
@ -108,7 +111,22 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
break;
|
||||
case PRECOMBAT_MAIN:
|
||||
if (game.getActivePlayerId().equals(playerId)) {
|
||||
System.out.println("["+ game.getPlayer(playerId).getName() + "] Precombat Main, life=" + game.getPlayer(playerId).getLife());
|
||||
Player player = game.getPlayer(playerId);
|
||||
System.out.println("[" + game.getPlayer(playerId).getName() + "] Precombat Main, life=" + player.getLife());
|
||||
String s = "[";
|
||||
for (Card card : player.getHand().getCards(game)) {
|
||||
s += card.getName() + ";";
|
||||
}
|
||||
s += "]";
|
||||
System.out.println("Hand: " + s);
|
||||
s = "[";
|
||||
for (Permanent permanent : game.getBattlefield().getAllPermanents()) {
|
||||
if (permanent.getOwnerId().equals(player.getId())) {
|
||||
s += permanent.getName() + ";";
|
||||
}
|
||||
}
|
||||
s += "]";
|
||||
System.out.println("Permanents: " + s);
|
||||
if (actions.size() == 0) {
|
||||
calculatePreCombatActions(game);
|
||||
}
|
||||
|
@ -154,10 +172,10 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
|
||||
protected void calculatePreCombatActions(Game game) {
|
||||
if (!getNextAction(game)) {
|
||||
currentScore = GameStateEvaluator.evaluate(playerId, game);
|
||||
currentScore = GameStateEvaluator2.evaluate(playerId, game);
|
||||
Game sim = createSimulation(game);
|
||||
SimulationNode.resetCount();
|
||||
root = new SimulationNode(sim, maxDepth, playerId);
|
||||
SimulationNode2.resetCount();
|
||||
root = new SimulationNode2(sim, maxDepth, playerId);
|
||||
logger.fine("simulating pre combat actions -----------------------------------------------------------------------------------------");
|
||||
|
||||
addActionsTimed(new FilterAbility());
|
||||
|
@ -171,10 +189,10 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
|
||||
protected void calculatePostCombatActions(Game game) {
|
||||
if (!getNextAction(game)) {
|
||||
currentScore = GameStateEvaluator.evaluate(playerId, game);
|
||||
currentScore = GameStateEvaluator2.evaluate(playerId, game);
|
||||
Game sim = createSimulation(game);
|
||||
SimulationNode.resetCount();
|
||||
root = new SimulationNode(sim, maxDepth, playerId);
|
||||
SimulationNode2.resetCount();
|
||||
root = new SimulationNode2(sim, maxDepth, playerId);
|
||||
logger.fine("simulating post combat actions ----------------------------------------------------------------------------------------");
|
||||
addActionsTimed(new FilterAbility());
|
||||
if (root.children.size() > 0) {
|
||||
|
@ -186,18 +204,18 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected int addActions(SimulationNode node, FilterAbility filter, int depth, int alpha, int beta) {
|
||||
protected int addActions(SimulationNode2 node, FilterAbility filter, int depth, int alpha, int beta) {
|
||||
boolean stepFinished = false;
|
||||
int val;
|
||||
Game game = node.getGame();
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
logger.fine("interrupted");
|
||||
return GameStateEvaluator.evaluate(playerId, game);
|
||||
return GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
if (depth <= 0 || SimulationNode.nodeCount > maxNodes || game.isGameOver()) {
|
||||
if (depth <= 0 || SimulationNode2.nodeCount > maxNodes || game.isGameOver()) {
|
||||
logger.fine("simulating -- reached end state");
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
else if (node.getChildren().size() > 0) {
|
||||
logger.fine("simulating -- somthing added children:" + node.getChildren().size());
|
||||
|
@ -216,11 +234,11 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
}
|
||||
|
||||
if (game.isGameOver()) {
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
else if (stepFinished) {
|
||||
logger.fine("step finished");
|
||||
int testScore = GameStateEvaluator.evaluate(playerId, game);
|
||||
int testScore = GameStateEvaluator2.evaluate(playerId, game);
|
||||
if (game.getActivePlayerId().equals(playerId)) {
|
||||
if (testScore < currentScore) {
|
||||
// if score at end of step is worse than original score don't check further
|
||||
|
@ -236,7 +254,7 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
val = -simulateCounterAttack(game, node, depth-1, alpha, beta);
|
||||
break;
|
||||
default:
|
||||
val = -GameStateEvaluator.evaluate(playerId, game);
|
||||
val = -GameStateEvaluator2.evaluate(playerId, game);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +263,7 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
if (game.getTurn().getStepType() == PhaseStep.DECLARE_ATTACKERS)
|
||||
val = simulateBlockers(game, node, playerId, depth-1, alpha, beta, true);
|
||||
else
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
}
|
||||
else if (node.getChildren().size() > 0) {
|
||||
|
@ -263,12 +281,12 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
|
||||
}
|
||||
|
||||
protected int simulateCombat(Game game, SimulationNode node, int depth, int alpha, int beta, boolean counter) {
|
||||
protected int simulateCombat(Game game, SimulationNode2 node, int depth, int alpha, int beta, boolean counter) {
|
||||
Integer val = null;
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
logger.fine("interrupted");
|
||||
return GameStateEvaluator.evaluate(playerId, game);
|
||||
return GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
if (game.getTurn().getStepType() != PhaseStep.DECLARE_BLOCKERS) {
|
||||
game.getTurn().setPhase(new CombatPhase());
|
||||
|
@ -297,31 +315,31 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
}
|
||||
else if (!counter) {
|
||||
finishCombat(game);
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
// val = simulateCounterAttack(game, node, depth, alpha, beta);
|
||||
}
|
||||
}
|
||||
if (val == null)
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
if (logger.isLoggable(Level.FINE))
|
||||
logger.fine("returning -- combat score: " + val + " depth:" + depth + " for player:" + game.getPlayer(node.getPlayerId()).getName());
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
protected int simulateAttackers(Game game, SimulationNode node, UUID attackerId, int depth, int alpha, int beta, boolean counter) {
|
||||
protected int simulateAttackers(Game game, SimulationNode2 node, UUID attackerId, int depth, int alpha, int beta, boolean counter) {
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
logger.fine("interrupted");
|
||||
return GameStateEvaluator.evaluate(playerId, game);
|
||||
return GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
Integer val = null;
|
||||
SimulationNode bestNode = null;
|
||||
SimulatedPlayer attacker = (SimulatedPlayer) game.getPlayer(attackerId);
|
||||
SimulationNode2 bestNode = null;
|
||||
SimulatedPlayer2 attacker = (SimulatedPlayer2) game.getPlayer(attackerId);
|
||||
|
||||
for (Combat engagement: attacker.addAttackers(game)) {
|
||||
if (alpha >= beta) {
|
||||
logger.fine("simulating -- pruning attackers");
|
||||
//logger.fine("simulating -- pruning attackers");
|
||||
break;
|
||||
}
|
||||
Game sim = game.copy();
|
||||
|
@ -332,9 +350,9 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
}
|
||||
}
|
||||
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, playerId, playerId));
|
||||
SimulationNode newNode = new SimulationNode(sim, depth, game.getActivePlayerId());
|
||||
SimulationNode2 newNode = new SimulationNode2(sim, depth, game.getActivePlayerId());
|
||||
if (logger.isLoggable(Level.FINE))
|
||||
logger.fine("simulating attack -- node#: " + SimulationNode.getCount());
|
||||
logger.fine("simulating attack -- node#: " + SimulationNode2.getCount());
|
||||
sim.checkStateAndTriggered();
|
||||
while (!sim.getStack().isEmpty()) {
|
||||
sim.getStack().resolve(sim);
|
||||
|
@ -361,7 +379,7 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
}
|
||||
}
|
||||
if (val == null)
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
if (bestNode != null) {
|
||||
node.children.clear();
|
||||
node.children.add(bestNode);
|
||||
|
@ -371,17 +389,17 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
return val;
|
||||
}
|
||||
|
||||
protected int simulateBlockers(Game game, SimulationNode node, UUID defenderId, int depth, int alpha, int beta, boolean counter) {
|
||||
protected int simulateBlockers(Game game, SimulationNode2 node, UUID defenderId, int depth, int alpha, int beta, boolean counter) {
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
logger.fine("interrupted");
|
||||
return GameStateEvaluator.evaluate(playerId, game);
|
||||
return GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
Integer val = null;
|
||||
SimulationNode bestNode = null;
|
||||
SimulationNode2 bestNode = null;
|
||||
//check if defender is being attacked
|
||||
if (game.getCombat().isAttacked(defenderId, game)) {
|
||||
SimulatedPlayer defender = (SimulatedPlayer) game.getPlayer(defenderId);
|
||||
SimulatedPlayer2 defender = (SimulatedPlayer2) game.getPlayer(defenderId);
|
||||
for (Combat engagement: defender.addBlockers(game)) {
|
||||
if (alpha >= beta) {
|
||||
logger.fine("simulating -- pruning blockers");
|
||||
|
@ -395,9 +413,9 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
}
|
||||
}
|
||||
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, playerId, playerId));
|
||||
SimulationNode newNode = new SimulationNode(sim, depth, defenderId);
|
||||
SimulationNode2 newNode = new SimulationNode2(sim, depth, defenderId);
|
||||
if (logger.isLoggable(Level.FINE))
|
||||
logger.fine("simulating block -- node#: " + SimulationNode.getCount());
|
||||
logger.fine("simulating block -- node#: " + SimulationNode2.getCount());
|
||||
sim.checkStateAndTriggered();
|
||||
while (!sim.getStack().isEmpty()) {
|
||||
sim.getStack().resolve(sim);
|
||||
|
@ -408,13 +426,13 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
Combat simCombat = sim.getCombat().copy();
|
||||
finishCombat(sim);
|
||||
if (sim.isGameOver()) {
|
||||
val = GameStateEvaluator.evaluate(playerId, sim);
|
||||
val = GameStateEvaluator2.evaluate(playerId, sim);
|
||||
}
|
||||
else if (!counter) {
|
||||
val = simulatePostCombatMain(sim, newNode, depth-1, alpha, beta);
|
||||
}
|
||||
else
|
||||
val = GameStateEvaluator.evaluate(playerId, sim);
|
||||
val = GameStateEvaluator2.evaluate(playerId, sim);
|
||||
if (!defenderId.equals(playerId)) {
|
||||
if (val < beta) {
|
||||
beta = val;
|
||||
|
@ -432,7 +450,7 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
}
|
||||
}
|
||||
if (val == null)
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
if (bestNode != null) {
|
||||
node.children.clear();
|
||||
node.children.add(bestNode);
|
||||
|
@ -442,11 +460,11 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
return val;
|
||||
}
|
||||
|
||||
protected int simulateCounterAttack(Game game, SimulationNode node, int depth, int alpha, int beta) {
|
||||
protected int simulateCounterAttack(Game game, SimulationNode2 node, int depth, int alpha, int beta) {
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
logger.fine("interrupted");
|
||||
return GameStateEvaluator.evaluate(playerId, game);
|
||||
return GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
Integer val = null;
|
||||
if (!game.isGameOver()) {
|
||||
|
@ -465,7 +483,7 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
logger.fine("returning -- counter attack score: " + val + " depth:" + depth + " for player:" + game.getPlayer(node.getPlayerId()).getName());
|
||||
}
|
||||
if (val == null)
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = GameStateEvaluator2.evaluate(playerId, game);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -500,11 +518,11 @@ public class ComputerPlayer5 extends ComputerPlayer4 implements Player {
|
|||
simulateStep(game, new EndOfCombatStep());
|
||||
}
|
||||
|
||||
protected int simulatePostCombatMain(Game game, SimulationNode node, int depth, int alpha, int beta) {
|
||||
protected int simulatePostCombatMain(Game game, SimulationNode2 node, int depth, int alpha, int beta) {
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
logger.fine("interrupted");
|
||||
return GameStateEvaluator.evaluate(playerId, game);
|
||||
return GameStateEvaluator2.evaluate(playerId, game);
|
||||
}
|
||||
logger.fine("simulating -- post combat main");
|
||||
game.getTurn().setPhase(new PostCombatMainPhase());
|
||||
|
|
|
@ -41,9 +41,9 @@ import mage.util.Logging;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Config {
|
||||
public class Config2 {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(Config.class.getName());
|
||||
private final static Logger logger = Logging.getLogger(Config2.class.getName());
|
||||
|
||||
public static final int maxDepth;
|
||||
public static final int maxNodes;
|
||||
|
@ -56,12 +56,12 @@ public class Config {
|
|||
static {
|
||||
Properties p = new Properties();
|
||||
try {
|
||||
File file = new File(Config.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||
File file = new File(Config2.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||
p.load(new FileInputStream(new File(file.getParent() + File.separator + "AIMinimax.properties")));
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
} catch (URISyntaxException ex) {
|
||||
Logger.getLogger(Config.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(Config2.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
maxDepth = Integer.parseInt(p.getProperty("maxDepth"));
|
||||
maxNodes = Integer.parseInt(p.getProperty("maxNodes"));
|
|
@ -8,13 +8,7 @@ package mage.player.ai;
|
|||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.keyword.DoubleStrikeAbility;
|
||||
import mage.abilities.keyword.FirstStrikeAbility;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.player.ai.ma.ArtificialScoringSystem;
|
||||
|
@ -28,9 +22,9 @@ import mage.util.Logging;
|
|||
* this evaluator is only good for two player games
|
||||
*
|
||||
*/
|
||||
public class GameStateEvaluator {
|
||||
public class GameStateEvaluator2 {
|
||||
|
||||
private final static transient Logger logger = Logging.getLogger(GameStateEvaluator.class.getName());
|
||||
private final static transient Logger logger = Logging.getLogger(GameStateEvaluator2.class.getName());
|
||||
|
||||
static {
|
||||
logger.setLevel(Level.ALL);
|
||||
|
@ -40,10 +34,10 @@ public class GameStateEvaluator {
|
|||
public static final int LOSE_GAME_SCORE = -WIN_GAME_SCORE;
|
||||
|
||||
|
||||
private static final int LIFE_FACTOR = Config.evaluatorLifeFactor;
|
||||
private static final int PERMANENT_FACTOR = Config.evaluatorPermanentFactor;
|
||||
private static final int CREATURE_FACTOR = Config.evaluatorCreatureFactor;
|
||||
private static final int HAND_FACTOR = Config.evaluatorHandFactor;
|
||||
private static final int LIFE_FACTOR = Config2.evaluatorLifeFactor;
|
||||
private static final int PERMANENT_FACTOR = Config2.evaluatorPermanentFactor;
|
||||
private static final int CREATURE_FACTOR = Config2.evaluatorCreatureFactor;
|
||||
private static final int HAND_FACTOR = Config2.evaluatorHandFactor;
|
||||
|
||||
public static int evaluate(UUID playerId, Game game) {
|
||||
Player player = game.getPlayer(playerId);
|
|
@ -38,14 +38,14 @@ import mage.util.Logging;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SimulateBlockWorker implements Callable {
|
||||
public class SimulateBlockWorker2 implements Callable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(SimulationWorker.class.getName());
|
||||
private final static Logger logger = Logging.getLogger(SimulationWorker2.class.getName());
|
||||
|
||||
private SimulationNode node;
|
||||
private SimulationNode2 node;
|
||||
private ComputerPlayer5 player;
|
||||
|
||||
public SimulateBlockWorker(ComputerPlayer5 player, SimulationNode node) {
|
||||
public SimulateBlockWorker2(ComputerPlayer5 player, SimulationNode2 node) {
|
||||
this.player = player;
|
||||
this.node = node;
|
||||
}
|
|
@ -36,12 +36,12 @@ import mage.game.Game;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SimulatedAction {
|
||||
public class SimulatedAction2 {
|
||||
|
||||
private Game game;
|
||||
private List<Ability> abilities;
|
||||
|
||||
public SimulatedAction(Game game, List<Ability> abilities) {
|
||||
public SimulatedAction2(Game game, List<Ability> abilities) {
|
||||
this.game = game;
|
||||
this.abilities = abilities;
|
||||
}
|
|
@ -31,18 +31,13 @@ package mage.player.ai;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.common.PassAbility;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
|
@ -54,28 +49,27 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.StackAbility;
|
||||
import mage.target.Target;
|
||||
import mage.util.Copier;
|
||||
import mage.util.Logging;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SimulatedPlayer extends ComputerPlayer<SimulatedPlayer> {
|
||||
public class SimulatedPlayer2 extends ComputerPlayer<SimulatedPlayer2> {
|
||||
|
||||
private final static transient Logger logger = Logging.getLogger(SimulatedPlayer.class.getName());
|
||||
private final static transient Logger logger = Logging.getLogger(SimulatedPlayer2.class.getName());
|
||||
private boolean isSimulatedPlayer;
|
||||
private FilterAbility filter;
|
||||
private transient ConcurrentLinkedQueue<Ability> allActions;
|
||||
private static PassAbility pass = new PassAbility();
|
||||
|
||||
public SimulatedPlayer(UUID id, boolean isSimulatedPlayer) {
|
||||
public SimulatedPlayer2(UUID id, boolean isSimulatedPlayer) {
|
||||
super(id);
|
||||
pass.setControllerId(playerId);
|
||||
this.isSimulatedPlayer = isSimulatedPlayer;
|
||||
}
|
||||
|
||||
public SimulatedPlayer(final SimulatedPlayer player) {
|
||||
public SimulatedPlayer2(final SimulatedPlayer2 player) {
|
||||
super(player);
|
||||
this.isSimulatedPlayer = player.isSimulatedPlayer;
|
||||
if (player.filter != null)
|
||||
|
@ -83,8 +77,8 @@ public class SimulatedPlayer extends ComputerPlayer<SimulatedPlayer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SimulatedPlayer copy() {
|
||||
return new SimulatedPlayer(this);
|
||||
public SimulatedPlayer2 copy() {
|
||||
return new SimulatedPlayer2(this);
|
||||
}
|
||||
|
||||
public List<Ability> simulatePriority(Game game, FilterAbility filter) {
|
||||
|
@ -213,7 +207,7 @@ public class SimulatedPlayer extends ComputerPlayer<SimulatedPlayer> {
|
|||
game.getPlayers().resetPassed();
|
||||
}
|
||||
else {
|
||||
SimulationNode parent = (SimulationNode) game.getCustomData();
|
||||
SimulationNode2 parent = (SimulationNode2) game.getCustomData();
|
||||
int depth = parent.getDepth() - 1;
|
||||
if (depth == 0) return true;
|
||||
logger.fine("simulating -- triggered ability - adding children:" + options.size());
|
||||
|
@ -224,13 +218,13 @@ public class SimulatedPlayer extends ComputerPlayer<SimulatedPlayer> {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected void addAbilityNode(SimulationNode parent, Ability ability, int depth, Game game) {
|
||||
protected void addAbilityNode(SimulationNode2 parent, Ability ability, int depth, Game game) {
|
||||
Game sim = game.copy();
|
||||
sim.getStack().push(new StackAbility(ability, playerId));
|
||||
ability.activate(sim, false);
|
||||
sim.applyEffects();
|
||||
SimulationNode newNode = new SimulationNode(sim, depth, playerId);
|
||||
logger.fine("simulating -- node #:" + SimulationNode.getCount() + " triggered ability option");
|
||||
SimulationNode2 newNode = new SimulationNode2(sim, depth, playerId);
|
||||
logger.fine("simulating -- node #:" + SimulationNode2.getCount() + " triggered ability option");
|
||||
for (Target target: ability.getTargets()) {
|
||||
for (UUID targetId: target.getTargets()) {
|
||||
newNode.getTargets().add(targetId);
|
|
@ -40,7 +40,7 @@ import mage.game.combat.Combat;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SimulationNode implements Serializable {
|
||||
public class SimulationNode2 implements Serializable {
|
||||
|
||||
protected static int nodeCount;
|
||||
|
||||
|
@ -48,13 +48,13 @@ public class SimulationNode implements Serializable {
|
|||
protected int gameValue;
|
||||
protected List<Ability> abilities;
|
||||
protected int depth;
|
||||
protected List<SimulationNode> children = new ArrayList<SimulationNode>();
|
||||
protected List<SimulationNode2> children = new ArrayList<SimulationNode2>();
|
||||
protected List<UUID> targets = new ArrayList<UUID>();
|
||||
protected List<String> choices = new ArrayList<String>();
|
||||
protected UUID playerId;
|
||||
protected Combat combat;
|
||||
|
||||
public SimulationNode(Game game, int depth, UUID playerId) {
|
||||
public SimulationNode2(Game game, int depth, UUID playerId) {
|
||||
this.game = game;
|
||||
this.depth = depth;
|
||||
this.playerId = playerId;
|
||||
|
@ -62,12 +62,12 @@ public class SimulationNode implements Serializable {
|
|||
nodeCount++;
|
||||
}
|
||||
|
||||
public SimulationNode(Game game, List<Ability> abilities, int depth, UUID playerId) {
|
||||
public SimulationNode2(Game game, List<Ability> abilities, int depth, UUID playerId) {
|
||||
this(game, depth, playerId);
|
||||
this.abilities = abilities;
|
||||
}
|
||||
|
||||
public SimulationNode(Game game, Ability ability, int depth, UUID playerId) {
|
||||
public SimulationNode2(Game game, Ability ability, int depth, UUID playerId) {
|
||||
this(game, depth, playerId);
|
||||
this.abilities = new ArrayList<Ability>();
|
||||
abilities.add(ability);
|
||||
|
@ -97,7 +97,7 @@ public class SimulationNode implements Serializable {
|
|||
return this.abilities;
|
||||
}
|
||||
|
||||
public List<SimulationNode> getChildren() {
|
||||
public List<SimulationNode2> getChildren() {
|
||||
return this.children;
|
||||
}
|
||||
|
|
@ -39,16 +39,16 @@ import mage.util.Logging;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SimulationWorker implements Callable {
|
||||
public class SimulationWorker2 implements Callable {
|
||||
|
||||
private final static Logger logger = Logging.getLogger(SimulationWorker.class.getName());
|
||||
private final static Logger logger = Logging.getLogger(SimulationWorker2.class.getName());
|
||||
|
||||
private Game game;
|
||||
private SimulatedAction previousActions;
|
||||
private SimulatedAction2 previousActions;
|
||||
private Ability action;
|
||||
private SimulatedPlayer player;
|
||||
private SimulatedPlayer2 player;
|
||||
|
||||
public SimulationWorker(Game game, SimulatedPlayer player, SimulatedAction previousActions, Ability action) {
|
||||
public SimulationWorker2(Game game, SimulatedPlayer2 player, SimulatedAction2 previousActions, Ability action) {
|
||||
this.game = game;
|
||||
this.player = player;
|
||||
this.previousActions = previousActions;
|
|
@ -1,5 +1,5 @@
|
|||
# Default global logging level.
|
||||
.level=FINER
|
||||
.level=ALL
|
||||
|
||||
# Set the default logging level for new ConsoleHandler instances
|
||||
java.util.logging.ConsoleHandler.level = ALL
|
Binary file not shown.
Loading…
Reference in a new issue