It is currently 29 Oct 2025, 12:46
   
Text Size

Combat AI

Post MTG Forge Related Programming Questions Here

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

Combat AI

Postby Sloth » 25 Nov 2010, 21:37

I just wanted to inform you that I'm working on a mayor overhaul of ComputerUtil_Block. It's not finished and I don't want to submit it before the next beta is released. I plan to update ComputerUtil_Attack afterwards. Has anyone tried anything so far? Or are there any wishes/advise?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Combat AI

Postby slapshot5 » 26 Nov 2010, 02:54

What do you mean by tried anything? If you mean, noticing combat bugs, then yes. The AI's combat decisions seem to have gotten slightly worse.

I'm at 12 life and compy is at 20 life. I've got a Serra Angel out, and he's got 2 1/1 Goblin tokens. And he's attacking straight into me. I just kill them off one-by-one.

I've noticed this a couple times now.

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

Re: Combat AI

Postby Chris H. » 26 Nov 2010, 12:59

Sloth wrote:I just wanted to inform you that I'm working on a mayor overhaul of ComputerUtil_Block. It's not finished and I don't want to submit it before the next beta is released. I plan to update ComputerUtil_Attack afterwards.
`
Sounds like a good idea. I would like to release the next beta on Monday.

Sol should be back from family commitments soon. I think that he may have a few suggestions that would prove useful.
User avatar
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

Re: Combat AI

Postby lazylockie » 26 Nov 2010, 13:38

You might want to AI take into consideration Bushido and Flanking when attacking / blocking, and also to a lesser extent, Deathtouch. I've seen numerous times when AI gets fooled by those three keywords.
lazylockie
 
Posts: 508
Joined: 13 Jul 2010, 22:44
Has thanked: 74 times
Been thanked: 15 times

Re: Combat AI

Postby friarsol » 29 Nov 2010, 02:07

The Blockers system that's in place now has a lot of good ideas, but I think they don't consider a lot of the newer keywords.

Here are some important questions I think the AI needs to consider for each attacker to create an order to declare blockers?

  • How many creatures can I legally block with? (Flying/Fear/Shadow/etc)

  • If this is unblocked what percentages of my remaining life total/poison counter accumulation would this take off?

  • Any other keywords that should be considered? (Trample/Lifelink/Regen)

  • Is this attack suspicious? (Attacking with a weak/pumpable creature that would easily die)

  • Does the attacker survive at end of combat? (Ball Lightning)

Here are some important questions I think the AI needs to consider for each blocker:

(Make sure temporarily adjust power/toughness for things like Bushido/Flanking/Rampage)

  • Would this Blocker survive to deal damage (Flanking/First/Double Strike)? At end of combat? (Death by Damage, or Basilisk type effects)

  • Would this Blocker kill the Attacker?

  • Is the Attacker a better creature than the Blocker?
[/list]

Blocking is pretty complex, but there are a lot of pieces that can be implemented to help improve things.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Combat AI

Postby Sloth » 29 Nov 2010, 16:30

I'm mostly finished with my blocking code. At the moment the AI considers the following steps:

A. Good Blocks
1. Blockers that can destroy the attacker but won't get destroyed
2. Blockers that won't get destroyed
3. Blockers that can destroy the attacker and are worth less
4. TODO: Good Gangblocks (pretty risky)

B. Necessary trade blocks if life is in danger (would sink below 4)

C. Necessary chump blocks if life is still in danger (would sink below 4)

D. Reinforce blockers blocking attackers with trample (from A.3, B or C) if life is still in danger (would sink below 4)

E. Support blockers not destroying the attacker (from A.2 or C) with more blockers to try to kill the attacker
1. Try to use more safe blockers first
2. Try to add one blocker that could be destroyed, but is worth less than the attacker


Even though I tested a bit, I will submit it after the next beta just to be sure no mayor bugs slipped through.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Combat AI

Postby friarsol » 29 Nov 2010, 16:34

Seems pretty good. Is there considerations for Poison counters at the same point life is considered? I find the AI to be extremely dumb when blocking Infect creatures.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Combat AI

Postby Sloth » 29 Nov 2010, 17:12

friarsol wrote:Seems pretty good. Is there considerations for Poison counters at the same point life is considered? I find the AI to be extremely dumb when blocking Infect creatures.
Not yet. But it should be fairly easy. I will see to it.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Combat AI

Postby SoulStorm » 29 Nov 2010, 19:12

I'm really looking forward to this update! Nice work Sloth!
SoulStorm
 
Posts: 423
Joined: 24 Jun 2010, 22:48
Has thanked: 16 times
Been thanked: 11 times

Re: Combat AI

Postby SoulStorm » 29 Nov 2010, 20:30

Something else just occurred to me. What about code to protect planeswalkers? What about using the same code that is in steps B, C, and D? Instead of being based upon life dropping below 4, it would be based upon a planeswalker being on the field.

The other question is whether or not 4 life is the best threshold to use?
SoulStorm
 
Posts: 423
Joined: 24 Jun 2010, 22:48
Has thanked: 16 times
Been thanked: 11 times

Re: Combat AI

Postby Sloth » 30 Nov 2010, 13:49

SoulStorm wrote:Something else just occurred to me. What about code to protect planeswalkers? What about using the same code that is in steps B, C, and D? Instead of being based upon life dropping below 4, it would be based upon a planeswalker being on the field.
Planeswalkers will also be protected with "bad" blocks, but only if they wouldn't survive otherwise.

SoulStorm wrote:The other question is whether or not 4 life is the best threshold to use?
Yes, that is debatable. 4 is just a guessed number. A more complex evaluation (and maybe some more randomness) would be good.

The blocking code was submitted to the SVN. Please post your experiences, i.e. situations where the AI made blocking mistakes.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Combat AI

Postby SoulStorm » 30 Nov 2010, 15:04

Sloth wrote:The blocking code was submitted to the SVN. Please post your experiences, i.e. situations where the AI made blocking mistakes.
I'd do that but for some reason I've never been able to create a working build from the SVN. I'm going to have to wait until the next update to make any evaluations.

Thanks for all the hard work!
SoulStorm
 
Posts: 423
Joined: 24 Jun 2010, 22:48
Has thanked: 16 times
Been thanked: 11 times

Re: Combat AI

Postby slapshot5 » 30 Nov 2010, 20:41

Hey Sloth, since you are digging around in there, any idea how easy it would be to implement keywords like:

CARDNAME can't be blocked except by two or more creatures.
CARDNAME can't be blocked except by three or more creatures.

?

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

Re: Combat AI

Postby Sloth » 30 Nov 2010, 21:08

slapshot5 wrote:Hey Sloth, since you are digging around in there, any idea how easy it would be to implement keywords like:

CARDNAME can't be blocked except by two or more creatures.
CARDNAME can't be blocked except by three or more creatures.

?

Thanks,
slapshot5
Uhh, that won't be easy. It's possible to declare an attacker with one of these keywords unblocked in setAssignedDamage in Combat.java if the number of blockers is not enough. It won't be displayed that the attacker is unblocked, but I think that's ok.

The blocking AI will also be difficult, but doable.

Do you want to give it a try slapshot? Otherwise I will tinker around a bit.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Combat AI

Postby slapshot5 » 30 Nov 2010, 22:55

I'm going to be on the road for at least the next 5 days. I won't get around to it anytime soon if I do at all.

I've poked around in combat once or twice. If you have some ideas, go for it. I'd be starting from square one.

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

Next

Return to Developer's Corner

Who is online

Users browsing this forum: Timothysow 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: Timothysow and 21 guests

Login Form