It is currently 29 Aug 2025, 09:18
   
Text Size

Getting started - hello

Post MTG Forge Related Programming Questions Here

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

Re: Getting started - hello

Postby 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.
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Re: Getting started - hello

Postby 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.
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Re: Getting started - hello

Postby ArsenalNut » 27 Jun 2012, 12:59

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.
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.
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: Getting started - hello

Postby 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

Postby ArsenalNut » 27 Jun 2012, 20:12

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 didn't realize there was a random element. The AI must have gotten "lucky" in my tests.

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
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: Getting started - hello

Postby 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?
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Re: Getting started - hello

Postby friarsol » 28 Jun 2012, 02:01

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?
Are you just asking what can be afforded? Or what might be played?
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Getting started - hello

Postby 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.
jmartus
 
Posts: 207
Joined: 11 Oct 2010, 09:25
Has thanked: 0 time
Been thanked: 7 times

Re: Getting started - hello

Postby mcrawford620 » 28 Jun 2012, 21:13

friarsol wrote:Are you just asking what can be afforded? Or what might be played?
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.
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Re: Getting started - hello

Postby ArsenalNut » 28 Jun 2012, 23:03

mcrawford620 wrote:
friarsol wrote:Are you just asking what can be afforded? Or what might be played?
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.
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.
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: Getting started - hello

Postby Sloth » 29 Jun 2012, 06:23

mcrawford620 wrote:
friarsol wrote:Are you just asking what can be afforded? Or what might be played?
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.
There are three functions that the AI uses for a spellAbility sa:

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Getting started - hello

Postby 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

Postby Sloth » 30 Jun 2012, 08:44

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.
Yes, i guess he is ok.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Getting started - hello

Postby 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.
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

Re: Getting started - hello

Postby 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.
mcrawford620
 
Posts: 112
Joined: 25 Jun 2012, 16:59
Has thanked: 55 times
Been thanked: 25 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 27 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 27 users online :: 0 registered, 0 hidden and 27 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 27 guests

Login Form