AI Move Analysis (Split from 3 Events running)

Haha, what? I'm also interested if they've considered making the AI "less dumber-er" and if so, why or why not. Did Kamahl edit out some exceptionally whiny part of his post or is jozier just being an even worse jozier than jozier?

Mod edit (Riggy): Splitting discussion of AI stuff into it's own thread.
«1

Comments

  • gamar wrote:
    Haha, what? I'm also interested if they've considered making the AI "less dumber-er" and if so, why or why not. Did Kamahl edit out some exceptionally whiny part of his post or is jozier just being an even worse jozier than jozier?

    I'm guessing Jozier is salty that he lost to my team on defense in a two-pronged-attack attempt during the Hot Shot tournament. Or something. It's a legitimate issue with the game when the AI is constantly on easy mode, missing match-5's and poorly handling characters. Several hero choices are artificially sub-par options simply because the AI is completely pants-on-head with them, and other braindead options that don't require much timing or thought are just far superior. Thor, Black Panther, Punisher, etc, all come to mind, whereas timing-related heroes such as IM40, Human Torch, and Psylocke are weaker simply because of it).
  • Kamahl_FoK wrote:
    I'm guessing Jozier is salty that he lost to my team on defense in a two-pronged-attack attempt during the Hot Shot tournament. Or something. It's a legitimate issue with the game when the AI is constantly on easy mode, missing match-5's and poorly handling characters. Several hero choices are artificially sub-par options simply because the AI is completely pants-on-head with them, and other braindead options that don't require much timing or thought are just far superior. Thor, Black Panther, Punisher, etc, all come to mind, whereas timing-related heroes such as IM40, Human Torch, and Psylocke are weaker simply because of it).

    There's no point to talk about better AI unless you want to just retreat the moment an enemy has 5 blue AP when using Magneto. If you're not willing to put up with that, all the talk about 'stronger AI' is simply hypocrisy. Even with the 1 per turn limit you pretty much aren't going to escape a Magnetic Field lockdown, not to mention making a match 5 bypasses this limit because it's a new turn.

    This game purposely avoids teaching AI from doing anything outrageously cheap because it wouldn't be very fun to immediately lose a game when even a small amount of blue AP has been collected.
  • Phantron wrote:
    There's no point to talk about better AI unless you want to just retreat the moment an enemy has 5 blue AP when using Magneto. If you're not willing to put up with that, all the talk about 'stronger AI' is simply hypocrisy. Even with the 1 per turn limit you pretty much aren't going to escape a Magnetic Field lockdown, not to mention making a match 5 bypasses this limit because it's a new turn.

    This game purposely avoids teaching AI from doing anything outrageously cheap because it wouldn't be very fun to immediately lose a game when even a small amount of blue AP has been collected.


    I don't see how it would be a pointless effort. I'm not saying they should code Magneto to always match 5 on defense - as a software designer myself, that would be a nightmare trying to analyze the array and then make sure the AI makes the move. The way the AI handles Magneto's blue is honestly fine - the only thing I would consider tweaking on it is that it always would target 2 of the enemy's special tiles. The easiest implementation I feel that they could do with their currently operating code would be to just match up colors of abilities that would place a countdown / strike / etc tile of that same color. IM40 is ready to cast Recharge? If an obvious match of yellow exists (as in something that wouldn't have to cascade), instead make that match and don't cast recharge. Else, if no yellow matches exist, cast recharge and go on as normal. I'd like to say you also chose the one skill in the game that, with an advanced AI, the game would become unbearable. No single other skill would be anywhere near that obnoxious. The fact that I've seen Hood target two corner spots before is a sign that the AI needs just a bit of attention. Hell, even Bagman will target his own team's countdown tiles, which.. well, it's Bagman and it was a simulator event, I can't chalk that one up entirely to "bad" AI, as it seems to be working as intended there.
  • It's not going to be hard for the AI to always make a match 5 if possible with Magneto. There are at most 64 X 63 / 2 = 2016 ways to place 2 blue tiles and that's easily within the brute force range even if you made no attempt to optimize it. In practice you can also just look for placing blue tiles within 2 tiles of another blue tile (any further than that and you can't make a match out of it). So why not teach the AI to always make a match 4/5 with Magneto? Because it'd really suck to watch the AI spam you to death like that.

    They can probably put a behavior like: "Place tile close/away to (color/special/whatever)". For example Magneto's blue would be 'place tile close to blue', while Captain America's red would be "place tile away from red". That way it wouldn't be outright stupid as would be the case if you actually taught the AI how to use Magnetic Field, but it'd still make them used more intelligently. But until the game is more balanced, there's only so much you can do with the AI, because you really don't want to play against an AI that actually knows how to use Spiderman or Magneto right now.
  • I'd like you to find me a way to hastily allow the game to process where the blue tiles would be placed. One of the most obnoxious things I've encountered in games as of late was in Duels of the Planeswalkers, where the game just waits for the AI to figure out what to do (and it can sometimes take a while). MPQ doesn't have that issue, thankfully, as it just cranks out one move after another with very little processing. I'm fine with that, and willing to keep the AI that 'dumb'. It's why I'm suggesting fixes the way I am, as they don't require extensive loops beyond what the game already has going for it. If you start incorporating complex algorithms, you're going to get some serious complaints during Lightning Rounds where every second is precious. This problem would be a larger factor in lower-grade phones. Just because you can brute force code it definitely doesn't mean that is how you should do it. If you'd like to see what I'm talking about, go do some ProjectEuler problems. They already have methods in place to just see what color matches the AI can make - a simple example is where you're only fighting Juggernaut, it will almost always match available red and green matches. Simply checking for those matches and then determining if or if not to use an ability would really help out a lot of characters.

    You're also ignoring the part where the AI can only do one instance of an ability per turn. It won't be able to spam you to death, and there is a huge likelihood that it will ignore the crit tile it just made so you can get a juicy hit in. Or match blue to clear out another potential match 5.

    Edit: Just stop focusing on Magneto's blue. He doesn't need help on defense, his purple has that situation covered very nicely, alongside his red... and blue still helps soften damage. The point of all this is to make less-used characters more appealing in the long haul so they don't pull off derp moves, like "Oh boy I have 6 green with HT and there are 3 green matches available, time to use it early and then match it, effectively wasting 5 AP!"
  • Kamahl_FoK wrote:
    I'd like you to find me a way to hastily allow the game to process where the blue tiles would be placed
    There are a number of algorithms to manipulate arrays efficiently. And while I give you props for referencing Project Euler, the scale for a brute force solution there is many times higher than here. Take the very naive approach below:

    1) For each cell in the top 7x7 grid (ignore the last row and column), check for color. If it's not blue, advance the counter and repeat
    2) If it's blue, check if the adjacent cell or the cell beyond that is blue. If one is, you have your first location for a tile drop.
    3) Then check the adjacent cell going down and the cell below that for blue. Same as above.
    4) Continue on from where you left off for the 2nd match.
    Refinements could be made to avoid hitting inappropriate tiles as well as creating 4 and 5 matches if desired.

    With only 49 initial data points, you're making up to 4 checks per node for just under 200 comparisons per loop. That is trivial to begin with, ignoring the fact that you'd be able to stop much earlier than that in most scenarios (as soon as you find 2 spots for a blue).
  • I'm taking it to PM since this is getting heavily off track, but tl;dr that will only work for straight lines and maybe crosses, wording is confusing. Misses far too many other options.
  • Kamahl_FoK wrote:
    I'm taking it to PM since this is getting heavily off track, but tl;dr that will only work for straight lines and maybe crosses, wording is confusing. Misses far too many other options.


    I believe that's why he referred to it as a naive approach.
  • Kamahl_FoK wrote:
    I'm taking it to PM since this is getting heavily off track, but tl;dr that will only work for straight lines and maybe crosses, wording is confusing. Misses far too many other options.


    I believe that's why he referred to it as a naive approach.
    We're discussing it. Rather than focus on one character's ability, we should be looking at the AI knowing what patterns can make a match 4 or 5 in general and then abstracting out the specific ability being used to create those patterns. Worse than Mag's blue is BWGS' purple. It's so sad to see the AI make a single match when he could have gotten 13+ green AP. Additionally, with Mags, we as humans can situationally decide if creating a 4-in-a-row with 1 tile, and setting up a match 4 in another blue clump is better than getting a crit tile out of making a single match 5. That's not something that can be easily programmed.

    I hated the time I spent working with Prolog, but I honestly think that a rules-based language is the only way to go here. Not that I'd ever want to write rules for complex multi-dimensional array manipulation, but hey, pay me enough, and I'll give you a godlike AI.
  • I think we're still waaaay below the effort-intelligence curve though

    In both algorithm design and processing power we don't need to design a ideal-playing chessmaster here. For example just having something that goes "make a match 5, if no match 5, find the 3x2 or 2x3 block with the most blues in it. place that bad boy somewhere in there" would be trivial to implement and would go a long way
  • gamar wrote:
    make a match 5, if no match 5, find the 3x2 or 2x3 block with the most blues in it
    Well, apparently detailed discussions in PMs are less fun than sharing our geekiness for all to see in this thread. So with that in mind...

    128782761376408095.jpg

    If you arrange the board in 4x3 (or 3x4) grids, you would need to have at least 3 blue tiles with a finite and relatively small number of patterns and permutations of that pattern, i.e. all the inverses and mirrors. From there, it's fairly trivial to compare the pattern in the current grid to a repository of known patterns and store where the optimal placements would be, with possible additional checks for things like special tiles, incidental matches outside the 4x3 grid, etc.

    More difficult would be to program what is ideal within a given scenario. It's far more difficult to program scenarios and cover them all intelligently. In some scenarios, making a match 3 to kill Psylocke's or M-Hawkeye's blue countdown may be the right play. But if there's a different match-5 play that will flat out kill that character, it's obviously the superior play. Unless... another character's non-blue countdown is about to go off, and you could set up and then make a match 4 that will kill that other player thus removing their countdown.

    Heuristics and goals are not things easily expressed in the traditional if-then-else logic. That looping mechanic kills performance, which is why I was thinking of a rules based language.
  • Keep in mind you don't have to find the perfect move. In fact playing this game would totally suck if the AI never made a mistake. It's by design supposed to mess up on purpose.

    We can simply develop some general rules that are attached to abilities like:

    Place tile near (color)
    Place tile away (color)
    Place tile over (enemy special)
    Do not place tile over (your special)

    For example Magneto's blue under this would be "Place tile over enemy special, near blue, and not over your own special". Captain America would be "Place tile over enemy special, away from red, and not over your own special". This wouldn't guaranteed a perfect move, but it should be better than randomly guessing a tile. Gravity Warp can be "Place tile near color of enemy special tile color".

    Flame Jet can be used as having a shadow skill that costs 5 more AP than Flame Jet. It'll make the usual check to see if it should save the AP. This will increase the chance you'll have some green AP to burn after you placed it.
  • IceIX
    IceIX ADMINISTRATORS Posts: 4,322 Site Admin
    Riggy wrote:
    More difficult would be to program what is ideal within a given scenario. It's far more difficult to program scenarios and cover them all intelligently. In some scenarios, making a match 3 to kill Psylocke's or M-Hawkeye's blue countdown may be the right play. But if there's a different match-5 play that will flat out kill that character, it's obviously the superior play. Unless... another character's non-blue countdown is about to go off, and you could set up and then make a match 4 that will kill that other player thus removing their countdown.

    Heuristics and goals are not things easily expressed in the traditional if-then-else logic. That looping mechanic kills performance, which is why I was thinking of a rules based language.
    PQ1 actually worked more off this style of AI than MPQ does. Every spell and item had its own script that the AI ran through each turn to decide what to do. Each piece of the puzzle would deliver a weight which would be placed against the other weights for each other spell and the AI would go with the most intelligent choice based on that weighting. This was doable as the number of things any given spell or item could do was pretty well set, so it was easy to have each item check for each of the other possibilities. MPQ is far more complex and gaining more complexity as engineers add more things abilities can do so it's less scalable like that.
  • Riggy wrote:
    Heuristics and goals are not things easily expressed in the traditional if-then-else logic. That looping mechanic kills performance, which is why I was thinking of a rules based language.

    But my point is that even complex rules and algorithms aren't actually necessary at the point where the game is now - it may take a lot of effort to design something that will pick the correct move 100% but it could (and usually does) take much less effort to design "naive" behaviors that are very likely to pick the correct move, or at least much more likely than the AI currently does
  • mags1587
    mags1587 Posts: 1,020 Chairperson of the Boards
    GSBW's purple would be improved by leaps and bounds if the AI just chose a random tile and then placed the rest of her green in the available spots next to that random tile.
  • mags1587 wrote:
    GSBW's purple would be improved by leaps and bounds if the AI just chose a random tile and then placed the rest of her green in the available spots next to that random tile.

    If she could manage her purple, she'd go from being a complete joke on defense to being a top tier one. "See green? Make the biggest cross match you can on it, GOGOGO". Next turn, probably hit a sniper rifle shot.
  • IceIX wrote:
    Riggy wrote:
    More difficult would be to program what is ideal within a given scenario. It's far more difficult to program scenarios and cover them all intelligently. In some scenarios, making a match 3 to kill Psylocke's or M-Hawkeye's blue countdown may be the right play. But if there's a different match-5 play that will flat out kill that character, it's obviously the superior play. Unless... another character's non-blue countdown is about to go off, and you could set up and then make a match 4 that will kill that other player thus removing their countdown.

    Heuristics and goals are not things easily expressed in the traditional if-then-else logic. That looping mechanic kills performance, which is why I was thinking of a rules based language.
    PQ1 actually worked more off this style of AI than MPQ does. Every spell and item had its own script that the AI ran through each turn to decide what to do. Each piece of the puzzle would deliver a weight which would be placed against the other weights for each other spell and the AI would go with the most intelligent choice based on that weighting. This was doable as the number of things any given spell or item could do was pretty well set, so it was easy to have each item check for each of the other possibilities. MPQ is far more complex and gaining more complexity as engineers add more things abilities can do so it's less scalable like that.
    But the actual pool of scripts inside of a given fight is fairly static. At most, you'd see 3 heroes x 3 abilities + 3 enemies x 3 abilities + (some arbitrary number of core game mechanics, such as match 4/5, post-drop look ahead). So while the number of scripts overall is definitely increasing, it seems like that number is static for a given combat.

    Is it possible to encapsulate those scripts and then for a given combat pass only the relevant ones into the "weighting engine"? Seems like a simple (naive icon_e_smile.gif) approach to keep the engine from getting bogged down.
  • IceIX
    IceIX ADMINISTRATORS Posts: 4,322 Site Admin
    Riggy wrote:
    But the actual pool of scripts inside of a given fight is fairly static. At most, you'd see 3 heroes x 3 abilities + 3 enemies x 3 abilities + (some arbitrary number of core game mechanics, such as match 4/5, post-drop look ahead). So while the number of scripts overall is definitely increasing, it seems like that number is static for a given combat.

    Is it possible to encapsulate those scripts and then for a given combat pass only the relevant ones into the "weighting engine"? Seems like a simple (naive icon_e_smile.gif) approach to keep the engine from getting bogged down.
    Sure, that's somewhat trivial, yes. The problem lies in backwards compatibility for all abilities that affects weighting. To give an example of something that just got put in (but nothing in-game uses it yet), there is now the ability for tiles to have their strength affected. So a Strike tile could go from 20-25 while in combat. That's great and adds a new wrinkle to gameplay. We can put a script in saying that this new ability that makes a tile stronger has X weight per tile it would affect and that would work fine for that ability. But we'd also have to go through and change each Strike tile generating ability to take into account the fact that this new ability exists if we want the AI to handle it properly. After all, it's a better deal to use Strike tiles when something else makes use of it as opposed to other times. Each new mechanic adds that layer on to each ability.

    It's not an impossible or unsolveable problem by any means, simply one that's a recipe for accidental oversights and the bugs attendant with them. Which would of course re-enact its little drama every time a mechanic was introduced.
  • IceIX wrote:
    Riggy wrote:
    But the actual pool of scripts inside of a given fight is fairly static. At most, you'd see 3 heroes x 3 abilities + 3 enemies x 3 abilities + (some arbitrary number of core game mechanics, such as match 4/5, post-drop look ahead). So while the number of scripts overall is definitely increasing, it seems like that number is static for a given combat.

    Is it possible to encapsulate those scripts and then for a given combat pass only the relevant ones into the "weighting engine"? Seems like a simple (naive icon_e_smile.gif) approach to keep the engine from getting bogged down.
    Sure, that's somewhat trivial, yes. The problem lies in backwards compatibility for all abilities that affects weighting. To give an example of something that just got put in (but nothing in-game uses it yet), there is now the ability for tiles to have their strength affected. So a Strike tile could go from 20-25 while in combat. That's great and adds a new wrinkle to gameplay. We can put a script in saying that this new ability that makes a tile stronger has X weight per tile it would affect and that would work fine for that ability. But we'd also have to go through and change each Strike tile generating ability to take into account the fact that this new ability exists if we want the AI to handle it properly. After all, it's a better deal to use Strike tiles when something else makes use of it as opposed to other times. Each new mechanic adds that layer on to each ability.

    It's not an impossible or unsolveable problem by any means, simply one that's a recipe for accidental oversights and the bugs attendant with them. Which would of course re-enact its little drama every time a mechanic was introduced.
    So when you say that PQ1 works more off this style of AI than MPQ does, it sounds like you're saying that MPQ is intended to evolve in that direction, it's just MPQ has more complicated abilities than what PQ1 had. The games definitely go longer and have more tactical depth than it's predecessor, so it has higher to climb, so to speak. But that is the intention?

    You know, if you guys need some help, my consulting fees are reasonable. icon_e_smile.gif Oh, wait, I see you're hiring... oh, wait, we're expecting twins in just under 2 months. Nevermind. icon_e_biggrin.gif
  • IceIX wrote:
    It's not an impossible or unsolveable problem by any means, simply one that's a recipe for accidental oversights and the bugs attendant with them. Which would of course re-enact its little drama every time a mechanic was introduced.

    And that is why the gods gave us property based test scaffoldings. With randomly generated data, and a set of scripts per character, it's not really all that difficult to ask the machine to double check move quality without accidental oversights. I build an actor-based distributed application that is very prone to small changes here and there affecting system stability, but this kind of testing allows us to have a very short release process.

    I don't know which specific toolset you guys use to build MPQ, but I'd be surprised if there was not something you could add to replicate this kind of thing.