It is currently 24 Apr 2024, 05:52
   
Text Size

Hint to the AI the value of activating an ability?

Moderator: CCGHQ Admins

Hint to the AI the value of activating an ability?

Postby 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?
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?

Postby thefiremind » 07 Jun 2012, 15:04

I just encountered a similar problem. I coded Rootwater Thief like this:
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>
but the AI never wants to pay those 2 mana, even if it has nothing else to play for that turn (and no instants to play on my next turn, either).

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...
User avatar
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?

Postby Eglin » 11 Jun 2012, 06:54

You can ensure that your game is set to the highest difficulty and try the firebreathing tag.
User avatar
Eglin
Programmer
 
Posts: 195
Joined: 01 Mar 2012, 14:44
Has thanked: 39 times
Been thanked: 22 times

Re: Hint to the AI the value of activating an ability?

Postby thefiremind » 11 Jun 2012, 10:26

Eglin wrote:You can ensure that your game is set to the highest difficulty and try the firebreathing tag.
The firebreathing tag did nothing for Rootwater Thief, probably because it's not an activated ability. Thanks anyway for the tip.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
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?

Postby 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.
MisterBenn
 
Posts: 97
Joined: 19 Mar 2011, 16:19
Has thanked: 24 times
Been thanked: 11 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 15 guests


Who is online

In total there are 15 users online :: 0 registered, 0 hidden and 15 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 15 guests

Login Form