AI matching question

Options
cooperbigdaddy
cooperbigdaddy Posts: 364 Mover and Shaker
I understand the AI will always match a 5-line or a 4 if there are ones available.

But besides that, how do they decide what to match? I would think they would always want to match their strongest color, right? But it seems whenever I play with C4rol, they hardly ever match their strongest color. But in my mind, C4rol's green would be amazing against AI because they SHOULD be matching their color anytime there's a possible match that isn't a different colored 4/5 line match.

Am I wrong about this?

Comments

  • Pants1000
    Pants1000 Posts: 484 Mover and Shaker
    Options
    The AI considers all colors that power an ability equal and randomly chooses a match from those colors.  
  • jamesh
    jamesh Posts: 1,600 Chairperson of the Boards
    Options
    This article describes how it worked 1.5 years ago:

    http://www.demiurgestudios.com/engineering/a-worthy-opponent/

    I'm not sure if it has changed since then.

  • Pogo
    Pogo Posts: 185 Tile Toppler
    Options
    I've thought for a while that even if the AI doesn't work specifically to mess with the player, it would make sense for it to "choose" a power that it wants to cast, and always give that match color preference until it fires the power, then pick a new power/color, repeat.
  • jamesh
    jamesh Posts: 1,600 Chairperson of the Boards
    Options
    The algorithm is weighted towards matching colours that will charge up an ability, but a match four will take precedence, even if the colour is useless for the AI team.  If there are two matches that will charge abilities, it will pick one at random.

    Also, I don't think it is smart enough to notice that an ability is passive and doesn't actually need any AP.  You can see this when e.g. Luke Cage decides to match away his protect tile when there are other matches available.
  • Dragon_Nexus
    Dragon_Nexus Posts: 3,701 Chairperson of the Boards
    Options
    Tell you what, the enemy AI has grown very good at avoiding traps and Wasp's timer.

    I had a board with Spider Woman's traps on it. 4 matches would set one off and one match would do nothing. There were no other possibilities.

    They chose not to match the trap. So I had to. And the board reshuffled and hid them all 8I
  • Starfury
    Starfury Posts: 719 Critical Contributor
    edited May 2017
    Options
    Tell you what, the enemy AI has grown very good at avoiding traps and Wasp's timer.

    I had a board with Spider Woman's traps on it. 4 matches would set one off and one match would do nothing. There were no other possibilities.

    They chose not to match the trap. So I had to. And the board reshuffled and hid them all 8I
    Unbelievable! That couldn't happen more than ... like ... 1 in 5 times  :p
  • Smudge
    Smudge Posts: 562 Critical Contributor
    Options
    AI logic:

    1. Is there an in-line match-5 available?  Take it.  Otherwise...
    2. Is there a match-4 available?  Take it.  Otherwise...
    3. Have I used my Team-Up ability yet?  If not, pick randomly between my "strong" colors and TU matches... aka colors that any of my characters deal more match damage in or any TU match, passive powers or not.  Otherwise...
    4. Make a match-3 using one of my "strong" colors - colors that match up with the colors the character has higher match damage in (for Juggernaut as an example, make either a green, red, or black match or for Wasp, make a yellow, blue, or black match).  If I have used my Team-Up ability, TU matches are now lower priority than "strong" matches.  Otherwise...
    5. Pick any available match-3s available.  If I have used my Team-Up ability, include TU matches.
    Of course, it always feels like the AI is acting outside these boundaries, but this is consistent action for it.  Hopefully this is clear enough to follow.
  • Jaedenkaal
    Jaedenkaal Posts: 3,357 Chairperson of the Boards
    Options
    Smudge said:
    AI logic:

    1. Is there an in-line match-5 available?  Take it.  Otherwise...
    2. Is there a match-4 available?  Take it.  Otherwise...
    3. Have I used my Team-Up ability yet?  If not, pick randomly between my "strong" colors and TU matches... aka colors that any of my characters deal more match damage in or any TU match, passive powers or not.  Otherwise...
    4. Make a match-3 using one of my "strong" colors - colors that match up with the colors the character has higher match damage in (for Juggernaut as an example, make either a green, red, or black match or for Wasp, make a yellow, blue, or black match).  If I have used my Team-Up ability, TU matches are now lower priority than "strong" matches.  Otherwise...
    5. Pick any available match-3s available.  If I have used my Team-Up ability, include TU matches.
    Of course, it always feels like the AI is acting outside these boundaries, but this is consistent action for it.  Hopefully this is clear enough to follow.
    Not quite. The AI cannot tell the difference between a match-5 and match-4 (in-line match-5s just happen to be match-4s)
  • Smudge
    Smudge Posts: 562 Critical Contributor
    edited May 2017
    Options
    Smudge said:
    AI logic:

    1. Is there an in-line match-5 available?  Take it.  Otherwise...
    2. Is there a match-4 available?  Take it.  Otherwise...
    3. Have I used my Team-Up ability yet?  If not, pick randomly between my "strong" colors and TU matches... aka colors that any of my characters deal more match damage in or any TU match, passive powers or not.  Otherwise...
    4. Make a match-3 using one of my "strong" colors - colors that match up with the colors the character has higher match damage in (for Juggernaut as an example, make either a green, red, or black match or for Wasp, make a yellow, blue, or black match).  If I have used my Team-Up ability, TU matches are now lower priority than "strong" matches.  Otherwise...
    5. Pick any available match-3s available.  If I have used my Team-Up ability, include TU matches.
    Of course, it always feels like the AI is acting outside these boundaries, but this is consistent action for it.  Hopefully this is clear enough to follow.
    Not quite. The AI cannot tell the difference between a match-5 and match-4 (in-line match-5s just happen to be match-4s)
    Then why does it always prioritize the in-line match-5s over a match-4 when both are available?  I believe my statement is still correct.

    Edit: I could be mistaken of course, and I'll gladly admit when I'm wrong, but I have had numerous situations where both a match-4 and an in-line match-5 are available, and I have never seen the AI take the match-4.
  • Jaedenkaal
    Jaedenkaal Posts: 3,357 Chairperson of the Boards
    Options
    According to the article linked above, which is the best information we have, the AI only looks for match-4s. Sometimes it gets match-5s, but only because they are also match-4s.

    If the AI was programmed to look for match-5s, I would expect it to find T- and L- matches, as well; there's no reason to specifically exclude those if you're coding it to look for match-5s specifically, whereas it makes perfect sense if you're only programming it to look for match-4s.
  • Smudge
    Smudge Posts: 562 Critical Contributor
    Options
    Fair's fair.  I'm not admitting defeat on this point until I see the AI bypass a match-5 in-line in favor of a match-4 when both exist, however.  The article is almost 2 years old at this point; while I've always held it to be authoritative, to think that they haven't updated the code to prefer a match-5 in-line over a match-4 in that time is possible, but it seems unlikely to me.

    I fully understand that the AI doesn't "see" the T and L shapes since it only checks a single axis, but to update it to check from 1 tile behind to 2 tiles behind the swap for the total number of tiles matched in one line isn't much of a code change in nearly 2 years' time based on the code as described.
  • Straycat
    Straycat Posts: 963 Critical Contributor
    Options
    Smudge said:
    AI logic:

    1. Is there an in-line match-5 available?  Take it.  Otherwise...
    2. Is there a match-4 available?  Take it.  Otherwise...
    3. Have I used my Team-Up ability yet?  If not, pick randomly between my "strong" colors and TU matches... aka colors that any of my characters deal more match damage in or any TU match, passive powers or not.  Otherwise...
    4. Make a match-3 using one of my "strong" colors - colors that match up with the colors the character has higher match damage in (for Juggernaut as an example, make either a green, red, or black match or for Wasp, make a yellow, blue, or black match).  If I have used my Team-Up ability, TU matches are now lower priority than "strong" matches.  Otherwise...
    5. Pick any available match-3s available.  If I have used my Team-Up ability, include TU matches.
    Of course, it always feels like the AI is acting outside these boundaries, but this is consistent action for it.  Hopefully this is clear enough to follow.
    FWIW, this is my understanding of it too. I feel like the AI might also work in some sort of defense aspect, where it matches my strongest colors sometimes even if their strongest matches are available.
    Don't know about you guys, but I feel like I'm getting good at guessing what matches it will make. Especially when the Hulk or baby groot is playing for me.
  • MoosePrime
    MoosePrime Posts: 950 Critical Contributor
    Options
    The article jamesh linked above states:
    the criteria for selecting a swap are:
    1. Number of matched tiles in a straight line, up to 4
    2. Does the match charge an ability on the computer's team?
    That's it.  That's all the logic. The first rule takes precedence over the second [...] Sometimes the match-4 also results in a match‑5, but the computer doesn't “see” the match-5.
    I have never seen the AI take a match-4 when there is a match-5 available to it.

    I remember reading somewhere (it might have been that article, I'm not reading it again to look for this info) that the AI looks for the match that gives it the most AP, searching by rows and columns (thus ignoring T- and L-shaped matches), possibly ignoring the gain from the row clearing of a match-4. Therefore, since 5 in a row gives the most AP, it will choose that first, then a match-4, and lastly a match-3.
  • Jaedenkaal
    Jaedenkaal Posts: 3,357 Chairperson of the Boards
    Options
    The relevant part of the article is:

    "This scoring system means that the criteria for selecting a swap are:
    1. Number of matched tiles in a straight line, up to 4
    2. Does the match charge an ability on the computer's team?

    That's it.  That's all the logic.  "

  • MissChinch
    MissChinch Posts: 509 Critical Contributor
    Options
    We could probably suss this out... I'd always thought it was totally deterministic and used the same search pattern it does to resolve countdown tiles...   we just need someone less lazy than I am to post a board, AP totals and the move made (along with any powers in order of use)...   and we need a lot of them, probably something better addressed in a different forum altogether.
  • Ducky
    Ducky Posts: 2,255 Community Moderator
    Options
    *moving this over to Tips and Guides as it's actually useful information for people to know*
  • jamesh
    jamesh Posts: 1,600 Chairperson of the Boards
    Options
    According to the article linked above, which is the best information we have, the AI only looks for match-4s. Sometimes it gets match-5s, but only because they are also match-4s.
    One possibility that is consistent with the blog post is that a match-5 is detected as two separate match-4s, considering each end of the line.  This would double the chance of picking it over other match-4s on the board.