Monster thinking in an action rpg
#1 Members - Reputation: 182
Posted 23 August 2012 - 11:30 AM
i'm developing an action rpg with some University colleagues. Actually we're on monsters' ai design and we would like to implement a sort of "utility-based ai" so we have a "thinker" that assigns a numeric value on all the monster's decisions and we choose the highest (or the most appropriate, depending on monster's iq) and assign it in a monster's collection of decisions (like a goal-driven design pattern) .
One solution we found, is to write a mathematical formula for each decision, with all the important parameters for evaluation (so for a spell-decision we might have mp,distance from player, player's hp etc). This formula has also coefficients representing some of monster's behaviour (in this way we can alterate formulas by changing coefficients).
Now...
I've read also how fuzzy logic works; I was fashinated by it and by the many ways of expansion it has. I was wondering how we could use this technique to give our ai more semplicity, i mean create evaluations with fuzzy rules as IF player_far AND mp_high AND hp_high THEN veryDesiderable (for a spell having an high casting-time and consume high mp) and then defuzzificate it. In this way it's also simple to create a monster behaviour for example creating ad-hoc rules for every monster's iq category. But is it correct using fuzzy logic in a game with many parameters like an rpg? Is there a way of merging this two techniques? Are there better ai design techniques for evaluating monster's chooses ? Thanks
#2 Members - Reputation: 5899
Posted 23 August 2012 - 05:40 PM
If you are thinking about writing a formula to evaluate which spell to cast, you are probably going about this the wrong way. Think of all the possible actions the monster might take in the current situation (including spells, attacks, taking cover, calling for reinforcements, running away, asking for mercy and crying for mommy), and then think of what makes each action desirable or not desirable. Put it down in numbers, and you are golden.
#3 Moderators - Reputation: 7793
Posted 23 August 2012 - 06:09 PM
Hello everybody,
i'm developing an action rpg with some University colleagues. Actually we're on monsters' ai design and we would like to implement a sort of "utility-based ai" so we have a "thinker" that assigns a numeric value on all the monster's decisions and we choose the highest (or the most appropriate, depending on monster's iq) and assign it in a monster's collection of decisions (like a goal-driven design pattern) .
One solution we found, is to write a mathematical formula for each decision, with all the important parameters for evaluation (so for a spell-decision we might have mp,distance from player, player's hp etc). This formula has also coefficients representing some of monster's behaviour (in this way we can alterate formulas by changing coefficients).
This much all sounds great!
Now...
I've read also how fuzzy logic works; I was fashinated by it and by the many ways of expansion it has. I was wondering how we could use this technique to give our ai more semplicity, i mean create evaluations with fuzzy rules as IF player_far AND mp_high AND hp_high THEN veryDesiderable (for a spell having an high casting-time and consume high mp) and then defuzzificate it. In this way it's also simple to create a monster behaviour for example creating ad-hoc rules for every monster's iq category. But is it correct using fuzzy logic in a game with many parameters like an rpg? Is there a way of merging this two techniques? Are there better ai design techniques for evaluating monster's chooses ? Thanks
This is where I think you've gotten off track a bit.
A utility system does not need fuzzy logic, and in fact fuzzy logic is going to make your system harder to figure out and fine-tune. The problem with FL is that it can act very unpredictably and unintuitively, which is not going to help you get your project done ;-)
The power of utility systems is that you can just write those simple formulae, and with a good graphing tool, you can analyze exactly how the agents will behave. You can also map the behavior directly back into numbers, and use that to find when and where you need to tweak your formulae a bit.
I would suggest going ahead with your initial idea. It sounds like you're very close to getting a good utility-based system conceptualized, and that's a great start. I don't think you'll find it hard to manage once you get into it, and my gut is that you'll benefit a lot by keeping it as simple and straightforward as possible.
Best of luck and keep us posted on your progress! :-)
[Work - ArenaNet] [Epoch Language] [Scribblings] [Journal - peek into my shattered mind]
#4 Members - Reputation: 182
Posted 23 August 2012 - 06:10 PM
#5 Moderators - Reputation: 1874
Posted 23 August 2012 - 06:39 PM
What all of this can be combined to create is the concept of "expected utility" -- that is, what can we expect to be the total payoff of this action? By comparing the expected utility of all the possible actions, we can see which one is going to be the optimal one simply by picking the highest valued one.
If you want, I wrote an article for Game Developer Magazine in January of 2011 that is reprinted here. That article covers some quick techniques for converting concrete data into conceptual values. For a ton more information on creating utility-based systems, there might be a link to a book around here that is pretty much specifically dedicated to doing mathematics for behaviors in game AI.
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI
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!"
#6 Members - Reputation: 206
Posted 23 August 2012 - 10:53 PM
a) I am an instinctual sort of creature, like an alligator or maybe an ogre, and in the clutch I tend to rely upon particular strategies. These strategies will most likely be widely applicable and crudely effective (having gotten me this far in life) but due to their generality may be exploitable. So as an alligator if I smell a hero crossing my swamp I likely try and take a bite out of him. As an Ogre, I put my club to use. There is probably not going to be much decision-making involved for an instinctual sort of creature.
b) I am a sneaky, crafty, or cunning sort of monster like a goblin shaman or a street urchin. I am not very intelligent, but I may come up with some unexpected way to approach a confrontation. In my view, as the cunning monster I'm not so much comparing a bunch of options and deciding on the cleverest one, rather I'm just more likely to try something unorthodox rather than always rely on a standard approach. So, again I don't need complex decision making, what I really need is some mechanism for simulating creativity (a simple solution might be a lot of prescripted behaviors, that are randomly selected from so as to appear emergent). The key to my cleverness as a goblin shaman isn't that I pick the best possible move, rather, that I tend to try unexpected things, potentially gaining an advantage.
c) I am a normal, competent, human-equivalent intelligent being. This one is pretty complex, because there is such a range of cognitive behavior in humans, let alone fantasy races. However, I would say some good approximations are certainly possible. For one thing, depending on how your system works and whether it can handle this, you might consider the fact that the most important (and often the only) decision that a typical soldier makes in a brief conflict is whether to fight, and a lot of the time only one side makes even that decision. So, an orc hunter might put some effort into sizing up his opponent and deciding whether he feels lucky, but once he's charged in, he probably isn't spending a lot of time deciding who to swing his axe at. I would say, there are a few decisions (whether to fight, whether to run, maybe others?) that could benefit from a weighted statistical model *or* a fuzzy approach, but honestly for these kinds of monsters the choice of which action to take should probably be really simple.
d) I am a highly intelligent being, such as a wizard, a battlefield commander, an elder dragon, or whatever. For this category, I am somewhat divided. Traditionally, games tend to assign the least flexible, and least intelligent cognitive simulations (almost always a simple, scripted pattern) to ostensibly the most intelligent type of enemy. I understand why, as games have to maintain a certain level of fun, and often have to follow certain conventions to do so, but I still dislike it. If I am a seasoned, veteran troop commander, I am not entering a battle without a plan that stands a high chance of success (unless I'm in a desert badum-bum-tsh!). So, for these kinds of monsters, I could see employing a fairly elaborate cognitive model, perhaps even a perfectly rational algorithmic model. But, if you plan on keeping with RPG tradition, then actually you don't even need that for these guys, just some state machines and scripts will do it.
I hope this helps. I'm not disagreeing with anything else said, just offering my take on how certain monsters could think in battle. I probably over-simplified the human-types, because there is really a whole lot that you could do there. Good luck.
#7 Members - Reputation: 1006
Posted 24 August 2012 - 03:46 AM
- Weight of tendency to keep doing the same thing.
- Weight of preferred actions.
- Depth of plan to explore.
#9 Members - Reputation: 182
Posted 26 August 2012 - 03:25 AM
#10 Members - Reputation: 1006
Posted 26 August 2012 - 04:41 AM
#11 Members - Reputation: 182
Posted 26 August 2012 - 06:18 AM
#12 Moderators - Reputation: 1874
Posted 26 August 2012 - 10:16 AM
And what about artificial neural networks?
Don't. Just don't.
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI
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!"
#13 Members - Reputation: 182
Posted 26 August 2012 - 01:50 PM
Ok, i trust you, but they seem so fascinating and suitable for evaluating monsters' life expectancy (basing also on their experience)! I'll try to study in deep how they work.. I'm at the beginning of video game AI study and I love it, but there are so many informations and design methods that it isn't easy taking decisions about it!Don't. Just don't.
#14 Members - Reputation: 5899
Posted 26 August 2012 - 09:28 PM
Ok, i trust you, but they seem so fascinating and suitable for evaluating monsters' life expectancy (basing also on their experience)! I'll try to study in deep how they work.. I'm at the beginning of video game AI study and I love it, but there are so many informations and design methods that it isn't easy taking decisions about it!
Since it is such a big field, you should heed the warnings and not waste time in irrelevant methods like neural networks and genetic programming. If you want to use your time well, learn about finite state machines, behavior trees and other scripting options, planners and utility-based systems, because all of those things are truly useful when programming game AI.
#15 Members - Reputation: 182
Posted 27 August 2012 - 01:33 AM
Understood. Thanks again!Since it is such a big field, you should heed the warnings and not waste time in irrelevant methods like neural networks and genetic programming. If you want to use your time well, learn about finite state machines, behavior trees and other scripting options, planners and utility-based systems, because all of those things are truly useful when programming game AI.
#16 Members - Reputation: 487
Posted 27 August 2012 - 05:27 AM
Edited by Net Gnome, 27 August 2012 - 05:27 AM.
#17 Members - Reputation: 182
Posted 27 August 2012 - 06:02 AM
NN and Genetics will just slow you down, since all they will provide you is what you're going to do during gameplay testing anyway i.e., tweaking your algorithm's variables and structure. You're smarter already than the best NNs and Genetics out there, so they will provide you almost no benefit. Also, HIGHLY recommend getting Dave Mark's book on behavioral mathematics for game AI (link in his signature), almost all of your answers are contained in there
Thank you, I'm purchasing that book on amazon :-)
#18 Members - Reputation: 206
Posted 28 August 2012 - 10:28 AM
You're smarter already than the best NNs and Genetics out there
I don't think I agree with these sentiments, but the advice is good. Neural networks and genetic algorithms are among the most promising subjects in AI research. They are the only techniques with a good likelihood of producing real emergent behavior or machine learning. However, most implementations *are* unpredictable, training intensive, and unlikely to provide a whole lot of benefit in a typical rpg.not waste time in irrelevant methods like neural networks and genetic programming.
I would say if you want to look at something more advanced than finite state machines or scripts, the most fertile ground would be production systems. These are kind of (not really) like a large collection of interrelated if-then-else statements. The idea is to build up a collection of productions (sometimes called rules) that represent all of the 'mental' considerations of the AI.
In my opinion, this type of representation is much more authentic than a real-time plastic method like a GA or NN. Consider, during the course of a battle, it is pretty unlikely that a monster will be learning and incorporating a whole lot. It seems a bit more realistic to say that a monster or enemy has a lot of knowledge and experience (in the form of productions) that it brings into the battle, but that set of knowledge doesn't necessarily change a whole lot.
#19 Moderators - Reputation: 1874
Posted 28 August 2012 - 02:56 PM
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI
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!"
#20 Members - Reputation: 182
Posted 29 August 2012 - 04:02 AM
I don't think I agree with these sentiments, but the advice is good. Neural networks and genetic algorithms are among the most promising subjects in AI research. They are the only techniques with a good likelihood of producing real emergent behavior or machine learning. However, most implementations *are* unpredictable, training intensive, and unlikely to provide a whole lot of benefit in a typical rpg.
I would say if you want to look at something more advanced than finite state machines or scripts, the most fertile ground would be production systems. These are kind of (not really) like a large collection of interrelated if-then-else statements. The idea is to build up a collection of productions (sometimes called rules) that represent all of the 'mental' considerations of the AI.
In my opinion, this type of representation is much more authentic than a real-time plastic method like a GA or NN. Consider, during the course of a battle, it is pretty unlikely that a monster will be learning and incorporating a whole lot. It seems a bit more realistic to say that a monster or enemy has a lot of knowledge and experience (in the form of productions) that it brings into the battle, but that set of knowledge doesn't necessarily change a whole lot.
Thank you for your post. Different ideas are only good things!






