It is currently 06 May 2024, 23:39
   
Text Size

RFC: Cost X and AI

New decks and cards for Stainless Games' release

Moderator: CCGHQ Admins

RFC: Cost X and AI

Postby pcastellazzi » 23 Oct 2012, 13:21

I was trying to get working Black Sun's Zenith and Green Sun's Zenith (current implementation here)

The cards work ok when are played by a human player (me). The AI, on the other hand, can pay 46 with only two basic lands. At first i thought it was a problem with my implementation (may be it is, i dont know for sure yet).

As far as i know, i should use GetObjectX() to get the value of X payed by the user, which i am doing, also Red Sun's Zenith (core card) do this in the same way but does not show this weird behavoir.

Any ideas?
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 184
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 11 times
Been thanked: 30 times

Re: RFC: Cost X and AI

Postby BlindWillow » 23 Oct 2012, 16:53

I would be careful switching around the order of the important tags like casting cost and type. I know putting a color tag in the wrong place means it won't be read. So something could be happening with casting cost coming after type in your code.

I've had no problems with the following implementation for my Melira Pod deck. Here's the code I use (and no customization here, like in my version of Birthing Pod :wink:):

Code: Select all
<?xml version='1.0'?>
<CARD_V2>
  <FILENAME text="GREEN_SUNS_ZENITH_38221559" />
  <CARDNAME text="GREEN_SUNS_ZENITH" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Green Sun’s Zenith]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Zenit del Sole Verde]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Zenit der Grünen Sonne]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Zénith de Vertsoleil]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Cenit del sol verde]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[緑の太陽の頂点]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Green Sun’s Zenith]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Зенит Зеленого Солнца]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Zênite do Sol Verde]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="38221559" />
  <ARTID value="38221559" />
  <ARTIST name="David Rapoza" />
  <CASTING_COST cost="{X}{G}" />
  <FLAVOURTEXT>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[As the green sun crowned, Phyrexian prophecies glowed on the Tree of Tales.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Mentre il sole verde saliva, le profezie di Phyrexia brillavano sull’Albero dei Racconti.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Als die Grüne Sonne ihren höchsten Stand erreichte, glühten phyrexianische Prophezeiungen am Baum der Sagen.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Quand Vertsoleil fut à son zénith, des prophéties phyrexianes brillèrent sur l’Arbre de Récits.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Mientras se coronaba el sol verde, las profecías pirexianas brillaban en el Árbol de los Cuentos.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[緑の太陽が頂点にかかると、ファイレクシアの預言は伝承の樹の上で熱を帯びた。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[As the green sun crowned, Phyrexian prophecies glowed on the Tree of Tales.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Когда зеленое солнце достигло вершины, фирексийские пророчества засветились на Древе Преданий.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Conforme o sol verde se alçou, as profecias phyrexianas se iluminaram na Árvore das Lendas.]]></LOCALISED_TEXT>
  </FLAVOURTEXT>
  <TYPE metaname="Sorcery" />
  <EXPANSION value="DPG" />
  <RARITY metaname="R" />
  <SPELL_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Search your library for a green creature card with converted mana cost X or less, put it onto the battlefield, then shuffle your library. Shuffle Green Sun’s Zenith into its owner’s library.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Passa in rassegna il tuo grimorio per una carta creatura verde con costo di mana convertito pari o inferiore a X, mettila sul campo di battaglia, poi rimescola il tuo grimorio. Rimescola lo Zenit del Sole Verde nel grimorio del suo proprietario.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Durchsuche deine Bibliothek nach einer grünen Kreaturenkarte mit umgewandelten Manakosten von X oder weniger, bringe sie ins Spiel und mische dann deine Bibliothek. Mische den Zenit der Grünen Sonne in die Bibliothek seines Besitzers.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Cherchez dans votre bibliothèque une carte de créature verte avec un coût converti de mana inférieur ou égal à X, mettez-la sur le champ de bataille et mélangez ensuite votre bibliothèque. Mélangez le Zénith de Vertsoleil dans la bibliothèque de son propriétaire.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Busca en tu biblioteca una carta de criatura verde con coste de maná convertido de X o menos, ponla en el campo de batalla y luego baraja tu biblioteca. Baraja el Cenit del sol verde en la biblioteca de su propietario.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[あなたのライブラリーから、点数で見たマナ・コストがX以下の緑のクリーチャー・カードを1枚探し、それを戦場に出し、その後あなたのライブラリーを切り直す。 緑の太陽の頂点をオーナーのライブラリーに加えて切り直す。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Search your library for a green creature card with converted mana cost X or less, put it onto the battlefield, then shuffle your library. Shuffle Green Sun’s Zenith into its owner’s library.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Найдите в вашей библиотеке карту зеленого существа с конвертированной мана-стоимостью Х или меньше, положите ее на поле битвы, затем перетасуйте вашу библиотеку. Втасуйте Зенит Зеленого Солнца в библиотеку его владельца.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Procure em seu grimório um card de criatura verde com custo de mana convertido menor ou igual a X, coloque-o no campo de batalha e depois embaralhe seu grimório. Embaralhe Zênite do Sol Verde no grimório de seu dono.]]></LOCALISED_TEXT>
    <RESOLUTION_TIME_ACTION>
    local filter = Object():GetFilter()
    local effectController = EffectController()
    effectController:MarkSearchedLibrary()
    filter:Clear()
    filter:NotTargetted()
    filter:AddCardType( CARD_TYPE_CREATURE )
    filter:AddColour( COLOUR_GREEN )
    filter:SetConvertedCostMax( GetObjectX() )
    filter:SetZone( ZONE_LIBRARY )
    filter:SetPlayer( effectController )                           
    effectController:ChooseTarget( NO_VALIDATION, "CARD_QUERY_CHOOSE_CREATURE_TO_PUT_ONTO_BATTLEFIELD", EffectDC():Make_Targets(0) )
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    if EffectDC() ~= nil then
       local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
       if  target ~= nil then
          target:PutIntoPlay( EffectController() )
       end
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    Object():SetResolutionZone(ZONE_LIBRARY)
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    EffectController():ShuffleLibrary()
    </RESOLUTION_TIME_ACTION>
  </SPELL_ABILITY>
  <AI_BASE_SCORE score="900" zone="ZONE_HAND" />
</CARD_V2>
The base score is necessary to keep the AI from using it too soon.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: RFC: Cost X and AI

Postby pcastellazzi » 27 Oct 2012, 13:35

Your theory about the tag ordering was wrong. The problem with my implementation of GSZ was a bad combination of filters and filter_zone. To be precise, i removed filter_zone from my spell ability and added a colour filter (green) which i had forgotten.

As a side note, Object():SetResolutionZone(ZONE_LIBRARY) put the card in a random position, is not necessary to use EffectController():ShuffleLibrary().
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 184
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 11 times
Been thanked: 30 times

Re: RFC: Cost X and AI

Postby BlindWillow » 27 Oct 2012, 21:48

pcastellazzi wrote:As a side note, Object():SetResolutionZone(ZONE_LIBRARY) put the card in a random position, is not necessary to use EffectController():ShuffleLibrary().
Good to know. I coded GSZ early on, and I guess something redundant like that is never going to make itself known in gameplay. Thanks.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: RFC: Cost X and AI

Postby GamerXYZ0 » 28 Oct 2012, 00:19

I don't know much about coding cards, but wouldn't it still be smart to shuffle the library? After all, if some effect is used that places cards to a certain position of your library (like at the bottom), or if an opponent used something to manipulate your library, the library should of course be properly shuffled.
GamerXYZ0
 
Posts: 102
Joined: 17 Jun 2011, 19:29
Has thanked: 10 times
Been thanked: 7 times

Re: RFC: Cost X and AI

Postby BlindWillow » 28 Oct 2012, 00:27

GamerXYZ0 wrote:I don't know much about coding cards, but wouldn't it still be smart to shuffle the library? After all, if some effect is used that places cards to a certain position of your library (like at the bottom), or if an opponent used something to manipulate your library, the library should of course be properly shuffled.
Good point. If the card says shuffle, shuffling should happen, as it's not just a matter of the card being played going into a random position, but that all the cards in the deck have their positions re-randomized. Plus, there are abilities that trigger on shuffling to be considered.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: RFC: Cost X and AI

Postby thefiremind » 28 Oct 2012, 08:56

And wouldn't it be smart for the developers to make the SetResolutionZone(ZONE_LIBRARY) function shuffle the library? After all, there isn't ShuffleLibrary after SetResolutionZone in the original cards.
Did someone really test (for example by looking at the first N cards before and after) if it happens or not, instead of just being untrustful towards the developers? :lol:
< 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: RFC: Cost X and AI

Postby pcastellazzi » 28 Oct 2012, 14:57

My bad. What i meant is SetResolutionZone(ZONE_LIBRARY) shuffles the library. I tested it while coding Black/Green Sun's Zenith because Red Sun's Zenith (a core card) did not use EffectController():ShuffleLibrary() and i wondered if it was a bug or a "feature". It ended up being a "feature".
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 184
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 11 times
Been thanked: 30 times

Re: RFC: Cost X and AI

Postby BlindWillow » 28 Oct 2012, 20:49

Yep, triggers Cosi's Trickster and everything. Wonder if it was that way from the start or if they fixed that somewhere in a patch.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: RFC: Cost X and AI

Postby thefiremind » 21 Dec 2012, 15:29

This topic drifted away a bit from the original problem, but I'd like to bump it up because I experienced the same problem with my Green Sun's Zenith: I saw the AI cast it with {X} = 46 and {X} = 53 having only 2 lands. For your information, I tried with both GetObjectX() and GetEffectX() but the problem persists. I'm using a target sorter, but pcastellazzi doesn't, so the sorter isn't the culprit.

I had an idea right now, but I didn't test it yet (testing something that can go wrong only for the AI is difficult). What if we discourage the AI from using high values for {X} ?
Code: Select all
    filter:SetConvertedCostMax( GetObjectX() )
    if EffectController():IsAI() ~= 0 and GetObjectX() &gt; 25 then
       filter:SetConvertedCostMin(25) -- this way it will fetch nothing!
    end
If the AI always works as we know (by trying scenarios and watching what happens), with this code it should realize that high numbers won't do any good.

Another idea (more restrictive) is:
Code: Select all
    if EffectController():IsAI() == 0 then
       filter:SetConvertedCostMax( GetObjectX() )
    else
       filter:SetConvertedCostValue( GetObjectX() )
    end
After all, that's exactly how we treat cards like this most of the times (why paying more when we already know what we want to fetch?), and the AI will hopefully think twice before using a big number.
< 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: RFC: Cost X and AI

Postby pcastellazzi » 21 Dec 2012, 21:51

My latest version of Green Sun's Zenith seems to work ok. If you click the combo box with an hex number (left side of the page) you can access/compare with older versions to check what i tried before. I never understood why exactly this happend. Hope it helps.
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 184
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 11 times
Been thanked: 30 times

Re: RFC: Cost X and AI

Postby thefiremind » 21 Dec 2012, 23:43

The only change that I can see is adding the color restriction on the filter... but that was just a bug fix, I didn't forget that in my version. :D
< 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: RFC: Cost X and AI

Postby pcastellazzi » 22 Dec 2012, 12:02

thefiremind wrote:The only change that I can see is adding the color restriction on the filter... but that was just a bug fix, I didn't forget that in my version. :D
I removed filter_zone from the SPELL_ABILITY tag and the sorter too.
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 184
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 11 times
Been thanked: 30 times


Return to Magic: The Gathering - Duels of the Planeswalkers

Who is online

Users browsing this forum: No registered users and 4 guests


Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 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 4 guests

Login Form