Skip to content

Commit

Permalink
Clean up (#6722)
Browse files Browse the repository at this point in the history
  • Loading branch information
tool4ever authored Dec 26, 2024
1 parent 9b6203b commit 672a913
Show file tree
Hide file tree
Showing 12 changed files with 247 additions and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;
import java.util.Map;

public class AIDeckStatistics {
public class AiDeckStatistics {

public float averageCMC = 0;
// TODO implement this. Use a numerically stable algorithm from
Expand All @@ -24,9 +24,9 @@ public class AIDeckStatistics {

// in WUBRGC order from ManaCost.getColorShardCounts()
public int[] maxPips = null;
// public int[] numSources = new int[6];
// public int[] numSources = new int[6];
public int numLands = 0;
public AIDeckStatistics(float averageCMC, float stddevCMC, int maxCost, int maxColoredCost, int[] maxPips, int numLands) {
public AiDeckStatistics(float averageCMC, float stddevCMC, int maxCost, int maxColoredCost, int[] maxPips, int numLands) {
this.averageCMC = averageCMC;
this.stddevCMC = stddevCMC;
this.maxCost = maxCost;
Expand All @@ -35,7 +35,7 @@ public AIDeckStatistics(float averageCMC, float stddevCMC, int maxCost, int maxC
this.numLands = numLands;
}

public static AIDeckStatistics fromCards(List<Card> cards) {
public static AiDeckStatistics fromCards(List<Card> cards) {
int totalCMC = 0;
int totalCount = 0;
int numLands = 0;
Expand Down Expand Up @@ -75,7 +75,7 @@ public static AIDeckStatistics fromCards(List<Card> cards) {

}

return new AIDeckStatistics(totalCount == 0 ? 0 : totalCMC / (float)totalCount,
return new AiDeckStatistics(totalCount == 0 ? 0 : totalCMC / (float)totalCount,
0, // TODO use https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
maxCost,
maxColoredCost,
Expand All @@ -85,7 +85,7 @@ public static AIDeckStatistics fromCards(List<Card> cards) {
}


public static AIDeckStatistics fromDeck(Deck deck, Player player) {
public static AiDeckStatistics fromDeck(Deck deck, Player player) {
List<Card> cardlist = new ArrayList<>();
for (final Map.Entry<DeckSection, CardPool> deckEntry : deck) {
switch (deckEntry.getKey()) {
Expand All @@ -104,7 +104,7 @@ public static AIDeckStatistics fromDeck(Deck deck, Player player) {
return fromCards(cardlist);
}

public static AIDeckStatistics fromPlayer(Player player) {
public static AiDeckStatistics fromPlayer(Player player) {
Deck deck = player.getRegisteredPlayer().getDeck();
if (deck.isEmpty()) {
// we're in a test or some weird match, search through the hand and library and build the decklist
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package forge.ai.simulation;

import forge.ai.AIDeckStatistics;
import forge.ai.AiDeckStatistics;
import forge.ai.CreatureEvaluator;
import forge.card.mana.ManaAtom;
import forge.game.Game;
Expand Down Expand Up @@ -133,7 +133,7 @@ private Score getScoreForGameStateImpl(Game game, Player aiPlayer) {
score -= 2* opponentLife / (game.getPlayers().size() - 1);

// evaluate mana base quality
score += evalManaBase(game, aiPlayer, AIDeckStatistics.fromPlayer(aiPlayer));
score += evalManaBase(game, aiPlayer, AiDeckStatistics.fromPlayer(aiPlayer));
// TODO deal with opponents. Do we want to use perfect information to evaluate their manabase?
//int opponentManaScore = 0;
//for (Player opponent : aiPlayer.getOpponents()) {
Expand Down Expand Up @@ -173,7 +173,7 @@ private Score getScoreForGameStateImpl(Game game, Player aiPlayer) {
return new Score(score, summonSickScore);
}

public int evalManaBase(Game game, Player player, AIDeckStatistics statistics) {
public int evalManaBase(Game game, Player player, AiDeckStatistics statistics) {
// TODO should these be fixed quantities or should they be linear out of like 1000/(desired - total)?
int value = 0;
// get the colors of mana we can produce and the maximum number of pips
Expand Down
14 changes: 6 additions & 8 deletions forge-game/src/main/java/forge/game/card/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
private Map<Long, CardCollection> mustBlockCards = Maps.newHashMap();
private List<Card> blockedThisTurn = Lists.newArrayList();
private List<Card> blockedByThisTurn = Lists.newArrayList();
private Map<Player, CardCollection> chosenMap = Maps.newHashMap();

private CardCollection untilLeavesBattlefield = new CardCollection();

Expand All @@ -113,8 +112,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr

private GameEntity entityAttachedTo;

private Map<StaticAbility, CardPlayOption> mayPlay = Maps.newHashMap();

// changes by AF animate and continuous static effects

protected CardChangedType changedTypeByText; // Layer 3 by Text Change
Expand Down Expand Up @@ -160,6 +157,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr

private final Table<Long, Long, Map<String, String>> changedSVars = TreeBasedTable.create();

private Map<StaticAbility, CardPlayOption> mayPlay = Maps.newHashMap();

private final Map<Long, PlayerCollection> mayLook = Maps.newHashMap();
private final PlayerCollection mayLookFaceDownExile = new PlayerCollection();
private final PlayerCollection mayLookTemp = new PlayerCollection();
Expand Down Expand Up @@ -200,9 +199,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
private boolean unearthed;
private boolean ringbearer;
private boolean monstrous;

private boolean renowned;
private boolean solved = false;
private boolean solved;
private Long suspectedTimestamp = null;
private StaticAbility suspectedStatic = null;

Expand Down Expand Up @@ -304,6 +302,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
private String currentRoom = null;
private String sector = null;
private String chosenSector = null;
private Map<Player, CardCollection> chosenMap = Maps.newHashMap();

// points to the host that exiled this card, usually the one that has this object it its exiledCards field
// however it could also be a different card which isn't an error but means the exiling SA was gained
Expand Down Expand Up @@ -331,6 +330,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
// breaking when the LKI object is changed to a different card state.
private int lkiCMC = -1;

private CombatLki combatLKI;

private CardRules cardRules;
private final CardView view;

Expand All @@ -353,8 +354,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars, ITr
private final Table<SpellAbility, StaticAbility, List<String>> chosenModesYourCombatStatic = HashBasedTable.create();
private final Table<SpellAbility, StaticAbility, List<String>> chosenModesYourLastCombatStatic = HashBasedTable.create();

private CombatLki combatLKI;

private ReplacementEffect shieldCounterReplaceDamage = null;
private ReplacementEffect shieldCounterReplaceDestroy = null;
private ReplacementEffect stunCounterReplaceUntap = null;
Expand Down Expand Up @@ -8235,6 +8234,5 @@ public void copyFrom(Card in) {

this.changedCardNames.putAll(in.changedCardNames);
setChangedCardTraits(in.getChangedCardTraits());

}
}
18 changes: 8 additions & 10 deletions forge-game/src/main/java/forge/game/card/CardState.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ public void setFunctionalVariantName(String functionalVariantName) {
view.setFunctionalVariantName(functionalVariantName);
}


public final int getBasePower() {
return basePower;
}
Expand Down Expand Up @@ -263,7 +262,6 @@ public final void setBaseDefense(final String string) {
public Set<Integer> getAttractionLights() {
return this.attractionLights;
}

public final void setAttractionLights(Set<Integer> attractionLights) {
this.attractionLights = attractionLights;
view.updateAttractionLights(this);
Expand Down Expand Up @@ -492,14 +490,6 @@ public final void clearStaticAbilities() {
staticAbilities.clear();
}

public final String getImageKey() {
return imageKey;
}
public final void setImageKey(final String imageFilename0) {
imageKey = imageFilename0;
view.updateImageKey(this);
}

public FCollectionView<ReplacementEffect> getReplacementEffects() {
FCollection<ReplacementEffect> result = new FCollection<>(replacementEffects);
CardTypeView type = getTypeWithChanges();
Expand Down Expand Up @@ -752,6 +742,14 @@ public void setSetCode(String setCode0) {
view.updateSetCode(this);
}

public final String getImageKey() {
return imageKey;
}
public final void setImageKey(final String imageFilename0) {
imageKey = imageFilename0;
view.updateImageKey(this);
}

/* (non-Javadoc)
* @see forge.game.GameObject#hasProperty(java.lang.String, forge.game.player.Player, forge.game.card.Card, forge.game.spellability.SpellAbility)
*/
Expand Down
Loading

0 comments on commit 672a913

Please sign in to comment.