mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Allows running tests using a seeded RNG.
Running the same game twice now works! There may be issues I haven't found with certain AI behaviors around mechanics I didn't use in my tests. (cherry picked from commit 194b47c1ad61c8f1efb6bce8af2bb10d1fa8f6c3)
This commit is contained in:
@@ -2216,7 +2216,10 @@ public class ComputerUtil {
|
||||
}
|
||||
return ComputerUtilCard.getBestAI(list);
|
||||
} else {
|
||||
return Iterables.getFirst(votes.keySet(), null);
|
||||
// TODO: This is just picking randomly amongst already picked things. It should probably pick the worst instead.
|
||||
List<Object> a = Arrays.asList(votes.keySet().toArray());
|
||||
Collections.shuffle(a, MyRandom.getRandom());
|
||||
return a.get(0);
|
||||
}
|
||||
case "Protection":
|
||||
if (votes.isEmpty()) {
|
||||
|
||||
@@ -134,7 +134,8 @@ public class ComputerUtilMana {
|
||||
Collections.sort(orderedCards, new Comparator<Card>() {
|
||||
@Override
|
||||
public int compare(final Card card1, final Card card2) {
|
||||
return Integer.compare(manaCardMap.get(card1), manaCardMap.get(card2));
|
||||
int result = Integer.compare(manaCardMap.get(card1), manaCardMap.get(card2));
|
||||
return result != 0 ? result : Float.compare(card1.getTimestamp(), card2.getTimestamp());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -308,7 +309,7 @@ public class ComputerUtilMana {
|
||||
}
|
||||
|
||||
// select which abilities may be used for each shard
|
||||
Multimap<ManaCostShard, SpellAbility> sourcesForShards = ComputerUtilMana.groupAndOrderToPayShards(ai, manaAbilityMap, cost);
|
||||
ListMultimap<ManaCostShard, SpellAbility> sourcesForShards = ComputerUtilMana.groupAndOrderToPayShards(ai, manaAbilityMap, cost);
|
||||
|
||||
sortManaAbilities(sourcesForShards);
|
||||
|
||||
@@ -858,7 +859,6 @@ public class ComputerUtilMana {
|
||||
}
|
||||
|
||||
AiController aic = ((PlayerControllerAi)ai.getController()).getAi();
|
||||
int chanceToReserve = aic.getIntProperty(AiProps.RESERVE_MANA_FOR_MAIN2_CHANCE);
|
||||
|
||||
PhaseType curPhase = ai.getGame().getPhaseHandler().getPhase();
|
||||
|
||||
@@ -877,7 +877,8 @@ public class ComputerUtilMana {
|
||||
// obey mana reservations for Main 2; otherwise, obey mana reservations depending on the "chance to reserve"
|
||||
// AI profile variable.
|
||||
if (sa.getSVar("LowPriorityAI").equals("")) {
|
||||
if (chanceToReserve == 0 || MyRandom.getRandom().nextInt(100) >= chanceToReserve) {
|
||||
float chanceToReserve = aic.getFloatProperty(AiProps.RESERVE_MANA_FOR_MAIN2_CHANCE);
|
||||
if (MyRandom.getRandom().nextDouble() >= chanceToReserve) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1005,7 +1006,7 @@ public class ComputerUtilMana {
|
||||
* @return a boolean.
|
||||
*/
|
||||
private static String payMultipleMana(ManaCostBeingPaid testCost, String mana, final Player p) {
|
||||
List<String> unused = new ArrayList<>(4);
|
||||
List<String> unused = new ArrayList<String>(4);
|
||||
for (String manaPart : TextUtil.split(mana, ' ')) {
|
||||
if (StringUtils.isNumeric(manaPart)) {
|
||||
for (int i = Integer.parseInt(manaPart); i > 0; i--) {
|
||||
|
||||
Reference in New Issue
Block a user