Bug: AI Mana Payment with Energy (SOLVED)
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Bug: AI Mana Payment with Energy (SOLVED)
by luke » 10 Mar 2018, 19:03
Currently using 1.6.7. Also testing with commit 9a3bc52 from March 8.
I do a lot of command line simulations and see a ton of messages like this:
I only found one reference to this here, but there was no follow-up (sorry, it won't let me post full link):
/forum/viewtopic.php?f=26&t=21186&p=220749#p220749
I spent some time researching this and it appears to happen when the AI is using cards like Aether Hub or Servant of the Conduit and runs out of energy. For example, 5 Aether Hubs (testing ) with 1 energy counter will result in the above message if the AI attempts to play Glorybringer. It successfully taps and pays the first R, but fails on the second because there is no more energy to pay additional costs.
This in itself isn't a big deal, but the problem is that costs aren't refunded:
This bug can be reliably reproduced by creating a deck with 30 Aether Hubs and 30 Glorybringers and having them play each other.
I do a lot of command line simulations and see a ton of messages like this:
- Code: Select all
ComputerUtil : payManaCost() cost was not paid for Glorybringer. Didn't find what to pay for {R}
I only found one reference to this here, but there was no follow-up (sorry, it won't let me post full link):
/forum/viewtopic.php?f=26&t=21186&p=220749#p220749
I spent some time researching this and it appears to happen when the AI is using cards like Aether Hub or Servant of the Conduit and runs out of energy. For example, 5 Aether Hubs (testing ) with 1 energy counter will result in the above message if the AI attempts to play Glorybringer. It successfully taps and pays the first R, but fails on the second because there is no more energy to pay additional costs.
This in itself isn't a big deal, but the problem is that costs aren't refunded:
- The first Aether Hub is still tapped
- Energy counter is not refunded
- Glorybringer is in limbo somewhere -- it doesn't get put back in hand
This bug can be reliably reproduced by creating a deck with 30 Aether Hubs and 30 Glorybringers and having them play each other.
Last edited by luke on 12 Mar 2018, 19:21, edited 1 time in total.
- luke
- Posts: 3
- Joined: 10 Mar 2018, 18:31
- Has thanked: 0 time
- Been thanked: 0 time
Re: Bug: AI Mana Payment with Energy
by luke » 10 Mar 2018, 21:37
I'm not sure if this is the best solution, but I think I might have found a fix.
In ComputerUtilMana.payManaCost (line 359), initialize energy at the top of the method:
Edit: Reduced code slightly
In ComputerUtilMana.payManaCost (line 359), initialize energy at the top of the method:
- Code: Select all
int testEnergyPool = ai.getCounters(CounterType.ENERGY);
- Code: Select all
if (test) {//<-- existing line 460
// Check energy when testing
CostPayEnergy energyCost = saPayment.getPayCosts().getCostEnergy();
if(energyCost != null) {
testEnergyPool -= Integer.parseInt(energyCost.getAmount());
if(testEnergyPool < 0) {
// Can't pay energy cost
break;
}
}
Edit: Reduced code slightly
- luke
- Posts: 3
- Joined: 10 Mar 2018, 18:31
- Has thanked: 0 time
- Been thanked: 0 time
Re: Bug: AI Mana Payment with Energy
by friarsol » 11 Mar 2018, 02:02
Feel free to post a merge request on our Gitlab.luke wrote:I'm not sure if this is the best solution, but I think I might have found a fix.
In ComputerUtilMana.payManaCost (line 359), initialize energy at the top of the method:Then in the test block after line 460:
- Code: Select all
int testEnergyPool = ai.getCounters(CounterType.ENERGY);
Since making this change, I have yet to encounter the "cost was not paid" message.
- Code: Select all
if (test) {//<-- existing line 460
// Check energy when testing
CostPayEnergy energyCost = saPayment.getPayCosts().getCostEnergy();
if(energyCost != null) {
testEnergyPool -= Integer.parseInt(energyCost.getAmount());
if(testEnergyPool < 0) {
// Can't pay energy cost
break;
}
}
Edit: Reduced code slightly
https://git.cardforge.org/dashboard/activity
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Bug: AI Mana Payment with Energy (SOLVED)
by luke » 12 Mar 2018, 19:20
- luke
- Posts: 3
- Joined: 10 Mar 2018, 18:31
- Has thanked: 0 time
- Been thanked: 0 time
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 77 guests