AI Combat and Finest Hour
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
8 posts
• Page 1 of 1
AI Combat and Finest Hour
by jim » 20 Mar 2010, 15:11
I have a local implementation of Finest Hour that seems to get the rules right, as far as I understand them. Before I check it in I'd like to make it so that playing Finest Hour isn't an automatic "I win" for the human player. However, to do that, I'll need to add some specific logic for Exalted, and it may be too specific. Since I haven't written logic for the AI before, I thought I'd post what I was thinking here for comment.
Currently, in ComputerUtil_Attack2, the AI has logic to keep back enough blockers so that it won't die if the human attacks. This logic ignores Exalted, so I'd add an additional check for the edge case when the AI is keeping back zero blockers and there are any Exalted creatures in play. If Finest Hour is in play, I'd make the computer consider keeping an additional blocker because the original attacker will untap and almost surely attack again (with twice the Exalted bonus...). I don't think multiple Finest Hours should change the logic because only the original attacker gets untapped (we could add an additional check for vigilance, but that definitely seems too specific).
What do you think? Is there a better way? Is this logic worth having at all?
I'm happy to post the code if it helps. I have to figure out how to fix Knotvine Paladin and other creatures that are supposed to get bonuses "whenever they attack", so there's no rush here.
Currently, in ComputerUtil_Attack2, the AI has logic to keep back enough blockers so that it won't die if the human attacks. This logic ignores Exalted, so I'd add an additional check for the edge case when the AI is keeping back zero blockers and there are any Exalted creatures in play. If Finest Hour is in play, I'd make the computer consider keeping an additional blocker because the original attacker will untap and almost surely attack again (with twice the Exalted bonus...). I don't think multiple Finest Hours should change the logic because only the original attacker gets untapped (we could add an additional check for vigilance, but that definitely seems too specific).
What do you think? Is there a better way? Is this logic worth having at all?
I'm happy to post the code if it helps. I have to figure out how to fix Knotvine Paladin and other creatures that are supposed to get bonuses "whenever they attack", so there's no rush here.

- jim
- Posts: 46
- Joined: 19 Feb 2010, 01:46
- Location: Sunny New England
- Has thanked: 0 time
- Been thanked: 0 time
Re: AI Combat and Finest Hour
by DennisBergkamp » 20 Mar 2010, 19:17
I think it's worth having, and I don't think it's too specific (we have checks like that all over the place). So I say, add it in 
EDIT: as for fixing creatures like Knotvine Paladin, it shouldn't be that tricky (however, it would probably be messy). Just make sure creatureAttackedThisTurn (and creatureBlockedThisTurn) is set to false again right after the first combat phase... maybe we should rename them to creatureAttackedThisPhase and creatureBlockedThisPhase?

EDIT: as for fixing creatures like Knotvine Paladin, it shouldn't be that tricky (however, it would probably be messy). Just make sure creatureAttackedThisTurn (and creatureBlockedThisTurn) is set to false again right after the first combat phase... maybe we should rename them to creatureAttackedThisPhase and creatureBlockedThisPhase?
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: AI Combat and Finest Hour
by jim » 20 Mar 2010, 21:41
That sounds right -- thanks for looking into it. All I've had a chance to do so far is verify that Knotvine Paladin only gets his bonus on the first attack phase not the second. If it's just a matter of setting those values to false we should be able to find a way to do that.DennisBergkamp wrote:as for fixing creatures like Knotvine Paladin, it shouldn't be that tricky (however, it would probably be messy). Just make sure creatureAttackedThisTurn (and creatureBlockedThisTurn) is set to false again right after the first combat phase... maybe we should rename them to creatureAttackedThisPhase and creatureBlockedThisPhase?
- jim
- Posts: 46
- Joined: 19 Feb 2010, 01:46
- Location: Sunny New England
- Has thanked: 0 time
- Been thanked: 0 time
Re: AI Combat and Finest Hour
by jim » 23 Mar 2010, 01:10
What I'm doing is resetting them during the End of Combat Phase. I was afraid from the names that they were checked for some other purpose, but they don't seem to be. I did go ahead and rename them from XXThisTurn to XXThisPhase. I did the same for the BlockedThisTurn and GotBlockedThisTurn methods as well.DennisBergkamp wrote: as for fixing creatures like Knotvine Paladin, it shouldn't be that tricky (however, it would probably be messy). Just make sure creatureAttackedThisTurn (and creatureBlockedThisTurn) is set to false again right after the first combat phase... maybe we should rename them to creatureAttackedThisPhase and creatureBlockedThisPhase?
I need to do more testing but should have this in later this week. (Sorry, I work slower than many of you others.

- jim
- Posts: 46
- Joined: 19 Feb 2010, 01:46
- Location: Sunny New England
- Has thanked: 0 time
- Been thanked: 0 time
Re: AI Combat and Finest Hour
by DennisBergkamp » 03 Apr 2010, 00:53
Jim,
I've tested your updates a bit (along with Finest Hour) and did not find any bugs, so far so good
I'll just go ahead and release the next beta, if there's any bugs I'm sure we'll hear about it.
But great job with Finest Hour, that card must've taken quite a bit of work!
I've tested your updates a bit (along with Finest Hour) and did not find any bugs, so far so good

I'll just go ahead and release the next beta, if there's any bugs I'm sure we'll hear about it.
But great job with Finest Hour, that card must've taken quite a bit of work!
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: AI Combat and Finest Hour
by jim » 03 Apr 2010, 10:55
Thanks for putting it in with the beta, and for looking over it before the release. As you say, the players will probably find any bugs for us. And yes, it took more work than I thought it would, and I've had to take a break from Forge over the last week as a result. I think I may be less ambitious about the next card or cards that I add. 

- jim
- Posts: 46
- Joined: 19 Feb 2010, 01:46
- Location: Sunny New England
- Has thanked: 0 time
- Been thanked: 0 time
Re: AI Combat and Finest Hour
by DennisBergkamp » 03 Apr 2010, 17:45
Yeah, that's understandable, which is why I like to add a bunch of easy ones from time to time 

-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: AI Combat and Finest Hour
by Chris H. » 03 Apr 2010, 18:06
`jim wrote:I think I may be less ambitious about the next card or cards that I add.
I had the same mind set when I added Robber Fly and Vedalken Ghoul. They only needed several lines of easy code.

-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 52 guests