Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
Hint to the AI the value of activating an ability?
Moderator: CCGHQ Admins
Hint to the AI the value of activating an ability?
by MisterBenn » 15 Jan 2012, 21:27
Hi there, I came back to card development after a few weeks of being discouraged! I have my first deck complete but I am trying to optimise the AI's usage of certain cards. If anyone has wisdom on a couple of questions I'd be very grateful.
Titan Forge - can I hint to the AI that it's very desirable to pursue and trigger the golem making ability? When I have Energy Chamber alongside, the AI will place charge counters there and trigger it correctly. However, the AI will also get back to its own untap step with 3 mana available and doesn't choose to activate the Titan Forge's first ability. Can I encourage this to happen? I have a <AI_AVAILABILITY behaviour="InResponseOrBeforeMyUntap"/> tag against both abilities but as I understand that declares the abilities are merely available rather than encouraged. I also have things like <AI_BASE_SCORE score="1000" zone="in_play"/> against them but as I understand that just says it's good to have that ability out in play. The only other tag I've seen like this is <AI_PLAY_SCORE> but that's for picking when to play the card from what I can see.
Is there another method for closer control of activated abilities? I guess I could just have a triggered ability to force the ability to trigger at the end but that's a bit inelegant and might not play nice with other cards... any ideas?
Titan Forge - can I hint to the AI that it's very desirable to pursue and trigger the golem making ability? When I have Energy Chamber alongside, the AI will place charge counters there and trigger it correctly. However, the AI will also get back to its own untap step with 3 mana available and doesn't choose to activate the Titan Forge's first ability. Can I encourage this to happen? I have a <AI_AVAILABILITY behaviour="InResponseOrBeforeMyUntap"/> tag against both abilities but as I understand that declares the abilities are merely available rather than encouraged. I also have things like <AI_BASE_SCORE score="1000" zone="in_play"/> against them but as I understand that just says it's good to have that ability out in play. The only other tag I've seen like this is <AI_PLAY_SCORE> but that's for picking when to play the card from what I can see.
Is there another method for closer control of activated abilities? I guess I could just have a triggered ability to force the ability to trigger at the end but that's a bit inelegant and might not play nice with other cards... any ideas?
- MisterBenn
- Posts: 97
- Joined: 19 Mar 2011, 16:19
- Has thanked: 24 times
- Been thanked: 11 times
Re: Hint to the AI the value of activating an ability?
by thefiremind » 07 Jun 2012, 15:04
I just encountered a similar problem. I coded Rootwater Thief like this:
I'm afraid there's nothing to do when the AI doesn't understand the value of an activated or triggered ability. <AI_PLAY_SCORE> is very useful for spells (I used it to convince the AI to play Duress and Castigate, for example), but there's nothing like that for permanents' abilities, as far as I know.
- Code: Select all
<TRIGGERED_ABILITY>
<TRIGGER value="CREATURE_DEALT_COMBAT_DAMAGE_TO_PLAYER" simple_qualifier="self" />
<COST type="mana" cost="{2}" qualifier="conditional" />
<RESOLUTION_TIME_ACTION conditional="if">
local filter = Object():GetFilter()
filter:Clear()
filter:NotTargetted()
filter:SetPlayer( TriggerPlayer() )
filter:SetZone( ZONE_LIBRARY )
filter:May()
Object():GetPlayer():ChooseTarget( "CARD_QUERY_CHOOSE_CARD_TO_EXILE" )
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION conditional="if">
local target = Object():GetTargetCard()
if target ~= nil and target:GetZone() == ZONE_LIBRARY then
target:RemoveFromGame()
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION conditional="if">
TriggerPlayer():ShuffleLibrary()
</RESOLUTION_TIME_ACTION>
<AI_BASE_SCORE score="1200" zone="in_play" />
</TRIGGERED_ABILITY>
I'm afraid there's nothing to do when the AI doesn't understand the value of an activated or triggered ability. <AI_PLAY_SCORE> is very useful for spells (I used it to convince the AI to play Duress and Castigate, for example), but there's nothing like that for permanents' abilities, as far as I know.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: Hint to the AI the value of activating an ability?
by Eglin » 11 Jun 2012, 06:54
You can ensure that your game is set to the highest difficulty and try the firebreathing tag.
Re: Hint to the AI the value of activating an ability?
by thefiremind » 11 Jun 2012, 10:26
The firebreathing tag did nothing for Rootwater Thief, probably because it's not an activated ability. Thanks anyway for the tip.Eglin wrote:You can ensure that your game is set to the highest difficulty and try the firebreathing tag.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: Hint to the AI the value of activating an ability?
by MisterBenn » 15 Jun 2012, 00:37
Ha ha I forgot that I posted this question! I've concluded with my experiments since then that in some situations it's best to just code the card with an additional "if it's just before my untap and I can afford it, just go ahead and activate the ability" for the AI. The heuristics will evaluate correctly that it can save the mana and use the ability, or use the mana elsewhere if the benefit is greater. The only issue is if the deck contains multiple different cards that are implemented this way, the AI will of course just spend on the first card of this type that it considers.
I would love if 2013 brought a feature like "when this card is on the battlefield it is worth 300 plus 100 per charge counter on it" so that you could hint to the AI how to build up certain decks correctly when it's too early to be obvious.
I would love if 2013 brought a feature like "when this card is on the battlefield it is worth 300 plus 100 per charge counter on it" so that you could hint to the AI how to build up certain decks correctly when it's too early to be obvious.
- MisterBenn
- Posts: 97
- Joined: 19 Mar 2011, 16:19
- Has thanked: 24 times
- Been thanked: 11 times
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests