It is currently 29 Oct 2025, 00:49
   
Text Size

AI mana pool

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins

AI mana pool

Postby Sloth » 08 Jun 2011, 06:58

My next plan is to add a mana pool for the AI. I think we had the consensus to put it in the player class. I want to make the following simple functions:

addToManaPool
getManaPool
removeFromManaPool

I don't plan to revolutionize the mana paying AI, but the AI should use the mana in the pool before using its mana producers. Then, at least triggered mana abilities will be avaiable for the AI: Mana Drain, Braid of Fire, Gauntlet of Might, Priest of Gix, ...

I think this is a first step and easy to pull off. But since it has to grow into something more complex I would like to hear your opinions first.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: AI mana pool

Postby slapshot5 » 08 Jun 2011, 13:05

Will you still have a mana pool class, and will it still extend Card?

I'm guessing this won't change the way it's displayed at all, will it? Just that the AI will have a mana pool "card" in his battlefield.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: AI mana pool

Postby Sloth » 08 Jun 2011, 13:07

slapshot5 wrote:Will you still have a mana pool class, and will it still extend Card?

I'm guessing this won't change the way it's displayed at all, will it? Just that the AI will have a mana pool "card" in his battlefield.

-slapshot5
I don't plan to change anything for the human. The AI doesn't need a "card" as the mana pool. The pool will be invisible (until we can agree on a representation).
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: AI mana pool

Postby slapshot5 » 08 Jun 2011, 19:16

Would the human ever want to see the AI's mana pool?
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: AI mana pool

Postby juzamjedi » 08 Jun 2011, 19:29

It's unusual to care what is in the AI's mana pool. The typical decks where that matters are combo (ANT, Belcher, Mind's Desire, Dragonstorm, Prosbloom, and surely others I'm forgetting). At some point people will care about Mana Drain mana vs. their Spell Pierce / Daze. Overall I think it's not a big deal... I wouldn't expect AI to play combo decks, and for Mana Drain I could look at the spell I countered last turn.
juzamjedi
Tester
 
Posts: 575
Joined: 13 Nov 2008, 08:35
Has thanked: 6 times
Been thanked: 8 times

Re: AI mana pool

Postby Sloth » 08 Jun 2011, 19:39

I can imagine getting information on the AI (including content of mana pool) by mousing over the AI life.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: AI mana pool

Postby Sloth » 16 Jun 2011, 12:32

Now that the mana pool is there, I will improve AI mana ability handling step by step:

1. Using mana abilities with additional (non-mana) costs (Vivid Crag, Abandoned Outpost, Horizon Canopy, ...) - DONE (note that the AI will waste limited resources)

2. Using mana abilities with subabilities (Underground River, Pristine Talisman, Rainbow Vale, ...)

3. Using mana abilities that produce more than one mana (Sol Ring, ...)

4. ???

5. Profit
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: AI mana pool

Postby jeffwadsworth » 16 Jun 2011, 18:26

This is great news.
jeffwadsworth
Super Tester Elite
 
Posts: 1172
Joined: 20 Oct 2010, 04:47
Location: USA
Has thanked: 287 times
Been thanked: 70 times

Re: AI mana pool

Postby slapshot5 » 16 Jun 2011, 20:05

Can you look at making the compy not pay mana using lands it has animated? Might be tricky differentiating a land it has specifically animated using the AF vs. lands when they are all animated by a static animation (Kormus Bell, etc).

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: AI mana pool

Postby Sloth » 17 Jun 2011, 11:18

slapshot5 wrote:Can you look at making the compy not pay mana using lands it has animated? Might be tricky differentiating a land it has specifically animated using the AF vs. lands when they are all animated by a static animation (Kormus Bell, etc).

-slapshot5
I will look into this.


Step 2 has been made. There is a problem with lands producing more than 1 color, that can lead to inefficient mana usage (and can produce a bug with X costs). I'm working on it.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: AI mana pool

Postby Sloth » 18 Jun 2011, 11:54

Step 1 and 2 are now well supported with close to optimal AI decision making. I'm now trying to cleanup the code and I stumbled over determineLeftoverMana. This functions needs a lot of duplicate code and is prone to causing AI cost pay errors. Isn't it better to just iterate through the X starting at 0 and run canPlayCost with the complete cost until the first cost can't be paid?

If noone objects I will test to change this.

slapshot5 wrote:Can you look at making the compy not pay mana using lands it has animated? Might be tricky differentiating a land it has specifically animated using the AF vs. lands when they are all animated by a static animation (Kormus Bell, etc).

-slapshot5
This proves to be very tricky indeed. I improved this situation though, by restricting the usage of AF Animate to the Combat_Begin phase.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Create Player.getManaPool() ? Re: AI mana pool

Postby alexAG76 » 18 Jun 2011, 22:46

I need a method to fetch the ManaPool for a specific Player. Should I add a non-static getManaPool() method to Player or should I add a static one (*shudder*) to AllZone (as getManaPool(Player p) )? For the former, I can control the initialization when bootstrapping the game-state.

I need to make the code more species-agnostic for Minimax.

Sloth wrote: ...
3. Using mana abilities that produce more than one mana (Sol Ring, ...)
4. ???
5. Profit
:lol:I couldn't stop laughing for at least 30 seconds... Underpants Gnomes!
User avatar
alexAG76
Programmer
 
Posts: 23
Joined: 02 Nov 2010, 00:07
Has thanked: 1 time
Been thanked: 0 time

Re: Create Player.getManaPool() ? Re: AI mana pool

Postby slapshot5 » 19 Jun 2011, 01:08

alexAG76 wrote:I need a method to fetch the ManaPool for a specific Player. Should I add a non-static getManaPool() method to Player or should I add a static one (*shudder*) to AllZone (as getManaPool(Player p) )? For the former, I can control the initialization when bootstrapping the game-state.

I need to make the code more species-agnostic for Minimax.

Sloth wrote: ...
3. Using mana abilities that produce more than one mana (Sol Ring, ...)
4. ???
5. Profit
:lol:I couldn't stop laughing for at least 30 seconds... Underpants Gnomes!
Put it in Player. I think the mana pool access methods are going there eventually anyway.
-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: Create Player.getManaPool() ?

Postby alexAG76 » 19 Jun 2011, 02:38

slapshot5 wrote:Put [getManaPool()] in Player. I think the mana pool access methods are going there eventually anyway.
Done... but you won't see a commit-action for a good while. Patching won't work, either, because the patch to converge the game-state into a single class is, well, huge.

Thanks for the input, though.
User avatar
alexAG76
Programmer
 
Posts: 23
Joined: 02 Nov 2010, 00:07
Has thanked: 1 time
Been thanked: 0 time


Return to Developer's Corner

Who is online

Users browsing this forum: Bing [Bot] and 21 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 22 users online :: 1 registered, 0 hidden and 21 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: Bing [Bot] and 21 guests

Login Form