mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
fixed AI - will now attack if opponent has no defenders
This commit is contained in:
parent
65c55e4e2a
commit
d6c30e3734
6 changed files with 17 additions and 6 deletions
|
|
@ -372,13 +372,14 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
|
|||
}
|
||||
node.setGameValue(game.getState().getValue());
|
||||
SimulatedPlayer currentPlayer = (SimulatedPlayer) game.getPlayer(game.getPlayerList().get());
|
||||
logger.fine("simulating -- player " + currentPlayer.getName());
|
||||
SimulationNode bestNode = null;
|
||||
List<Ability> allActions = currentPlayer.simulatePriority(game, filter);
|
||||
if (logger.isLoggable(Level.FINE))
|
||||
logger.fine("simulating -- adding " + allActions.size() + " children:" + allActions);
|
||||
for (Ability action: allActions) {
|
||||
Game sim = game.copy();
|
||||
if (sim.getPlayer(playerId).activateAbility((ActivatedAbility) action.copy(), sim)) {
|
||||
if (sim.getPlayer(currentPlayer.getId()).activateAbility((ActivatedAbility) action.copy(), sim)) {
|
||||
sim.applyEffects();
|
||||
if (!sim.isGameOver() && action.isUsesStack()) {
|
||||
// only pass if the last action uses the stack
|
||||
|
|
|
|||
|
|
@ -230,13 +230,13 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
|||
else {
|
||||
switch (game.getTurn().getStepType()) {
|
||||
case PRECOMBAT_MAIN:
|
||||
val = simulateCombat(game, node, depth-1, alpha, beta, false);
|
||||
val = -simulateCombat(game, node, depth-1, alpha, beta, false);
|
||||
break;
|
||||
case POSTCOMBAT_MAIN:
|
||||
val = simulateCounterAttack(game, node, depth-1, alpha, beta);
|
||||
val = -simulateCounterAttack(game, node, depth-1, alpha, beta);
|
||||
break;
|
||||
default:
|
||||
val = GameStateEvaluator.evaluate(playerId, game);
|
||||
val = -GameStateEvaluator.evaluate(playerId, game);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue