Getting started - hello
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
40 posts
• Page 2 of 3 • 1, 2, 3
Re: Getting started - hello
by mcrawford620 » 26 Jun 2012, 21:18
Hmm, I see what you mean. I had done a similar test, and the computer did not cast Timely Reinforcements when it would not get an advantage. But maybe my test wasn't controlled enough. -- Edit, I see now there's a small random element in the AI's decisions, that's probably why it didn't play the card in my first tests.
I didn't know that I can run a less-than-7-card deck in developer mode, so that's a good tip for testing. I remember trying, and the AI lost on the first turn, but that must have been before I knew about developer mode.
I didn't know that I can run a less-than-7-card deck in developer mode, so that's a good tip for testing. I remember trying, and the AI lost on the first turn, but that must have been before I knew about developer mode.
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Getting started - hello
by mcrawford620 » 27 Jun 2012, 00:04
OK, what I'm trying for a fix is to put a check into AbilityFactoryAlterLife that checks the conditions on the SpellAbility. If it doesn't pass (i.e., the conditions would not be met if the AI casts this spell), then the AI doesn't use it.
Then since this card has a sub-ability that might still be useful, I do another check on the sub-ability's conditions to see if that one would succeed. I added another new SVar "AIPlayForSub:True" that needs to be there if the AI wants to play the card for the sub-ability, even if the main ability would not succeed. Basically I saw that there were about 1000 sub-abilities in other cards, and I didn't want the AI trying something that didn't make sense.
Then since this card has a sub-ability that might still be useful, I do another check on the sub-ability's conditions to see if that one would succeed. I added another new SVar "AIPlayForSub:True" that needs to be there if the AI wants to play the card for the sub-ability, even if the main ability would not succeed. Basically I saw that there were about 1000 sub-abilities in other cards, and I didn't want the AI trying something that didn't make sense.
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Getting started - hello
by ArsenalNut » 27 Jun 2012, 12:59
I tried the test I suggested. I was surprised to find that the AI didn't cast Timely Reinforcements when it wouldn't get some benefit. The AI would cast it the first chance it got when it would get some benefit. At this point, I am not sure why it was marked with RemAIDeck. In general, creatures are more useful to the AI than life, so adding something to AbilityFactoryAlterLife to wait to play it until the AI life total is below some threshold might improve the AI's use of Timely Reinforcements.mcrawford620 wrote:OK, what I'm trying for a fix is to put a check into AbilityFactoryAlterLife that checks the conditions on the SpellAbility. If it doesn't pass (i.e., the conditions would not be met if the AI casts this spell), then the AI doesn't use it.
Then since this card has a sub-ability that might still be useful, I do another check on the sub-ability's conditions to see if that one would succeed. I added another new SVar "AIPlayForSub:True" that needs to be there if the AI wants to play the card for the sub-ability, even if the main ability would not succeed. Basically I saw that there were about 1000 sub-abilities in other cards, and I didn't want the AI trying something that didn't make sense.
So many cards, so little time
-
ArsenalNut - Posts: 512
- Joined: 08 Jul 2011, 03:49
- Has thanked: 27 times
- Been thanked: 121 times
Re: Getting started - hello
by mcrawford620 » 27 Jun 2012, 19:29
Hmm, I commented out my code and tried your test again, and I can definitely see the AI casting Timely Reinforcements for no benefit. It sometimes takes him a couple of turns, because there is a random element in the decision. My fix will prevent him from doing it for no benefit, though.
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Getting started - hello
by ArsenalNut » 27 Jun 2012, 20:12
I didn't realize there was a random element. The AI must have gotten "lucky" in my tests.mcrawford620 wrote:Hmm, I commented out my code and tried your test again, and I can definitely see the AI casting Timely Reinforcements for no benefit. It sometimes takes him a couple of turns, because there is a random element in the decision. My fix will prevent him from doing it for no benefit, though.
I notice you checked in some changes to address AI issues with the hard coded Clones. Just to give you a heads up, I am working on adding a Clone AF that will make the Clones scriptable and hopefully fix most of the problems with the current hard coded clone series. My code is in a different branch right now. I am hoping to get my branch merged into the Trunk before the next release.
So many cards, so little time
-
ArsenalNut - Posts: 512
- Joined: 08 Jul 2011, 03:49
- Has thanked: 27 times
- Been thanked: 121 times
Re: Getting started - hello
by mcrawford620 » 28 Jun 2012, 01:39
Sounds good on the Clone.
Are there existing functions to figure out what cards in a CardList are castable, given what's on the board? Or something along those lines -- given the mana on the board or in my hand, what cards can be cast?
Are there existing functions to figure out what cards in a CardList are castable, given what's on the board? Or something along those lines -- given the mana on the board or in my hand, what cards can be cast?
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Getting started - hello
by friarsol » 28 Jun 2012, 02:01
Are you just asking what can be afforded? Or what might be played?mcrawford620 wrote:Sounds good on the Clone.
Are there existing functions to figure out what cards in a CardList are castable, given what's on the board? Or something along those lines -- given the mana on the board or in my hand, what cards can be cast?
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: Getting started - hello
by jmartus » 28 Jun 2012, 05:04
sorry if im being rude here but I saw this was a topic on ai discussion and how your trying to improve the ai, would love to see the ai play cards like Living Destiny.
Re: Getting started - hello
by mcrawford620 » 28 Jun 2012, 21:13
I think I mean both. I was looking for a function that would take a card, and tell me if it could be played, given the current board state. At first I was just asking about manager (what can be afforded) but what can actually be played would be even better.friarsol wrote:Are you just asking what can be afforded? Or what might be played?
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Getting started - hello
by ArsenalNut » 28 Jun 2012, 23:03
The closest thing to what you're looking for is forge.game.player.ComputerUtil.payManaCost. The AI uses this method to figure out if it can pay for an spell/ability or not. It actually gets called twice by the AI, once to figure if it can pay and again when the AI actually pays for the spell/ability.mcrawford620 wrote:I think I mean both. I was looking for a function that would take a card, and tell me if it could be played, given the current board state. At first I was just asking about manager (what can be afforded) but what can actually be played would be even better.friarsol wrote:Are you just asking what can be afforded? Or what might be played?
So many cards, so little time
-
ArsenalNut - Posts: 512
- Joined: 08 Jul 2011, 03:49
- Has thanked: 27 times
- Been thanked: 121 times
Re: Getting started - hello
by Sloth » 29 Jun 2012, 06:23
There are three functions that the AI uses for a spellAbility sa:mcrawford620 wrote:I think I mean both. I was looking for a function that would take a card, and tell me if it could be played, given the current board state. At first I was just asking about manager (what can be afforded) but what can actually be played would be even better.friarsol wrote:Are you just asking what can be afforded? Or what might be played?
sa.canPlay() checks restrictions (timing, zones, etc.).
ComputerUtil.canPayCost(sa) checks if the cost can be paid.
sa.canPlayAI() checks if the AI should play the sa now.
canBePlayedAndPayedByAI(sa) will check all three.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Getting started - hello
by mcrawford620 » 29 Jun 2012, 23:53
Why is Crumbling Colossus marked as No for the AI? I assume it's because it gets destroyed if it attacks, but it still seems useful to attack -- I can't really think of a class of situation where it wouldn't be good to attack. Especially since it has Trample, so it can't be easily blocked and destroyed.
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Getting started - hello
by Sloth » 30 Jun 2012, 08:44
Yes, i guess he is ok.mcrawford620 wrote:Why is Crumbling Colossus marked as No for the AI? I assume it's because it gets destroyed if it attacks, but it still seems useful to attack -- I can't really think of a class of situation where it wouldn't be good to attack. Especially since it has Trample, so it can't be easily blocked and destroyed.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Getting started - hello
by mcrawford620 » 01 Jul 2012, 04:28
Regarding the functions above that check the costs for the AI, do those functions check if the AI can play the card *right now* when some of the mana is already tapped? I was actually hoping for a function that would see if the AI could theoretically play a card given the current mana situation, but if the mana was all untapped. Say, on his next turn.
Just reading through the payManaCost() function...wow, who knew that paying mana could be so complicated. The most trivial things in real-life can turn out to be very complicated in code. I mean in real-life I usually just have to think, I have five lands so I can cast this 5-mana spell...but of course I'm subconsciously doing all the colors without thinking about it.
Just reading through the payManaCost() function...wow, who knew that paying mana could be so complicated. The most trivial things in real-life can turn out to be very complicated in code. I mean in real-life I usually just have to think, I have five lands so I can cast this 5-mana spell...but of course I'm subconsciously doing all the colors without thinking about it.
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
Re: Getting started - hello
by mcrawford620 » 01 Jul 2012, 05:49
I see a couple of comments saying "AI cannot use this properly until he can use SAs during Humans turn." What is causing that limitation? Is there no way for the AI to cast spells during the Human's turn?
Sorry for all the questions; thanks for all the answers.
Sorry for all the questions; thanks for all the answers.
- mcrawford620
- Posts: 112
- Joined: 25 Jun 2012, 16:59
- Has thanked: 55 times
- Been thanked: 25 times
40 posts
• Page 2 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 27 guests