Skip to content

Commit f8f53eb

Browse files
committed
AI can now use signets!
1 parent 6135274 commit f8f53eb

File tree

12 files changed

+16
-22
lines changed

12 files changed

+16
-22
lines changed

forge-ai/src/main/java/forge/ai/ManaPaymentService.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ public boolean payManaCost() {
578578
paymentList.add(ability);
579579
// Remove this multi-mana source from all other shard lists for this payment
580580
if (sourcesForShards != null) {
581-
for (ManaCostShard shard : sourcesForShards.keySet()) {
581+
for (ManaCostShard shard : new ArrayList<>(sourcesForShards.keySet())) {
582582
sourcesForShards.get(shard).removeIf(sa2 -> sa2.getHostCard() == manaSource);
583583
}
584584
}
@@ -1214,9 +1214,11 @@ public List<SpellAbility> getAIPlayableMana(Card c) {
12141214
// if a mana ability has a mana cost the AI will miscalculate
12151215
// if there is a parent ability the AI can't use it
12161216
final Cost cost = a.getPayCosts();
1217-
if (cost.hasManaCost() || (a.getApi() != ApiType.Mana && a.getApi() != ApiType.ManaReflected)) {
1218-
continue;
1219-
}
1217+
// Previously AI didn't know how to handle mana abilities with mana costs
1218+
// We're trying to fix that, so commenting this out for now
1219+
// if (cost.hasManaCost() || (a.getApi() != ApiType.Mana && a.getApi() != ApiType.ManaReflected)) {
1220+
// continue;
1221+
// }
12201222

12211223
if (a.getRestrictions() != null && a.getRestrictions().isInstantSpeed()) {
12221224
continue;

forge-gui-desktop/src/test/java/forge/ai/controller/AutoPaymentTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,17 @@ public void payWithSignets() {
124124
// AI doesn't know how to use Signets. So the score here is going to be bad
125125

126126
int score = sim.simulateSpellAbility(strix.getFirstSpellAbility()).value;
127-
AssertJUnit.assertFalse(score > 0);
128-
129-
// Once the AI learns how to use Signets, this test will pass
130-
// Uncomment below when the AI is fixed
127+
AssertJUnit.assertTrue(score > 0);
131128

132-
// Game simGame = sim.getSimulatedGameState();
133-
// Card strixBF = findCardWithName(simGame, strix.getName());
134-
// AssertJUnit.assertNotNull(strixBF);
135-
// AssertJUnit.assertEquals(ZoneType.Battlefield, strixBF.getZone().getZoneType());
129+
Game simGame = sim.getSimulatedGameState();
130+
Card strixBF = findCardWithName(simGame, strix.getName());
131+
AssertJUnit.assertNotNull(strixBF);
132+
AssertJUnit.assertEquals(ZoneType.Battlefield, strixBF.getZone().getZoneType());
133+
134+
Card signetBF = findCardWithName(simGame, signet.getName());
135+
Card islandBF = findCardWithName(simGame, island.getName());
136+
AssertJUnit.assertTrue(signetBF.isTapped());
137+
AssertJUnit.assertTrue(islandBF.isTapped());
136138
}
137139

138140
@Test

forge-gui/res/cardsfolder/a/azorius_signet.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ Name:Azorius Signet
22
ManaCost:2
33
Types:Artifact
44
A:AB$ Mana | Cost$ 1 T | Produced$ W U | SpellDescription$ Add {W}{U}.
5-
AI:RemoveDeck:All
65
Oracle:{1}, {T}: Add {W}{U}.

forge-gui/res/cardsfolder/b/boros_signet.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ Name:Boros Signet
22
ManaCost:2
33
Types:Artifact
44
A:AB$ Mana | Cost$ 1 T | Produced$ R W | SpellDescription$ Add {R}{W}.
5-
AI:RemoveDeck:All
65
Oracle:{1}, {T}: Add {R}{W}.

forge-gui/res/cardsfolder/d/dimir_signet.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ Name:Dimir Signet
22
ManaCost:2
33
Types:Artifact
44
A:AB$ Mana | Cost$ 1 T | Produced$ U B | SpellDescription$ Add {U}{B}.
5-
AI:RemoveDeck:All
65
Oracle:{1}, {T}: Add {U}{B}.

forge-gui/res/cardsfolder/g/golgari_signet.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ Name:Golgari Signet
22
ManaCost:2
33
Types:Artifact
44
A:AB$ Mana | Cost$ 1 T | Produced$ B G | SpellDescription$ Add {B}{G}.
5-
AI:RemoveDeck:All
65
Oracle:{1}, {T}: Add {B}{G}.

forge-gui/res/cardsfolder/g/gruul_signet.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ Name:Gruul Signet
22
ManaCost:2
33
Types:Artifact
44
A:AB$ Mana | Cost$ 1 T | Produced$ R G | SpellDescription$ Add {R}{G}.
5-
AI:RemoveDeck:All
65
Oracle:{1}, {T}: Add {R}{G}.

forge-gui/res/cardsfolder/i/izzet_signet.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ Name:Izzet Signet
22
ManaCost:2
33
Types:Artifact
44
A:AB$ Mana | Cost$ 1 T | Produced$ U R | SpellDescription$ Add {U}{R}.
5-
AI:RemoveDeck:All
65
Oracle:{1}, {T}: Add {U}{R}.

forge-gui/res/cardsfolder/o/orzhov_signet.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ Name:Orzhov Signet
22
ManaCost:2
33
Types:Artifact
44
A:AB$ Mana | Cost$ 1 T | Produced$ W B | SpellDescription$ Add {W}{B}.
5-
AI:RemoveDeck:All
65
Oracle:{1}, {T}: Add {W}{B}.

forge-gui/res/cardsfolder/r/rakdos_signet.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ Name:Rakdos Signet
22
ManaCost:2
33
Types:Artifact
44
A:AB$ Mana | Cost$ 1 T | Produced$ B R | SpellDescription$ Add {B}{R}.
5-
AI:RemoveDeck:All
65
Oracle:{1}, {T}: Add {B}{R}.

0 commit comments

Comments
 (0)