mirror of
https://github.com/correl/mage.git
synced 2025-03-30 17:00:10 -09:00
fixes and optimizations for monte carlo ai
This commit is contained in:
parent
a13bb9acf5
commit
2e21b7197b
5 changed files with 21 additions and 3 deletions
Mage/src/mage
abilities
game/permanent
players
|
@ -261,4 +261,5 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
|
|||
|
||||
public Map<ReplacementEffect, Ability> getReplacementEffects(Zone zone);
|
||||
public Map<Effect, Ability> getEffects(Game game, Zone zone, EffectType effectType);
|
||||
public String getValue();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
package mage.abilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -286,4 +287,17 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
return total;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
List<String> abilities = new ArrayList<String>();
|
||||
for (T ability: this) {
|
||||
abilities.add(ability.toString());
|
||||
}
|
||||
Collections.sort(abilities);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String s: abilities) {
|
||||
sb.append(s);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
this.zone = ability.zone;
|
||||
this.name = ability.name;
|
||||
this.usesStack = ability.usesStack;
|
||||
this.manaCosts = ability.manaCosts.copy();
|
||||
this.manaCosts = ability.manaCosts;
|
||||
this.manaCostsToPay = ability.manaCostsToPay.copy();
|
||||
this.costs = ability.costs.copy();
|
||||
this.optionalCosts = ability.optionalCosts.copy();
|
||||
|
|
|
@ -151,7 +151,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
StringBuilder sb = new StringBuilder(1024);
|
||||
sb.append(controllerId).append(name).append(tapped).append(damage);
|
||||
sb.append(subtype).append(supertype).append(power.getValue()).append(toughness.getValue());
|
||||
sb.append(abilities);
|
||||
sb.append(abilities.getValue());
|
||||
for (Counter counter: counters.values()) {
|
||||
sb.append(counter.getName()).append(counter.getCount());
|
||||
}
|
||||
|
|
|
@ -1224,12 +1224,15 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
playable.add(ability);
|
||||
}
|
||||
}
|
||||
// eliminate duplicate activated abilities
|
||||
Map<String, Ability> playableActivated = new HashMap<String, Ability>();
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(playerId)) {
|
||||
for (ActivatedAbility ability: permanent.getAbilities().getActivatedAbilities(Zone.BATTLEFIELD)) {
|
||||
if (canPlay(ability, available, game))
|
||||
playable.add(ability);
|
||||
playableActivated.put(ability.toString(), ability);
|
||||
}
|
||||
}
|
||||
playable.addAll(playableActivated.values());
|
||||
return playable;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue