AI in RPG's

Started by
9 comments, last by black_mage_s 22 years, 4 months ago
In an rpg with turn based combat, other than the basic control AI for NPC movement and that (which could be coded into the map data, is there any actual AI? Battles are just pretty much random commands. Should there be AI in battles then? How would this work?
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me
Advertisement
Hehehe i used to think that also, but to think of it, have you ever saw a monster in FF games cast heal when at full health? there is some logic ai, and for bosses (if have any) youll definetly want some ai. random is boring, not having always the same thing is good, but total random ai would make no sense, cast random spell, attacks at random, pfff.
Well, there''s as little or as much as you want, really. Since most monsters tend to exist only to be hacked to bits, you probably don''t need much more than to randomly pick an attack from a predetermined list. But you could get more sophisticated than this, if you liked...

One contrived example would be to use a state-space search in much the same way that chess programs and the like work. Example: for every move available to the NPC, calculate the resultant state (probably the updated stat levels of the NPCs and the PCs), and then for each of those moves, calculate the state that would arise from each of the PC''s possible moves in response, and then do all the NPC responses, etc. Repeat those 2 steps a few times... after you''ve gone to a certain depth, the system can analyse those states to see which one is most beneficial to the NPC, and make the move that started that off. You could do this with a simple depth first search, but also look up ''minimax'', and ''alpha-beta pruning'' which are additional concepts that help here (and which are beyond my ability to explain well ).

You could also build in some basic rule-based systems into the combat, so that certain moves are chosen when certain predicates are true. Taken to the extreme, this could be a fully-worked production system, full of logic rules and so on. But you''d probably only need a list of if-checks that contribute to scores for each attack, and then once all the if-checks have been tested, see which attack scores most highly and execute it.

I am not really an AI expert so I don''t know what else you could do, but really there''s scope for you to put in as much effort as you like in this area. There may be a point of diminishing returns (after all, it doesn''t matter how intelligent your foes are, if they''re designed to be dead in 2 minutes anyway), but there''s plenty that could be done.
Check out Baldurs Gate for RPG AI. It includes a script compiler that allows you to write scripts for your player characters. I assume they use the same system to control all creatures in the game. I wouldn''t call scripting AI, but their system does alow randomness in the choices that a creatures make.
"I am a pitbull on the pantleg of opportunity."George W. Bush
The suggestions have all been good so far. Really, the necessity of further AI is a question of design. Programming AI is just really a way to get the game creatures to do what you want them to at a given time.
quote:Original post by Davaris
Check out Baldurs Gate for RPG AI. It includes a script compiler that allows you to write scripts for your player characters. I assume they use the same system to control all creatures in the game. I wouldn''t call scripting AI, but their system does alow randomness in the choices that a creatures make.


isnt baldurs gate a real time rpg?
im talking turn based
"Luck is for people without skill."- Robert (I Want My Island)"Real men eat food that felt pain before it died."- Me
quote:Original post by black_mage_s
isnt baldurs gate a real time rpg?
im talking turn based

It is still the same idea, making it turn-based just makes it easier to program (and play).
Maybe not important, but reading this I remembered a boss in the old ''Secret of Mana'' game for the SNES. He''d always cast Wall on himself to reflect magic, and then would try to cure himself with Cure, which would bounce off of the wall every time and cure one of my guys instead. It was funny watching him do it over and over...

Anyway, back to your regularly scheduled programming.

------------------------------
Omnipotent_Q
"Natural Gas! It gives you... ideas!"
------------------------------Omnipotent_Q"Poor people are crazy. I'm eccentric."
Hello guys!

I was reading your posts and thought that I could join your discussion *gg*...
I have a suggestion for everyone that tries to simulate human behaviour (at least to a certain extent...).
You should reduce your NPC to a need-driven character. Just create a list of needs and how urgent they are, when they absolutely have to be fulfilled and when he/she/it could stop with fulfilling it.
Just take a simple example (its not in remote related to a combat, but I think it wouldn''t be too difficult to transform *gg*):
A monkey in a cage, lots of bananas laying around. Lets assume that he''s hungry. His need for food and a very high urgency (he would starve to death!) makes him go and search for anything to re-fill his stomach and reduce his need for nutrition.
After having found a banana, his need for food might be satisfied, but 5 minutes later he''ll be hungry again. No monkey would behave like that. He''d rather eat as much as he could get and stay in a satisfied state for a longer period.

The point is, you just have to implement a very easy model of your AI and then you can start to test and optimise it. Test and optimise it. I''m sure that you''ll find out that the behavior of your NPCs in a certain situation is kinda dull. So just check out your code and try to fix it. Of course your source will get longer and longer in the course of time, but that''s not the problem, I guess *gg*...

In a turn-based combat you could assign an aim to every of your NPCs that has to be reached, for example killing the player. Its a very easy form of the trigger methods. If a certain condition is "true", an action will be set. For example: If the health of an NPC gets a value < 25, he''ll try to retreat and save his own life.
But what if he just runs mad and only wants to do as much harm as possible?
Well, its your turn now.

I hope I could help you (at least in theory...you just have to understand your creatures and divide a complex behaviour into a lot of conditions)

Yours,

Indeterminatus

--si tacuisses, philosophus mansisses--
Indeterminatus--si tacuisses, philosophus mansisses--
quote:Original post by Indeterminatus
Hello guys!

I was reading your posts and thought that I could join your discussion *gg*...
I have a suggestion for everyone that tries to simulate human behaviour (at least to a certain extent...).
You should reduce your NPC to a need-driven character. Just create a list of needs and how urgent they are, when they absolutely have to be fulfilled and when he/she/it could stop with fulfilling it.
Just take a simple example (its not in remote related to a combat, but I think it wouldn''t be too difficult to transform *gg*):
A monkey in a cage, lots of bananas laying around. Lets assume that he''s hungry. His need for food and a very high urgency (he would starve to death!) makes him go and search for anything to re-fill his stomach and reduce his need for nutrition.
After having found a banana, his need for food might be satisfied, but 5 minutes later he''ll be hungry again. No monkey would behave like that. He''d rather eat as much as he could get and stay in a satisfied state for a longer period.

(remainder deleted)



This is more or less the AI model used in The Sims . Agents in that game have needs and desires, all of which have various ratings and which increase/decrease over time. Objects (say, the TV) decrease the Entertainmet Desire a bit the longer a Sim watches it. Eventually either something else happens in the room (somebody runs in on fire) or that particular need is satisfied and some other need or desire kicks in ("hmmm...now I''m hungry!"). I think the top 5 or so desires are prioritized and chosen from at random so the Sims are never quite predictable, adn how well each desire or need is satisfied feeds into the overall Sim "Happiness Factor".

Really great way of showing how basic AI techniques, such as the one Indeterminatus talks about above can make for some really excellent games.






Ferretman

ferretman@gameai.com
www.gameai.com

From the High Mountains of Colorado

Ferretman
ferretman@gameai.com
From the High Mountains of Colorado
GameAI.Com

This topic is closed to new replies.

Advertisement