Advertisement

RPG AI and Fairness - player's characters stats public to AI

Started by August 13, 2017 03:07 AM
8 comments, last by Hebi 7 years, 3 months ago

What worries me is fairness, I don't want an AI with "god eyes".

In a first attempt, the AI wasn't smart at all. It has a set of rules, that could be customized per possible enemy formation, that makes the AI acts as it has personality. For example: Wolves had a 80% prob of using Bite and 20% of using Tackle.

Then I tried to make the AI do things with sense, by coding a reusable algorithm, then I can use rules to give different enemies formations different personalities, like this one is more raw damage focused and this other more status ailment focused. To achieve this I was trying to make the AI player to collect stats about the human player skills and characters by looking at the log, my game has a console that logs everything like most RPGs (think Baldur's Gate). An attack looks like this in the console:
 


Wolf uses Bite

Mina takes 34 points of damage

Mina uses Fire Ball

Wolf takes 200 points of damage

The AI player has a function, run(), that is triggered each time a character it controls is ready to act. Then it analyzes the log and collect stats to two tables. One with stats per skills, like how many times it was used and how many times it did hit or was dodged, so the AI player knows what skills are more effective again the human player's team. These skills stats are per target. The second table is for human player's character stats. The AI player is constantly trying to guess the armor, attack power, etc, the enemies have.

But coding that is quite difficult so I switched to a simpler method. I gave the AI player "god eyes". It has now full access to human player's stats, two tables aren't required anymore as the real character structure is accessible to the AI player. But the AI player pretends that it doesn't have "god eyes" by, for example, acting like it ignores a character armor again fire, until a fire attack finally hit that character, then a boolean flag is set, and the AI player can stop pretending it doesn't know the target exact armor again fire.

Currently, the AI player can assign one of two roles to the characters it controls. Attacker and Explorer. More will be developed, like Healer, Tank, etc. For now there are Attackers and Explorers.

These roles has nothing to do with character classes. They are only for the use of AI player.

Explorer: will try to hit different targets with different skills to "reveal" their stats, like dodge rate, armor again different types of damage. They must chose which skills to use by considering all skills of all characters in the team, but I'm still figuring the algorithm so right now they are random but at least they take care to not try things that they already tried on targets that they already hit. Explorers will switch to attackers at some time during a battle.

Attacker: will try to hit the targets that can be eliminated in less turns. When no stats are known they will chose own skills based on raw power, once the different types of armors are known to the AI, they will switch to skills that exploits this info, if such skills are available to them. Attackers will try different skills if a skill chosen based on raw power was halved by half or more and all enemy armors aren't known yet, but won't try for the best possible skill if one that isn't halved by as much as half its power is already known. Attackers may be lucky an select the best possible skill in the first attempt, but I expect a formation to work better if there are some explorers.

This system opens up interesting gameplay possibilities. If you let a wolf escape, the next pack may come already knowing your stats, and that implies that their attackers will take better decisions sooner as the AI requires now less exploration.

So, the description of an enemy formation that you can encounter during the game may be:
 


PackOfWolves1: {

    formation: ["wolf", null,   "wolf", null,   "wolf",

                null,   "wolf", null,   "wolf", null,

                null,   null,   null,   null,   null],

    openStatrategy: ["Explorer", null,      "Explorer", null,       "Explorer",

                     null,       "Attacker", null,      "Attacker", null,

                     null,       null,       null,      null,       null]

}

What do you think about these ideas? Was something similar tried before? Would you consider unfair an AI with "god eyes"?

Never programmed an AI, but as far as I know it's horribly complicated, and common practice is to "cheat" like you do.

I believe it is mure important to keep a random element in it, it is very boring if you always get the same set of enemies, and if they always make the same moves.

Random elements also hide somewhat that you're cheating, they have the effect of getting less precise knowledge than you really have.

Advertisement

So cheating may not be so uncommon. That gives me some confidence.

Same as you, I never programmed and AI, other than implementing A* for 2D isometric prototypes. Enemy actions were always based on some kind of roll. I want a more challenging AI this time, one that does things with sense other than roll for everything.

If a smart player confirmed that an enemy is vulnerable to fire, not exploiting that has no sense, and destroys the illusion you are playing again an intelligence. But, choosing always the same action pattern also destroy that illusion, it's true. I think then, that I need some kind of configurable parameters to make the AI vary behavior. If it looks like the AI is doing that to avoid being predictable then it's fine, I guess.

Basically don't try to make the game fun for the computer, try to make it fun for the player.

 

At least part of the joy of playing an RPG (at least for me) is wondering what the enemies going to do, and see'ing whether or not I get screwed over. If the AI is smart enough to always pick the best choice, they feel pointless and I wish I could autoplay the game at 100X the normal speed since I already know what's going to happen.

So this is a classic example of the blurry line between game design and game AI.

On the one hand, yes, you have a challenge presented here, in that the AI needs to operate under certain constraints - or at least perceived constraints.

The flip side of course is that this isn't really about how to build an AI, it's about how to design a compelling opponent in the first place.

Many AI decisions rest on game design foundations, as you're finding here. The trick is to solve the game design questions first and foremost, and then do whatever it takes to make the AI play the way you've designed it to.

As far as cheating goes, it's rampant in almost every game from an AI perspective. Sometimes it just doesn't make sense to simulate ignorance. Then again, sometimes it does - and this is back to game design. Stealth games without simulated ignorance would just be shooters, for just one example.

Ultimately you need to plan ahead from a perspective of "what should the gameplay feel like?" and work towards a suitable AI implementation from there.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

7 hours ago, conquestor3 said:

Basically don't try to make the game fun for the computer, try to make it fun for the player.

 

At least part of the joy of playing an RPG (at least for me) is wondering what the enemies going to do, and see'ing whether or not I get screwed over. If the AI is smart enough to always pick the best choice, they feel pointless and I wish I could autoplay the game at 100X the normal speed since I already know what's going to happen.

I agree, but that doesn't mean that the enemy must do completely random things. am I right? A certain algorithm is still needed.

 

4 hours ago, ApochPiQ said:

So this is a classic example of the blurry line between game design and game AI.

On the one hand, yes, you have a challenge presented here, in that the AI needs to operate under certain constraints - or at least perceived constraints.

The flip side of course is that this isn't really about how to build an AI, it's about how to design a compelling opponent in the first place.

Many AI decisions rest on game design foundations, as you're finding here. The trick is to solve the game design questions first and foremost, and then do whatever it takes to make the AI play the way you've designed it to.

As far as cheating goes, it's rampant in almost every game from an AI perspective. Sometimes it just doesn't make sense to simulate ignorance. Then again, sometimes it does - and this is back to game design. Stealth games without simulated ignorance would just be shooters, for just one example.

Ultimately you need to plan ahead from a perspective of "what should the gameplay feel like?" and work towards a suitable AI implementation from there.

Then I may be trying to solve a design problem, not AI problem. I definitely want the AI to be able to win, and the game to feel challenging, not impossible of-course. It is an RPG, no doubt, but I imagined battles as very tactical (think Baldur's Gate, where encounters aren't random and you can lose any of them).

Advertisement

One thing to remember is that players are really good at coming up with explanations for the NPC behaviors even when there isn't one. They will ascribe meaning and intent to what is pouring out of a random die roll. If you start with perfect knowledge and then fuzzy it up a bit, it may look just as plausible as your "exploration and learning" method... but with a lot less work.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

There is a balance to it, and the balance is so difficult it is often a big part of what goes in to regular patches for long-term games.

Balancing a game AI is tricky. Make a game too easy and players won't enjoy it. Make a game too difficult and players will hate it.  Generally there are options for different levels of difficulty, often each needs to be fine-tuned individually.  

Nobody wants to fight a perfect AI. A machine that always makes the ideal decisions, always follows the ideal path, always makes perfect shots, always makes the perfect corrections and countermoves to the player's actions.  On the other hand, nobody wants a stupid AI. A machine that always makes predictable decisions, that regularly makes the same mistakes, that never really plans ahead.

And as for hidden stuff, you as a player realize things about hidden stuff all the time.  You know the location of all the mines and resources. You have learned all the great positions for being a sniper, or the great positions for picking up tons of loot. That stuff isn't shown on the map, but it is something you have learned.  The AI isn't doing complex machine learning, nor is it likely to retain knowledge between levels. The AI also needs a bit of unpredictability so it doesn't follow the same path around the map every game, always falling for the same traps, always routing through the same funnels.  To compensate, most game AI's look at information that isn't shown to the player.

Further, understand there is more to randomized behavior than a dice roll.  There are many different distribution curves that can be used, various statistical models and probability options.  Numbers can be biased high or biased low. Odds can be heavily skewed. Distribution curves can be modified at runtime, adapting to skew right or left to automatically balance based on how the player is performing.  

 

Consider games like Mario Kart, the series has done well at dumbing-down the AI to make horrible mistakes when the player is trailing, or pushing the AI to perfect or near-perfect performance with full knowledge of the board when the player is performing exceptionally well.  Even if the player understands the computer is 'cheating' and occasionally loses to it, the players still adapt and play the game because it is fun and challenging.

15 hours ago, IADaveMark said:

One thing to remember is that players are really good at coming up with explanations for the NPC behaviors even when there isn't one. They will ascribe meaning and intent to what is pouring out of a random die roll. If you start with perfect knowledge and then fuzzy it up a bit, it may look just as plausible as your "exploration and learning" method... but with a lot less work.

I think I have seen players "filling the holes" with their imagination before. I remember all those fandom wikis trying to explain some characters behavior or tactics. Some are good at reverse engineering and do quite a good work figuring the rules behind some bosses attack patterns.

Am I over-thinking things?

11 hours ago, frob said:

There is a balance to it, and the balance is so difficult it is often a big part of what goes in to regular patches for long-term games.

Balancing a game AI is tricky. Make a game too easy and players won't enjoy it. Make a game too difficult and players will hate it.  Generally there are options for different levels of difficulty, often each needs to be fine-tuned individually.  

Nobody wants to fight a perfect AI. A machine that always makes the ideal decisions, always follows the ideal path, always makes perfect shots, always makes the perfect corrections and countermoves to the player's actions.  On the other hand, nobody wants a stupid AI. A machine that always makes predictable decisions, that regularly makes the same mistakes, that never really plans ahead.

And as for hidden stuff, you as a player realize things about hidden stuff all the time.  You know the location of all the mines and resources. You have learned all the great positions for being a sniper, or the great positions for picking up tons of loot. That stuff isn't shown on the map, but it is something you have learned.  The AI isn't doing complex machine learning, nor is it likely to retain knowledge between levels. The AI also needs a bit of unpredictability so it doesn't follow the same path around the map every game, always falling for the same traps, always routing through the same funnels.  To compensate, most game AI's look at information that isn't shown to the player.

Further, understand there is more to randomized behavior than a dice roll.  There are many different distribution curves that can be used, various statistical models and probability options.  Numbers can be biased high or biased low. Odds can be heavily skewed. Distribution curves can be modified at runtime, adapting to skew right or left to automatically balance based on how the player is performing.  

 

Consider games like Mario Kart, the series has done well at dumbing-down the AI to make horrible mistakes when the player is trailing, or pushing the AI to perfect or near-perfect performance with full knowledge of the board when the player is performing exceptionally well.  Even if the player understands the computer is 'cheating' and occasionally loses to it, the players still adapt and play the game because it is fun and challenging.

Mario Kart is also a good example of AI showing personality more than intelligence. I will think about it.

I know that roll a dice is not the only way of doing it. But random() and shuffle() are always good friends and I think a lot of RPG out there are just rolling dices. I always thought that turn based battle systems, or semi real-time ones (with focus and cooldown times that vary per skill) but usually with no free movement, are an attempt to make roll based AI possible. For example, in classic turn based JRPGs, you can roll once to select a target then again to select skill, discarding the ones that are a certain miss. I can't offer a concrete implementation as evidence, it's something I'm guessing.

When using a per formation roll based rules system, I decided that having to test all formations would require too much time, so I switched to a more complex but reusable AI code. The idea is that I don't need to teach the AI player how to win per every possible formation. The AI is able to scan all skills in its own characters and take decisions. I invented a function, that I called rdps, "Relative Damage Per Second", that the Attacker role uses to figure out the best skill. When the target armor is unknown, a middle class armor is assumed, when known the real value is used. Right now the AI doesn't understand status ailments, nor it knows how to counter them.

If I follow ApochPiQ advice and define the game design questions first, so far I have:

  • Enemies are able to win.
  • Enemies behavior doesn't look random.
  • Enemies behavior shows personality.
  • No per formation AI scripting/rule set.

Maybe the last is more an optimization and I should just remove it for now, and the third one is more a wish, or a plus if time constraints permit, than something present in my current implementation.

It may be out of place for an RPG, but bringing RTEs to the table, what I have observed is that most AIs have a finite set of possible strategies, some apply to many civilizations and some to a specific civilization, the strategy that will be used is decided at the start of a match, maybe for some titles it can be switched at the middle of the match.

I think a sense of personality may be given to the different formations/enemy species, by removing certain strategies from some formations and enforcing certain strategies to others. For example, a story based forced rule, maybe during a certain boss fight: "If Mina is in the player's formation, lock her as target of all Attackers until she dies at least once. Attackers are free to test for armors but not to change target".

I got from this thread that make the human player's character structures public to the AI isn't a bad practice nor something new.

This topic is closed to new replies.

Advertisement