AI attacking and blocking Observations
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: AI attacking and blocking Observations
by timmermac » 14 Feb 2011, 20:45
February 14th Beta:
Computer casts an Overrun...
...and doesn't attack.
Fate protects fools, little children, ships named Enterprise, and dwarves named Tim.
Computer casts an Overrun...
...and doesn't attack.
Fate protects fools, little children, ships named Enterprise, and dwarves named Tim.
"I just woke up, haven't had coffee, let alone a pee in 7 days, and I find out you stole my ass and made a ...mini-me! Carter, I should be irked currently, yes?" - Jack O'Neill
Re: AI attacking and blocking Observations
by timmermac » 19 Feb 2011, 22:25
Is it possible to code the AI in such a way that if it gets a Beastmaster Ascension out, it will automatically attack with everything that can? The computer hardly ever takes advantage of that card, which makes it easier for me to beat it than it should be.
"I just woke up, haven't had coffee, let alone a pee in 7 days, and I find out you stole my ass and made a ...mini-me! Carter, I should be irked currently, yes?" - Jack O'Neill
Re: AI attacking and blocking Observations
by Chris H. » 19 Feb 2011, 22:54
`timmermac wrote:Is it possible to code the AI in such a way that if it gets a Beastmaster Ascension out, it will automatically attack with everything that can? The computer hardly ever takes advantage of that card, which makes it easier for me to beat it than it should be.
Masher8 spent some time improving various aspects of the computer attacking code and it should make better choices at this time.
I am in the process of uploading a new beta and people can check out the improvements that he made.
-
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: AI attacking and blocking Observations
by friarsol » 23 Feb 2011, 17:49
This one's for Masher.
I have a 3/3 Wall of Vines equipped with a Loxodon Warhammer (where its 3 power came from) and AI has a 2/2 Thunder Spirit. AI attacks straight up with the Thunder Spirit. I'm guessing because it didn't look for creatures with Reach before it decided to suicide into my wall.
Here's some debug output:
I have a 3/3 Wall of Vines equipped with a Loxodon Warhammer (where its 3 power came from) and AI has a 2/2 Thunder Spirit. AI attacks straight up with the Thunder Spirit. I'm guessing because it didn't look for creatures with Reach before it decided to suicide into my wall.
Here's some debug output:
- Code: Select all
3 = ai aggression
Normal attack
1
Thunder Spirit = attacking expecting to kill creature or cause damage, or is unblockable
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: AI attacking and blocking Observations
by Sloth » 23 Feb 2011, 18:44
I took a look at the new code and think the problem lies here:friarsol wrote:This one's for Masher.
I have a 3/3 Wall of Vines equipped with a Loxodon Warhammer (where its 3 power came from) and AI has a 2/2 Thunder Spirit. AI attacks straight up with the Thunder Spirit. I'm guessing because it didn't look for creatures with Reach before it decided to suicide into my wall.
Here's some debug output:
- Code: Select all
3 = ai aggression
Normal attack
1
Thunder Spirit = attacking expecting to kill creature or cause damage, or is unblockable
- Code: Select all
if(!CombatUtil.canDestroyBlocker(defender, attacker)){
// make exception for walls, they are usually extra tough but not dangerous unless they have
// high power, so check for walls that can kill but ignore others
if(!(defender.isWall() && defender.getNetAttack() > 0)){
canKillAll = false; // there is a dangerous creature that can survive an attack from this creature
// see if the creature is of higher or lower value. We don't want to attack only to lose value
if(CardFactoryUtil.evaluateCreature(defender) < CardFactoryUtil.evaluateCreature(attacker)){isWorthLessThanAllKillers = false;}
}
}
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: AI attacking and blocking Observations
by Masher8 » 23 Feb 2011, 19:29
Thanks Sol, I'll check this out. I'm aware of some other interesting behaviours as well, and walls are one of the weak points of the attacking AI at the moment.friarsol wrote:This one's for Masher.
I have a 3/3 Wall of Vines equipped with a Loxodon Warhammer (where its 3 power came from) and AI has a 2/2 Thunder Spirit. AI attacks straight up with the Thunder Spirit. I'm guessing because it didn't look for creatures with Reach before it decided to suicide into my wall.
Here's some debug output:
- Code: Select all
3 = ai aggression
Normal attack
1
Thunder Spirit = attacking expecting to kill creature or cause damage, or is unblockable
Edit:
This specific type of scenario should now be played a bit more sensibly by the AI. I've tidied up a couple of other corners of odd behaviour.
I've made that variable a bit more descriptive of it's current functions Sloth, it's changed over time. You were right in spotting that bit of code was the problem.
- Masher8
- Posts: 18
- Joined: 05 Feb 2011, 13:57
- Has thanked: 0 time
- Been thanked: 0 time
Re: AI attacking and blocking Observations
by Replika » 08 Mar 2011, 14:23
The AI needs some improvements when being attacked for lethal.
I have made two screenshots instead of describing the situation. I used r7256. The green lines are the blocks the AI made:
Situation 1
The AI blocked in a way that it didn't lose its creature and took lethal damage. The correct block would have been to chump the Kor Skyfisher and go to 1 life.
Situation 2
This is something that I have seen a lot from the AI: When not blocking at all would kill the AI, it blocks as many attackers as it can.
However, this is rarely correct. In this situation, the AI can kill me on it's next attack. Therefore there are only two correct blocks:
1) Chumping with 1, maybe 2 Hawks and going to 3 or 5, expecting to win on the backswing. This is the block I would have expected from the AI.
2) Blocking the Mosquito Guard with 2 Squadron Hakws, going to 1. Consider your job as done if you get the AI to do such a block. This way, the AI not only survives, it only loses one Hawk, still wins on the board and also took down one of my creatures.
By the way, I have never seen the AI gangblocking an attacker if that attacker can kill only one of its blockers. I can happily attack my Moriok Reaver into the AIs double Sea Gate Oracle and it won't block. For some reason, it values its 1/3 higher than my 3/2. On a similar note, I have rarely seen the AI blocking my 2/1 flyer with its 1/1 flyer, even though the 2/1 creature is clearly of higher value than the 1/1.
I have made two screenshots instead of describing the situation. I used r7256. The green lines are the blocks the AI made:
Situation 1
The AI blocked in a way that it didn't lose its creature and took lethal damage. The correct block would have been to chump the Kor Skyfisher and go to 1 life.
Situation 2
This is something that I have seen a lot from the AI: When not blocking at all would kill the AI, it blocks as many attackers as it can.
However, this is rarely correct. In this situation, the AI can kill me on it's next attack. Therefore there are only two correct blocks:
1) Chumping with 1, maybe 2 Hawks and going to 3 or 5, expecting to win on the backswing. This is the block I would have expected from the AI.
2) Blocking the Mosquito Guard with 2 Squadron Hakws, going to 1. Consider your job as done if you get the AI to do such a block. This way, the AI not only survives, it only loses one Hawk, still wins on the board and also took down one of my creatures.
By the way, I have never seen the AI gangblocking an attacker if that attacker can kill only one of its blockers. I can happily attack my Moriok Reaver into the AIs double Sea Gate Oracle and it won't block. For some reason, it values its 1/3 higher than my 3/2. On a similar note, I have rarely seen the AI blocking my 2/1 flyer with its 1/1 flyer, even though the 2/1 creature is clearly of higher value than the 1/1.
Re: AI attacking and blocking Observations
by Sloth » 08 Mar 2011, 17:10
This should work better now. The AI will check if it's life is still in danger between chosing every blocker. Thanks Replika.Replika wrote:Situation 2
This is something that I have seen a lot from the AI: When not blocking at all would kill the AI, it blocks as many attackers as it can.
However, this is rarely correct. In this situation, the AI can kill me on it's next attack. Therefore there are only two correct blocks:
1) Chumping with 1, maybe 2 Hawks and going to 3 or 5, expecting to win on the backswing. This is the block I would have expected from the AI.
2) Blocking the Mosquito Guard with 2 Squadron Hakws, going to 1. Consider your job as done if you get the AI to do such a block. This way, the AI not only survives, it only loses one Hawk, still wins on the board and also took down one of my creatures.
By the way, I have never seen the AI gangblocking an attacker if that attacker can kill only one of its blockers. I can happily attack my Moriok Reaver into the AIs double Sea Gate Oracle and it won't block. For some reason, it values its 1/3 higher than my 3/2. On a similar note, I have rarely seen the AI blocking my 2/1 flyer with its 1/1 flyer, even though the 2/1 creature is clearly of higher value than the 1/1.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: AI attacking and blocking Observations
by Sloth » 16 Mar 2011, 10:12
The AI should block much better now if attacked for lethal. Please post if you find more mistakes.Replika wrote:The AI needs some improvements when being attacked for lethal.
I have made two screenshots instead of describing the situation. I used r7256. The green lines are the blocks the AI made:
Situation 1
The AI blocked in a way that it didn't lose its creature and took lethal damage. The correct block would have been to chump the Kor Skyfisher and go to 1 life.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: AI attacking and blocking Observations
by friarsol » 18 Mar 2011, 20:45
AI has a 1/5 Grizzled Leotau and I have a 2/2 and a 3/3 untapped. The AI attacks with this in the log:
3 = ai aggression
Normal attack
3
Grizzled Leotau = attacking expecting to kill creature or cause damage, or is unblockable
even though he won't kill anything or cause damage.
3 = ai aggression
Normal attack
3
Grizzled Leotau = attacking expecting to kill creature or cause damage, or is unblockable
even though he won't kill anything or cause damage.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: AI attacking and blocking Observations
by cc-drake » 19 Mar 2011, 08:59
- AI does not block my Amrou Kithkin with Nightscape Familiar even if AI has enough mana to regenerate
- AI blocks my level 4 Null Champion with an 1/1 and a 2/2 even if I have to regenerate
- AI is on 6 life and I attack with a 4/4 with trample. AI has a 1/1, 2/2 and a 4/4, but blocks with both 1/1 and 2/2. Should block with the 4/4 instead.
- I'm on 3 life, AI is on 1 and controls only a 7/6 flying Dragon. I control 8 creatures (including a wall, an indestructible creature, and some with vigilance or first strike), but no flying creature at all. AI decides not to attack.
- AI blocks my level 4 Null Champion with an 1/1 and a 2/2 even if I have to regenerate
- AI is on 6 life and I attack with a 4/4 with trample. AI has a 1/1, 2/2 and a 4/4, but blocks with both 1/1 and 2/2. Should block with the 4/4 instead.
- I'm on 3 life, AI is on 1 and controls only a 7/6 flying Dragon. I control 8 creatures (including a wall, an indestructible creature, and some with vigilance or first strike), but no flying creature at all. AI decides not to attack.
Re: AI attacking and blocking Observations
by Agetian » 25 Mar 2011, 05:32
I noticed that when the AI is about to die and it chooses not to attack in order to be able to block my creatures if I attack, it doesn't take Shadow into consideration properly - for example, if I have a 2/1 black creature with Shadow (Dauthi Horror for memory), and I have 3 hit points, and the AI has 2 hit points and it has, let's say, a 3/3 creature, it will choose not to attack me in its turn with its 3/3, probably hoping to block my Shadow card when I attack with it (even though if the AI did attack, it could have either finished me off or made me block with my precious Shadow card). Then, on my next turn I attack with my Shadow creature and the AI can't use its 3/3 to block my creature card anyway (because his 3/3 doesn't have Shadow).
Otherwise, by the way, very nice improvements in general to the AI attacking/blocking and other aspects! The AI has become much, much smarter since I last remember it from a year ago or so.
Otherwise, by the way, very nice improvements in general to the AI attacking/blocking and other aspects! The AI has become much, much smarter since I last remember it from a year ago or so.
- Agetian
- Programmer
- Posts: 3472
- Joined: 14 Mar 2011, 05:58
- Has thanked: 677 times
- Been thanked: 561 times
Re: AI attacking and blocking Observations
by Sloth » 30 Mar 2011, 10:07
The AI will now attack more aggressively with creatures that can't block any of your creatures anyway. Thanks for reporting Agetian.Agetian wrote:I noticed that when the AI is about to die and it chooses not to attack in order to be able to block my creatures if I attack, it doesn't take Shadow into consideration properly - for example, if I have a 2/1 black creature with Shadow (Dauthi Horror for memory), and I have 3 hit points, and the AI has 2 hit points and it has, let's say, a 3/3 creature, it will choose not to attack me in its turn with its 3/3, probably hoping to block my Shadow card when I attack with it (even though if the AI did attack, it could have either finished me off or made me block with my precious Shadow card). Then, on my next turn I attack with my Shadow creature and the AI can't use its 3/3 to block my creature card anyway (because his 3/3 doesn't have Shadow).
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: AI attacking and blocking Observations
by Agetian » 31 Mar 2011, 05:04
No problem. Compiled the latest SVN with your latest change, Sloth, and gave it a test yesterday - works much, much better now, thank you very much.
I have one more observation about strange behavior by the way - I had a 3/4 creature with an equipment that gave Double Strike, and the AI opponent had a 2/2 creature. The AI cast Giant Growth in his Main 1 phase on his 2/2 creature, making it a 5/5 (I expected that an attack would follow, because Giant Growth lasts only till the end of turn), but then it chose not to attack me during its Combat phase - probably predicting that my double strike creature will finish his creature with 6 damage anyway?... I'm not sure what the AI reasoning here was, but in essence it basically wasted a Giant Growth card. If it attacked, it would have either dealt 5 damage to me if I chose not to block, or at least it would have made me block with my 3/4 Double Strike, and both creatures would have died in the process, making it probably not the worst trade (a mere 2/2 for a 3/4 DS is a good trade IMO, though of course the Double Strike thing was an equipment so I could have later attached it to something else, though it still would have taken me a couple turns probably).
Thank you very much for your hard work on AI improvements, much appreciated!
I have one more observation about strange behavior by the way - I had a 3/4 creature with an equipment that gave Double Strike, and the AI opponent had a 2/2 creature. The AI cast Giant Growth in his Main 1 phase on his 2/2 creature, making it a 5/5 (I expected that an attack would follow, because Giant Growth lasts only till the end of turn), but then it chose not to attack me during its Combat phase - probably predicting that my double strike creature will finish his creature with 6 damage anyway?... I'm not sure what the AI reasoning here was, but in essence it basically wasted a Giant Growth card. If it attacked, it would have either dealt 5 damage to me if I chose not to block, or at least it would have made me block with my 3/4 Double Strike, and both creatures would have died in the process, making it probably not the worst trade (a mere 2/2 for a 3/4 DS is a good trade IMO, though of course the Double Strike thing was an equipment so I could have later attached it to something else, though it still would have taken me a couple turns probably).
Thank you very much for your hard work on AI improvements, much appreciated!
- Agetian
- Programmer
- Posts: 3472
- Joined: 14 Mar 2011, 05:58
- Has thanked: 677 times
- Been thanked: 561 times
Re: AI attacking and blocking Observations
by eidolon » 02 Apr 2011, 11:50
If the AI decides that the best move is to kill a creature in combat or with a removal spell, it should prefer creatures with abilities (maybe check for pump / regeneration first) over "vanilla" creatures.
- eidolon
- Posts: 56
- Joined: 15 Sep 2009, 22:12
- Location: Bavaria, Germany
- Has thanked: 0 time
- Been thanked: 0 time
Who is online
Users browsing this forum: No registered users and 70 guests