mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
another AI fix
This commit is contained in:
parent
580dfadbef
commit
85e1f68554
4 changed files with 11 additions and 9 deletions
|
@ -160,6 +160,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
||||||
logger.debug("simulating pre combat actions -----------------------------------------------------------------------------------------");
|
logger.debug("simulating pre combat actions -----------------------------------------------------------------------------------------");
|
||||||
|
|
||||||
addActionsTimed(new FilterAbility());
|
addActionsTimed(new FilterAbility());
|
||||||
|
// addActions(root, new FilterAbility(), maxDepth, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||||
if (root.children.size() > 0) {
|
if (root.children.size() > 0) {
|
||||||
root = root.children.get(0);
|
root = root.children.get(0);
|
||||||
actions = new LinkedList<Ability>(root.abilities);
|
actions = new LinkedList<Ability>(root.abilities);
|
||||||
|
@ -176,6 +177,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
||||||
root = new SimulationNode(null, sim, maxDepth, playerId);
|
root = new SimulationNode(null, sim, maxDepth, playerId);
|
||||||
logger.debug("simulating post combat actions ----------------------------------------------------------------------------------------");
|
logger.debug("simulating post combat actions ----------------------------------------------------------------------------------------");
|
||||||
addActionsTimed(new FilterAbility());
|
addActionsTimed(new FilterAbility());
|
||||||
|
// addActions(root, new FilterAbility(), maxDepth, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||||
if (root.children.size() > 0) {
|
if (root.children.size() > 0) {
|
||||||
root = root.children.get(0);
|
root = root.children.get(0);
|
||||||
actions = new LinkedList<Ability>(root.abilities);
|
actions = new LinkedList<Ability>(root.abilities);
|
||||||
|
@ -296,8 +298,8 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
||||||
}
|
}
|
||||||
else if (!counter) {
|
else if (!counter) {
|
||||||
finishCombat(game);
|
finishCombat(game);
|
||||||
val = GameStateEvaluator.evaluate(playerId, game);
|
// val = GameStateEvaluator.evaluate(playerId, game);
|
||||||
// val = simulateCounterAttack(game, node, depth, alpha, beta);
|
val = simulateCounterAttack(game, node, depth, alpha, beta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (val == null)
|
if (val == null)
|
||||||
|
@ -326,16 +328,16 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Game sim = game.copy();
|
Game sim = game.copy();
|
||||||
UUID defenderId = game.getOpponents(playerId).iterator().next();
|
UUID defenderId = game.getOpponents(attackerId).iterator().next();
|
||||||
for (CombatGroup group: engagement.getGroups()) {
|
for (CombatGroup group: engagement.getGroups()) {
|
||||||
for (UUID attackId: group.getAttackers()) {
|
for (UUID attackId: group.getAttackers()) {
|
||||||
sim.getPlayer(attackerId).declareAttacker(attackId, defenderId, sim);
|
sim.getPlayer(attackerId).declareAttacker(attackId, defenderId, sim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, playerId, playerId));
|
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, attackerId, attackerId));
|
||||||
SimulationNode newNode = new SimulationNode(node, sim, depth, attackerId);
|
SimulationNode newNode = new SimulationNode(node, sim, depth, attackerId);
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("simulating attack for player:" + game.getPlayer(newNode.getPlayerId()).getName());
|
logger.debug("simulating attack for player:" + game.getPlayer(attackerId).getName());
|
||||||
sim.checkStateAndTriggered();
|
sim.checkStateAndTriggered();
|
||||||
while (!sim.getStack().isEmpty()) {
|
while (!sim.getStack().isEmpty()) {
|
||||||
sim.getStack().resolve(sim);
|
sim.getStack().resolve(sim);
|
||||||
|
@ -399,10 +401,10 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, playerId, playerId));
|
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, defenderId, defenderId));
|
||||||
SimulationNode newNode = new SimulationNode(node, sim, depth, defenderId);
|
SimulationNode newNode = new SimulationNode(node, sim, depth, defenderId);
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("simulating block for player:" + game.getPlayer(newNode.getPlayerId()).getName());
|
logger.debug("simulating block for player:" + game.getPlayer(defenderId).getName());
|
||||||
sim.checkStateAndTriggered();
|
sim.checkStateAndTriggered();
|
||||||
while (!sim.getStack().isEmpty()) {
|
while (!sim.getStack().isEmpty()) {
|
||||||
sim.getStack().resolve(sim);
|
sim.getStack().resolve(sim);
|
||||||
|
@ -455,9 +457,9 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
||||||
}
|
}
|
||||||
Integer val = null;
|
Integer val = null;
|
||||||
if (!game.isGameOver()) {
|
if (!game.isGameOver()) {
|
||||||
logger.debug("simulating -- counter attack");
|
|
||||||
simulateToEnd(game);
|
simulateToEnd(game);
|
||||||
game.getState().setActivePlayerId(game.getState().getPlayerList(game.getActivePlayerId()).getNext());
|
game.getState().setActivePlayerId(game.getState().getPlayerList(game.getActivePlayerId()).getNext());
|
||||||
|
logger.debug("simulating -- counter attack for player " + game.getPlayer(game.getActivePlayerId()).getName());
|
||||||
game.getTurn().setPhase(new BeginningPhase());
|
game.getTurn().setPhase(new BeginningPhase());
|
||||||
if (game.getPhase().beginPhase(game, game.getActivePlayerId())) {
|
if (game.getPhase().beginPhase(game, game.getActivePlayerId())) {
|
||||||
simulateStep(game, new UntapStep());
|
simulateStep(game, new UntapStep());
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class GameStateEvaluator {
|
||||||
|
|
||||||
int score = lifeScore + permanentScore + handScore;
|
int score = lifeScore + permanentScore + handScore;
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("game state evaluated to- lifeScore:" + lifeScore + " permanentScore:" + permanentScore + " handScore:" + handScore + " total:" + score);
|
logger.debug("game state for player " + player.getName() + " evaluated to- lifeScore:" + lifeScore + " permanentScore:" + permanentScore + " handScore:" + handScore + " total:" + score);
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue