Archived

This topic is now archived and is closed to further replies.

black_mage_s

AI in RPG's

Recommended Posts

black_mage_s    103
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Kylotan    10011
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.

Share this post


Link to post
Share on other sites
Davaris    118
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.

Share this post


Link to post
Share on other sites
EtherTide    122
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.

Share this post


Link to post
Share on other sites
black_mage_s    103
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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).

Share this post


Link to post
Share on other sites
Omnipotent_Q    122
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!"

Share this post


Link to post
Share on other sites
Indeterminatus    129
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--

Share this post


Link to post
Share on other sites
Ferretman    276
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

Share this post


Link to post
Share on other sites
Kylotan    10011
Of course, that post uses the word "reduce", implying that this is a simpler method... you still need to model each need, how it is measured, how it will be satisfied and then produce the 'known' routines to satisfy the needs.

Also, the original poster was referring mainly to combat by the looks of it, and I'm not sure how appropriate a needs-based system would be for that situation. Do you really need anything more complex than: IF health < cowardice_threshold THEN run away? And so on. I'm not saying you don't: but I'd like to see some examples.

And anyway: from a psychological point of view, combat makes many needs temporarily irrelevant (hunger, shelter, etc) and other needs are so obvious that representing them is implicit in the system (killing opponent, avoiding death). So a system that only really represents 2 or 3 needs is pretty simple.

Edited by - Kylotan on November 22, 2001 9:42:45 PM

Share this post


Link to post
Share on other sites