Suggestion Technical Suggestions for Possible AI Improvement

Discussion in 'Suggestions' started by Beefster, Mar 24, 2019.

  1. Beefster

    Beefster Poptop Tamer

    I don't know details about the Wargroove engine and I don't know the nitty gritty details on the AI, but there is a pretty common consensus that, at least for Arcade Mode, the AI is... bad. It sorta ends up making things uninteresting when the only way the AI stands a chance with a massive material advantage. Since most people have complained about the campaign being too difficult, I don't think that's necessarily a good place for an improved AI. Maybe if some of the advantages were trimmed, but not for the default difficulty.

    I wouldn't say I'm an expert at AI, but I have done a number of minor AI projects and have a background in computer science with an unofficial emphasis in AI/Machine Learning. Basically I just took all the AI classes my university offered, did some AI research, and made some bots. I'm no dummy about AI and I understand the challenges we're dealing with here from a technical standpoint.

    Any sort of tree search is infeasible. The combinatorial explosion is far too big to even do one round of adversarial search. There is no way the AI can make grandmaster decisions without practically putting players to sleep while the AI thinks (maybe with deep learning and a million CPU hours of training on some supercomputing cluster. Maybe.) The AI has to take pretty massive shortcuts. That's just reality, especially if this game is to run well on weak devices.

    High level ideas like "don't move to a location were the commander can be killed in one turn" don't exactly work for the aforementioned combinatorial explosion issue.

    So let's take a look at the most glaring issues with the AI:
    • It doesn't make use of transports. At all.
    • It has no concept of "contested property" and makes little effort to rush for critical property, only capturing properties that happen to be in range on a given turn.
    • There is no guarantee that ranged units will attack before others, leading to taking more damage than necessary
    • Recruiting doesn't seem to be terribly reactive to enemy forces. It seems that it prefers to build the most expensive units possible and rarely creates units to counter incoming units.
    • Ranged units are often left unprotected
    • Commanders will often wander directly into danger
    Let's first address the issue of making recruiting more reactive. I propose the following algorithm:
    • Count units of each type for enemies and allies.
    • Multiply this by a matrix mapping current unit counts on both sides to ideal unit counts on your own side.
      • This matrix would be precomputed and could be extracted from machine learning, tuned by hand, or some combination of the two
      • Some key things to check for:
        • enemy air units should increase the ideal counts of mages and ballistas (At least +0.8 for each, probably)
        • enemy knights should increase the ideal count of pikes
        • enemy ballistas and trebs should increase the ideal count of knights (+1 or so, probably) and to a lesser extent, dogs, and mages
        • allied pikes and dogs should slightly increase the count of other pikes and dogs (between +0.2 and +0.5, probably)
    • Layer on other vectors for current states such as turn number, money, and income. There could also be a standard composition used as a template, layered unconditionally. Tuning required.
    • Subtract your current unit counts from the resulting vector.
    • Filter out negative values and the unit types that cannot currently be recruited
    • Using the resulting values as weights, randomly determine the unit to recruit. This could potentially be nonlinear: perhaps squaring the values before using them as weights might be appropriate. This will require experimentation and tuning.
    • In the case that all weights are 0, use the current recruiting algorithm.
    Note that this doesn't take into account where units are. This should reduce complexity considerably while still being reasonably reactive.

    To make units attack in a more sensible order, simply sort them before taking actions. I suggest something like this ordering:
    • Units able to capture, from highest HP to lowest, except for commander (defer action to later phase if not in capturing range)
    • Ranged Units
    • "Melee" units, except for commander
    • Commander
    • Transports
    Units within each group could be sorted by farthest from own HQ first by Manhattan distance. If there are multiple HQs for some reason, use the closest one or pick one arbitrarily (cheap operation either way).

    (assuming some things about the AI system here) To protect ranged units, increase the AI's reward/desirability for placing melee units adjacent to ranged units. To make the commander less likely to walk into danger, massively increase the punishment/avoidance factor for squares that are in attacking range of golems and dragons or in the crit range of knights and trebs.

    To make use of transports, it needs long term goals. It is most likely too computationally expensive to determine where a unit might be needed, so using them for reinforcement logistics probably won't work. However, transports could at least be used to rush for contested property. It's a bit trickier to work out a good algorithm here, but here's my proposal:
    • For each neutral property that is not farther (by Manhattan distance) from your HQ than an opponent's HQ, assign it to a non-commander unit that can capture it. If no units are available for this assignment, defer until the next turn.
    • Each unit with capturing goals, instead of its normal behavior, will move toward its next goal until all goals are fulfilled
    • Capturers will prioritize properties farthest-first.
    • Other properties that happen to be on the way to the goal will be captured even if the journey is slowed down.
      Last edited: Mar 24, 2019
      Fadedsun likes this.

    Share This Page