Game Development Community

learning AI partner

by Jeremie "Moogy" Laflamme · in Technical Issues · 03/12/2003 (9:39 am) · 7 replies

Has anyone seen any AI that can adapte to a partners tactics.

I have a squad of ships and the AI will adapte it self more an more to the player piloting style.

any ideas on this

#1
08/15/2003 (2:54 pm)
You might try some kind of genetic algo or something to try and match the player's style. I'm not sure though.
#2
08/15/2003 (3:12 pm)
This sounds like it could be very difficult. What kind of things would the A.I. pick up on? It wouldn't be too hard to make an A.I. squad which learns and copies the player style, but if they are squad ships, you would want them to learn how to best complement the player rather then imitate them.

You could have some general A.I tactics, and you could alternate between them. Record the results as well as the tactic used. The most successful over a few battles, would probably be the tactic which best compliments the player. This is a very basic way of doing it, and not particularily intelligent, but give the A.I. enough preset tactics, and it would seem like the A.I. is playing well with the player and adapting to them, as you drop the tactics which perform the poorest.
#3
08/15/2003 (7:47 pm)
You can also add in some delays and other minor characteristics to individual tactics for the AI. When the AI first flies with the player they can use some pretty stock actions with an average delay, as they spend more time with the player they get "better" by responding quicker to the player's own actions, even if they really don't learn anything this will create the impression of them getting better and adapting to the player. This can also apply to other AI pilots, not just the player, so you can effectively get unit skills in addition to individual skills.

You can also set the degree to which the AI pilots will pay attention to the player, making it so new pilots may not even notice what the player is doing and simply follow them rather than manuvering/acting with them. Or perhaps the converse, a rookie pilot that is so fixated on the player that they don't even notice the enemy on their own 6. Another characteristic that can be developed is the rookie AI pilot that is always either getting in the players way or not watching where they shoot and hitting the player. Yet another would be an AI pilot that breaks away from the player and acts completely independantly. You may even be able to get away with simple "skill" modifiers like these rather than actually having them learn.

There are a number of methods for getting opponent AI to "learn" from and adapt to the player as an enemy, many of these should also work well in this application. A good example is what William mentioned above, they have a "database" of actions and a history of their attempts, they can then weigh them by their success ratio when choosing their actions.

Edit: I have to go dig up some of my old "team" AI code, then I'll add some more, I can't remember exactly what I did there to get the teamates to work with the player better.
#4
08/18/2003 (12:52 am)
I would suggest something like this:

1. Write some code to analyze the players style of playing. This would mainly involve gathering various statistics, which can be used in the next step.
2. Classify the playing style. Use the gathered statistics to map the player into one (or possibly more?) of several pre-determined playing styles.
3. Have the players team members use the same playing style. This will probably involve writing specific ai control-code for each style of play.

So this would mean, that if the player is always flying directly head-on towards the enemies, firing like crazy (that's the gathered statistics, step 1), we can classify his style of being "Aggresive" (step 2). This will make his team members pick the "Aggressive" style of play (step 3), which might tell them to do their best to stay close to the player and watch his back and sides.
#5
08/18/2003 (8:42 am)
Just out of curiosity, how exactly would you 'map' the player to a style? What gameplay statistics would you use to do this? If you could accurately map the player's style from some statistics, then this would be a better way to go, rather than flicking through tactics to find the player's style through trial-and-error. The only problem I can think of, is gathering enough statistics to make an accurate guess. I suppose each class of player style would have parameters set for its desired statistics, ands then you try to best fit what you have into one if these classes.

I like Keith's suggestions though, it could provide AI that seems intelligent, while not actually being that hard to implement, and not being too intensive CPU-wise.
#6
08/18/2003 (11:05 am)
It's kind of hard to give a generic answer to this. I've found that in most cases, developing good AI requires a very thorough understanding of the game it is to be used in, and how that game plays. In order to define how to "map the player to a style", we need to know which styles are likely to be common in the game. If we have those styles defined, we could analyze them and determine what makes them different. From this, we could determine which statistics we need to track, and which values of the statistics that map to each different style. The hard part in this process is gaining that thorough understanding of the game and how it will be played.
#7
08/18/2003 (12:45 pm)
A lot of strategy (Realtime and Turn-based) games use style classes for players, such as "builder" and "warmonger" so you may be able to find some good examples of how to assign a player to a specific style or class by searching for strategy game AI. How to actually apply it to your own game will depend on what you feel is important as well as what fits well in the game. You can get some of this from very basic formulas, such as shots fired per second, shots fired per target and a hits to shots ratio. Using just those figures you could roughly label the player as trigger happy or cautious. In a flight game you could also figure in basic statistics such as min/max/average g's, min/max/average speed and time spent using afterburner/thruster. From there you could classify the player as a speed demon, old lady or average pilot. You could go on with this until you have several characteristics defined for the player, for example a trigger-happy speed demon.

Looking back through my old AI code, even the team stuff, I had allways focused more on AI players that had unique characteristics rather than ones that actually learned from the player. The player(s) affected a number of global variables with their actions and those variables were used by the team and opponent AI to weigh some of their decisions. For example, if the player was doing a lot of sneaking around the global "noise" variable was low and that encouraged the team AI players to sneak around and the opponent AI was more relaxed. Several globals were taken into account in the process. Using the same example above, if the noise was low and the carnage was high the opponents would not be relaxed, instead they would be nervous and edgy. So in essence, they really didn't learn from the play, but they reacted well to the players actions.