mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -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());
|
node.setGameValue(game.getState().getValue());
|
||||||
SimulatedPlayer currentPlayer = (SimulatedPlayer) game.getPlayer(game.getPlayerList().get());
|
SimulatedPlayer currentPlayer = (SimulatedPlayer) game.getPlayer(game.getPlayerList().get());
|
||||||
|
logger.fine("simulating -- player " + currentPlayer.getName());
|
||||||
SimulationNode bestNode = null;
|
SimulationNode bestNode = null;
|
||||||
List<Ability> allActions = currentPlayer.simulatePriority(game, filter);
|
List<Ability> allActions = currentPlayer.simulatePriority(game, filter);
|
||||||
if (logger.isLoggable(Level.FINE))
|
if (logger.isLoggable(Level.FINE))
|
||||||
logger.fine("simulating -- adding " + allActions.size() + " children:" + allActions);
|
logger.fine("simulating -- adding " + allActions.size() + " children:" + allActions);
|
||||||
for (Ability action: allActions) {
|
for (Ability action: allActions) {
|
||||||
Game sim = game.copy();
|
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();
|
sim.applyEffects();
|
||||||
if (!sim.isGameOver() && action.isUsesStack()) {
|
if (!sim.isGameOver() && action.isUsesStack()) {
|
||||||
// only pass if the last action uses the stack
|
// only pass if the last action uses the stack
|
||||||
|
|
|
||||||
|
|
@ -230,13 +230,13 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
|
||||||
else {
|
else {
|
||||||
switch (game.getTurn().getStepType()) {
|
switch (game.getTurn().getStepType()) {
|
||||||
case PRECOMBAT_MAIN:
|
case PRECOMBAT_MAIN:
|
||||||
val = simulateCombat(game, node, depth-1, alpha, beta, false);
|
val = -simulateCombat(game, node, depth-1, alpha, beta, false);
|
||||||
break;
|
break;
|
||||||
case POSTCOMBAT_MAIN:
|
case POSTCOMBAT_MAIN:
|
||||||
val = simulateCounterAttack(game, node, depth-1, alpha, beta);
|
val = -simulateCounterAttack(game, node, depth-1, alpha, beta);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
val = GameStateEvaluator.evaluate(playerId, game);
|
val = -GameStateEvaluator.evaluate(playerId, game);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -59,7 +59,7 @@ public class SeaGateOracle extends CardImpl<SeaGateOracle> {
|
||||||
this.subtype.add("Human");
|
this.subtype.add("Human");
|
||||||
this.subtype.add("Wizard");
|
this.subtype.add("Wizard");
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
this.toughness = new MageInt(1);
|
this.toughness = new MageInt(3);
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SeaGateOracleEffect(), false));
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new SeaGateOracleEffect(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,11 @@
|
||||||
|
|
||||||
package mage.abilities.common;
|
package mage.abilities.common;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import mage.Constants.Zone;
|
import mage.Constants.Zone;
|
||||||
import mage.abilities.ActivatedAbilityImpl;
|
import mage.abilities.ActivatedAbilityImpl;
|
||||||
import mage.abilities.effects.common.PassEffect;
|
import mage.abilities.effects.common.PassEffect;
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -51,6 +53,11 @@ public class PassAbility extends ActivatedAbilityImpl<PassAbility> {
|
||||||
return new PassAbility(this);
|
return new PassAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canActivate(UUID playerId, Game game) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Pass";
|
return "Pass";
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,10 @@ public class PlayTargetWithoutPayingManaEffect extends OneShotEffect<PlayTargetW
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Card target = (Card) game.getObject(source.getFirstTarget());
|
Card target = (Card) game.getObject(source.getFirstTarget());
|
||||||
return controller.cast(target.getSpellAbility(), game, true);
|
if (controller != null && target != null) {
|
||||||
|
return controller.cast(target.getSpellAbility(), game, true);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue