It is currently 16 Apr 2024, 21:25
   
Text Size

[fixed]Mana sources with cost AI no tap for coloured mana

Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins

[fixed]Mana sources with cost AI no tap for coloured mana

Postby Aswan jaguar » 08 Jun 2017, 15:53

Describe the Bug:
AI can't use the lands from Homelands like Koskun Keep for coloured mana.fixed
The good thing is that these lands don't make AI to miss land drops.
Which card did behave improperly?
lands from Homelands.

Which update are you using? (date, name)Which type? (duel, gauntlet, sealed deck)
Manalink 2016/08/27: Eldritch Moon v2, duel

What exactly should be the correct behavior/interaction?
AI can use them for coloured mana.

Are any other cards possibly affected by this bug?
Probably all land cards that have {1} {T} add coloured mana or {2} {T} add coloured mana.
Attachments
ai no use of koskun like lands.rar
(2.54 KiB) Downloaded 192 times
Last edited by Aswan jaguar on 27 Sep 2022, 13:57, edited 8 times in total.
Reason: fixed all here & retitled
---
Trying to squash some bugs and playtesting.
User avatar
Aswan jaguar
Super Tester Elite
 
Posts: 8078
Joined: 13 May 2010, 12:17
Has thanked: 730 times
Been thanked: 458 times

Re: Lands from Homelands-AI no tap for coloured mana

Postby Korath » 08 Jun 2017, 21:09

I confirm this (in dev), as well as with Shimmering Grotto/Unknown Shores/Prismatic Lens, which the Homelands lands are based on. This is irritating, because Prismatic Lens at least used to work.

----

OK, the main problem here is the lines
Code: Select all
if (avail >= 2)
  choice = choose_a_color_exe(player, "What kind of mana?", 1, 0,
                              COLOR_TEST_COLORLESS | primary | (avail < 3 ? 0 : secondary));
in homelands_triple_land() and the similar ones in card_prismatic_lens(). The first 0 is the ai_choice parameter, and the AI will pick that choice in this sort of interface function every time, without fail. 0 here means COLOR_COLORLESS, so that's the only color the AI taps these mana sources for.

Probably the most straightforward way to fix this is to publicize choose_mana_all_one_color() from produce_mana.c, and replace the choose_a_color_exe() call with one to that. The card works fine if I copy its function into Shandalar (which is easier for me to debug, but should otherwise be equivalent for the purposes of this bug) and then do that. With the choose_a_color_exe() call untouched, the AI does nothing with two Wastes and a Castle Sengir on the bf and a Lightning Bolt in hand against my 3 life; replace it with choose_mana_all_one_color() and it immediately fries me.

There's a secondary problem, too - at the time the card tries to figure out which colors of mana it can produce (during EVENT_CHANGE_TYPE), it's using stale data for how much mana is available. That's difficult to avoid, since if we wait until after mana is counted, it's too late for this card to declare any mana of its own available. In practice, I'd expect this to make the AI less likely to tap one of these for colored mana during its first action during its first main phase of a turn.

Making a list of other affected cards would be helpful. They'll all have been implemented separately, so will all need to be fixed separately.

(Experimenting with this bug in Shandalar makes me sad. There was a Castle Sengir in the first Magic booster I ever cracked - I'd been playing for a while before that, but only with my friends' cast-off commons and uncommons - and I was excited to see it, since Sengir Vampire was everyone's finisher of choice in black. That only lasted until I actually tried to make it work in a deck, but still, nostalgiaz. And I still can't put it into Shandalar for real, because, like Manalink, its underlying mana engine is still fundamentally incapable of dealing with mana filtering correctly.)
Last edited by Aswan jaguar on 28 Dec 2021, 18:14, edited 1 time in total.
Reason: strikethrough fixed ones
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Re: [Needs list]Lands from Homelands-AI no tap for coloured

Postby Korath » 10 Jun 2017, 04:45

Looks like just Skyshroud Elf has the same underlying bug as the cards already mentioned (in dev).
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Re: [Needs list]Lands from Homelands-AI no tap for coloured

Postby Aswan jaguar » 10 Jun 2017, 13:25

EDIT: I checked all I found with "pay mana cost" and some with "pay life" to make coloured mana:

- Skycloud Expanse, Mossfire Valley and Shadowblood Ridge AI doesn't produce coloured mana so are totally useless for AI.
Note: with the other 2 of this cycle - Sungrass Prairie and Darkwater Catacombs - AI can use them to produce coloured mana.These have value activate in ct_all while the 3 top don't.I have tested and if the values are inserted the cards work fine for AI and human.In my limited tests no problem is caused.



- Petalmane Baku, Skyshroud Elf, Viridian Acolyte (has a bug already fixed? that produces only colourless mana for human, too so will need attention then), AI doesn't produce coloured mana.
Note: - Petalmane Baku doesn't have value activate as it should.When inserted AI produces only black mana though.
- Skyshroud Elf doesn't have paid mana source value as it should for second activated ability but even when inserted AI doesn't use the ability. no need makes things worse

- Prophetic Prism,Chromatic Sphere, Chromatic Star, Barbed Sextant, Standing Stones AI produces only black coloured mana.
Note: - Prophetic Prism doesn't have values for colour production in ct_all even if they are inserted though still produces only black.
- Barbed Sextant doesn't have value for paid mana source in ct_all even if inserted though still produces only black.

The hardcoded Celestial Prism works fine for AI if this helps.

- The cards with "Tap pay life" for coloured mana like Vesper Ghoul, Horizon Canopy, Mana Confluence work fine except:
AI however with Standing Stones which in addition to {T} pay life needs also {1} produces only black coloured mana.

- Farrelite Priest, Manaforge Cinder, Knotvine Mystic work fine.

- Azorious Signet, Gruul Signet and Dimir Signet work fine.(I tested only each of the separate sets using signets hoping that the others use the same base as these).
Last edited by Aswan jaguar on 15 Jan 2022, 17:20, edited 10 times in total.
Reason: add edit - strikethrough fixed ones
---
Trying to squash some bugs and playtesting.
User avatar
Aswan jaguar
Super Tester Elite
 
Posts: 8078
Joined: 13 May 2010, 12:17
Has thanked: 730 times
Been thanked: 458 times

Re: [list done]Lands from Homelands-AI no tap for coloured m

Postby Aswan jaguar » 02 Jan 2022, 14:33

Fixed Homeland Triplands and Aether Hub in commit f2c86a6.
Korath do we need the paid mana source value in ct_all (also do we have a function in C that makes the same thing?) for land cards that have only a paid mana ability like the Odyssey lands, Skycloud Expanse and the rest? Because I am busting my head how to make AI activate them and also not tap them needlessly like the artifacts and creatures with that value which though need paid mana source value.
---
Trying to squash some bugs and playtesting.
User avatar
Aswan jaguar
Super Tester Elite
 
Posts: 8078
Joined: 13 May 2010, 12:17
Has thanked: 730 times
Been thanked: 458 times

Re: [list done]mana sources that-AI no tap for coloured mana

Postby Korath » 02 Jan 2022, 21:41

Remember that many of these flags were named after cards they tended to appear on, have never been updated, and widely vary in how accurately they represent their actual purpose. The only thing EA_PAID_MANASOURCE does is prevent a card from being autotapped for mana in can_autotap(). The only way the AI will activate cards flagged with it at all is if they're also flagged EA_ACT_ABILITY (which makes it activate them using the normal try-something-random-and-see-how-dumb-it-was AI, not the deterministic pay-a-mana-cost AI).
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Re: [list done]mana sources that-AI no tap for coloured mana

Postby Aswan jaguar » 06 Jan 2022, 12:54

Fixed the odyssey lands in commit ed31f59.
Fixed Skyshroud Elf in commit 55ed5c6.
Fixed Viridian Acolyte and look a like cards in commit e7a0cd3.
Fixed Chromatic Sphere, Chromatic Star & Barbed Sextant in commit 283f071.
Fixed Standing Stones in commit 739b75d.
Recoded Celestial Prism in commit b5e489e this only to count mana and port to C code as AI used this correctly before, too.
Last edited by Aswan jaguar on 19 Jan 2022, 07:30, edited 4 times in total.
Reason: add fixed
---
Trying to squash some bugs and playtesting.
User avatar
Aswan jaguar
Super Tester Elite
 
Posts: 8078
Joined: 13 May 2010, 12:17
Has thanked: 730 times
Been thanked: 458 times

Re: [list done]mana sources that-AI no tap for coloured mana

Postby Aswan jaguar » 10 Jan 2022, 16:28

Any idea why the following code doesn't work for AI to produce mana? Also in ct_all I have only EA_MANA_SOURCE not activate values but this shouldn't be an issue, it wasn't for the other cards I have already changed above.
Code: Select all
int card_petalmane_baku(int player, int card, event_t event){
   /* CARD_ID_PETALMANE_BAKU   7539
   Petalmane Baku   |1|G
   Creature - Spirit 1/2
   Whenever you cast a Spirit or Arcane spell, you may put a ki counter on ~.
   |1, Remove X ki counters from ~: Add X mana of any one color to your mana pool. */

   if( arcane_spirit_spell_trigger(player, card, event, RESOLVE_TRIGGER_DUH) ){
      add_counter(player, card, player, card, COUNTER_KI);
   }

   if( event == EVENT_COUNT_MANA && affect_me(player, card) ){
      if( can_produce_mana(player, card) && count_counters(player, card, COUNTER_KI) > 0 && has_mana_for_activated_ability(player, card, MANACOST_X(1)) )
      {
         declare_mana_available_hex(player, COLOR_TEST_ANY_COLORED, count_counters(player, card, COUNTER_KI));
         //declare_mana_available(player, COLOR_COLORLESS, -1);
      }
   }

   if( event == EVENT_CAN_ACTIVATE && can_produce_mana(player, card) && count_counters(player, card, COUNTER_KI) > 0 &&
      get_card_instance(player, card)->targets[1].player != 1 )
   {
      return has_mana_for_activated_ability(player, card, MANACOST_X(1));
   }

   if(event == EVENT_ACTIVATE ){
      card_instance_t* instance = get_card_instance(player, card);
      
      int amount = count_counters(player, card, COUNTER_KI);
      if( !IS_AI(player) && amount > 1 ){
         amount = choose_a_number(player, "Remove how many counters?", count_counters(player, card, COUNTER_KI));
         if( amount == 0 || amount > count_counters(player, card, COUNTER_KI) ){
            spell_fizzled = 1;
         }
      }
      int choice = choose_mana_all_one_color(player, COLOR_TEST_ANY_COLORED, 1, "What kind of mana?", COLOR_TEST_COLORLESS);
      if (choice == -1){
         cancel = 1;
         return 0;
      }
      instance->targets[1].player = 1;
      charge_mana_for_activated_ability(player, card, MANACOST_X(1));
      instance->targets[1].player = 0;
      if (cancel == 1){
         return 0;
      }
      remove_counters(player, card, player, card, COUNTER_KI, amount);
      color_t color = choice;
      produce_mana(player, color, 1);
      tapped_for_mana_color = -2;   // mana ability, so can't respond (but not "tapping for mana", or even tapping)
   }

   return 0;
}
---
Trying to squash some bugs and playtesting.
User avatar
Aswan jaguar
Super Tester Elite
 
Posts: 8078
Joined: 13 May 2010, 12:17
Has thanked: 730 times
Been thanked: 458 times

Re: [list done]mana sources that-AI no tap for coloured mana

Postby Aswan jaguar » 19 Jan 2022, 07:32

Everything here except Petalmane Baku works now a lot better for AI. it works the issue was the in game id of lands to tap was bigger than Petalmane Baku in game id.
Last edited by Aswan jaguar on 27 Sep 2022, 13:54, edited 1 time in total.
Reason: edited
---
Trying to squash some bugs and playtesting.
User avatar
Aswan jaguar
Super Tester Elite
 
Posts: 8078
Joined: 13 May 2010, 12:17
Has thanked: 730 times
Been thanked: 458 times


Return to Archived Reports

Who is online

Users browsing this forum: No registered users and 59 guests


Who is online

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

Login Form