Archived

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

Nazrix

NPC AI in RPGs (2)

Recommended Posts

Nazrix    307
I started another thread cause that was getting cut off for some reason...at least for me it was dwarfsoft, finally someone is thinking upon the same lines as I do I couldn't agree w/ you more about the fact that NPCs should move around, and have an agenda. In the RPG I'm currently making, I have it so that each NPC has a schedule of where they're supposed to be at different hours of the day. Plus, that schedule can be changed dynamically as the game progresses. So, instead of quests and encounters happening at fixed points (like in Baulder's Gate) they happen more by coincidence as in real life. You may be just walking along and an NPC happens to walk by, and some sort of quest could arise. I like the idea of NPCs sharing information. That would add a lot of realism. Edited by - Nazrix on 7/1/00 2:44:05 PM

Share this post


Link to post
Share on other sites
dwarfsoft    1229
I think your post went through into NPC AI in RPGs the first time... Pity you cant read it tho... I would like to see your implementation of this, my RPG is going to be fully based around the NPC''s if I can actually do what I want that is


-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft

Share this post


Link to post
Share on other sites
Ingenu    1629
Happy to see that I''m not the only one having designed such NPCs.
Implementation not done yet for me

Maybe we could write this NPC engine/calendar all together and use it in our respective projects ?

Tell me if you agree.

You can mail me (check the icon on the top of my post)

(oh... Forget to mention I use C/C++, so I would write this ''module'' in c++. I hope you''re using C++ too.)


-* So many things to do, so few time to spend *-

Share this post


Link to post
Share on other sites
Altmann    122
What exactly do you mean by calendar : goal-driven ? If it is the case, it all goes back to deduction, my friend

Anyway, of course there is a need for passing messages. Since I''m basically a Unix programmer, could anyone summarize me what windows-style message passing means ?

Be reading you,
David

Share this post


Link to post
Share on other sites
Nazrix    307
Yeah, I don''t know why I can''t see the rest of that post. I''m at work and I tried 2 different computers to no avail...

Ingenu, that''s a pretty good idea. I use C++, yes. The system I''m using now is pretty crude, but it works.

Every NPC has an x and y value that tells them where to be at each hour. So, once the hour changes it scans through every NPC and compares their current x & y to the x & y they''re supposed to be and moves them there. It holds everything in arrays. If I want to change where they go, I just change the values of those arrays.

Crude, but effective.



"The road of excess leads to the palace of wisdom." --William Blake

Share this post


Link to post
Share on other sites
Ingenu    1629
Altmann : I mean that a NPC is following a schedule(r?).
Like anyone in the real world, he got things to do.
I don't know what's the meaning of 'windows-style message passing'.


The basic system will provide wandering NPC.
(Unlike in FF where the same people are always at the exact same location doing nothing and repeating the same sentences over and over.)

You define a one week long schedule for each NPC, and it'll follow it, with possible change.

As a second step, I would like to enhance the NPC AI by 'giving' the NPC needs and solutions to 'not need' anymore.

This will lead to a dynamic coherent world.
Need : Food.
Solution : Go to a food shop. Buy some food.
(Pathfinding...)

[Using a need/asnwer system may create a really nice world]

We'll need a bit more thinking and planning about that before working on it
Design is essential.
Happy to see that we'll work together Nazrix.




Edited by - Ingenu on July 3, 2000 12:23:17 PM

Share this post


Link to post
Share on other sites
Nazrix    307
Ingenu,
That's an interesting idea to include a need-based schedule as well.

So far, I was mostly thinking about each day the NPC goes to work for a while then goes to the tavern for lunch...that sort of thing. And of course story-based schedules where the schedules changed because of the story

I'm suprised more RPGs don't incorporate this sort of thing as it doesn't seem too hard to do...

It would be nice to work together, Ingenu, and share some ideas

"The road of excess leads to the palace of wisdom." --William Blake

Edited by - Nazrix on July 3, 2000 1:42:47 PM

Share this post


Link to post
Share on other sites
Altmann    122
Ok, got it.
(Windows-style was something written by dwarfsoft on the previous thread)

My goal-driven approach is basically your "need"/"not need" idea.

How do I "not need" eating ?
Either :
* go buy some bread
* go buy some meat
* ...

How do I "go buy" xxx ?
Either :
* if xxx is bread, go to the nearest bread shop
* go to the nearest supermarket

How do I "go to" the nearest yyy ?
Invoke path planner
...

Basically, this is a fuzzy expert system.

P.S. : If anybody is interested, I am mixing C++ and Java.

Share this post


Link to post
Share on other sites
Ingenu    1629
Altmann, I think that you're welcome if you want to work on the subject with us.

We mustn't be too many cause it become hard to manage many people but a little commity often generate great ideas.

Mixing JAVA and C++ ?
What exactly do you want to do ?
Scripting with JAVA in a C++ program ?

Nazrix : We'll have to design for a while before writting a single line of code.
(Well it's how I work, I hope it's ok)

Conceptual design, problems/solutions, code design (objects...), code programming.




Edited by - Ingenu on July 3, 2000 4:44:52 PM

Share this post


Link to post
Share on other sites
dwarfsoft    1229
I use C++, so that would cover that. I am basing my whole game around the NPC''s interaction with each other, and deduction (in my opinion) is not going to be the be-all and end-all of it. Message based (like I said before) is probably going to be enough to cover it. But you may also have to assume that a message could be a visual message like being seen with someone. I am sure that I can get great functionality out of a message based system, provided that I design it right



-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft

Share this post


Link to post
Share on other sites
MikeD    158
Dwarfsoft, I think the key idea for that is having nice simple methods that become complex through massive emergent behaviour. I don''t think it''s necessary to have any high level functionality just a small number of interacting rules that give the impression of complex relationships.

I''ve always loved the idea that a new NPC could be born with certain set concepts because of their background so that each time they meet any other agent in the game (player or NPC) they start up a new node in a relational database based on their preconceptions. i.e. a dwarf might be initially wary of elves but absolutely hate goblins, so that as soon as the dwarf met a goblin they would try to kill it or at least stay away from it. Every time the dwarf interacts with another agent their relationship would be updated based on events that occur (I think an events handler is a more accurate name than a message handler), obviously in the case of a goblin it would take less for the dwarf to be pushed over the edge and kill the goblin than it would for them to become lifelong friends. However, if the dwarf liked one goblin it would probably make them less hateful of other goblins (though not by much) and, maybe, in turn, having another dwarf see them being friends might affect their general concept of goblins. Either that or make them hate that dwarf for being a traitor.

If this sounds complex then try breaking it down into simple rules that make sense in your social context. People really aren''t that complicated you know ;-)

(Not that I''m suggesting you weren''t doing all of this anyway, I just thought I''d put my ideas down here for imminent flaming)

Mike

Share this post


Link to post
Share on other sites
Geta    136
quote:
Original post by MikeD

I think the key idea for that is having nice simple methods that become complex through massive emergent behaviour.



I really agree with this point, and I think its important for all of us trying to build complex NPC or agent behavior to keep this point at the forefront of our design considerations.

Look at nature, and one can see numerous examples of complex behavior that emerges from simple (yet unrelated) rules. Craig Reynolds'' work with flocking aptly demostrates how such behavior can be codified.

In a FPS, I was able to get NPCs to flank their opponents in a firefight, simply by seeking a non-LOS path (ie. a path where a node was given a bonus if it was not in the LOS of the opponent) to the opponent. From an observation point of view, it looked like the NPCs were actively flanking, but they really were not.

I think this key point that MikeD raises, means that one should focus on identifying the simple rules, and not the complex behavior.

Eric

Share this post


Link to post
Share on other sites
Kylotan    9860
quote:
Original post by Geta

In a FPS, I was able to get NPCs to flank their opponents in a firefight, simply by seeking a non-LOS path (ie. a path where a node was given a bonus if it was not in the LOS of the opponent) to the opponent. From an observation point of view, it looked like the NPCs were actively flanking, but they really were not.



Yes! Lots of people forget that the lovely part in a path-finding routine that calculates the ''cost'' is not restricted to physical obstacles! As you stated, enemy line-of-sight is a good one for certain units. Territory ownership might be another, to avoid violating treaties, or you could generate an influence map and use that to keep non-combat units in ''safe'' areas, etc etc.

Share this post


Link to post
Share on other sites
Kylotan    9860
quote:
Original post by Nazrix

Every NPC has an x and y value that tells them where to be at each hour. So, once the hour changes it scans through every NPC and compares their current x & y to the x & y they''re supposed to be and moves them there. It holds everything in arrays. If I want to change where they go, I just change the values of those arrays.

Crude, but effective.


Ultima VII does this. Although I think it is in 3hr slots, not hourly slots.

http://www.udic.org/ftpud/unsorted/schedule.txt

Share this post


Link to post
Share on other sites
MikeD    158
For my next job I''m going to wait until I find a company that''s writing a real time strategy game. As Kylotan says there''s so much that can be done with simple pathfinding it''s unbelievable.

Just giving the path finding function for a harvester a set of heuristics that demote nodes on a partial path if they are near a firefight would be fantastic. Giving different troops specific commands as to where they should or should not go on the map by dragging a no-go box over certain areas or setting a level of agressiveness is a simple improvement that would take away so much of the frustration of current RTS games.

Btw Geta, I like what you said about flanking troops in an FPS but I partially disagree. If the plan was to flank then the actions to carry out that plan for real people in a real situation would be, move to a specific point while keeping out of their LOS. Perhaps you didn''t have the planning layer but that doesn''t mean they weren''t actually flanking :-)

Mike

Share this post


Link to post
Share on other sites
Ingenu    1629
Here''s my quick thoughts on the subjects.
Might be a long post, but will try to avoid that.

AI Schedule/engine:

Concept:
Giving the world dynamic and living pattern by using actives NPC using a Schedule and/or a need based system.

Methods:
-Weekly based Schedule (Updated every hour).
(Weekly to avoid seeing to much repetition in the NPC activities)
-Optionaly using a need based system.
-Setting up a NPC MAnager to avoid consuming to much CPU cycles managinf off screen NPC.
-Creating a sector updater, to update the NPC status when entering a sector.
(the engine will compute what the NPC have to do, and compute the result of the need based system)
-Schedule modification following the result of the need based system.

OR
-A weekly schedule with a need system.
(In this one, the Schedule is only used as a general behaviour thing)

OR
-Need based only system.
(But giving the NPC a way to solve his problem, a job, and various other stuff)

TODO list:
-Basic need based system with simple needs (food, drink...)
-Not to forget special behaviour (in case of fire what to do..)
-Basic Schedukle system
(I think Nazrix already have done such a thing )

Discussion on the concept, methods is welcome
(It''s time to sleep here in FRANCE, so see you tomorrow)






-* So many things to do, so few time to spend *-

Share this post


Link to post
Share on other sites
Geta    136
quote:
Original post by MikeD

Btw Geta, I like what you said about flanking troops in an FPS but I partially disagree. If the plan was to flank then the actions to carry out that plan for real people in a real situation would be, move to a specific point while keeping out of their LOS. Perhaps you didn''t have the planning layer but that doesn''t mean they weren''t actually flanking :-)

Mike


A "planning layer" is a whole different issue, than generating complex behavior from simple rules (ie. emergent behavior), which was my point by including this example.

In the case of the FPS mentioned, there was no plan for the NPCs to flank their opponents. There was only a plan to survive any firefight, neutralize/kill their opponents, and move on with the mission, and accomplish its goals. The "enabling" of the non-LOS effect to pathfinding was the extent of the "flanking" plan in that particular game.

Eric

Share this post


Link to post
Share on other sites
Nazrix    307
quote:
Original post by Kylotan

Ultima VII does this. Although I think it is in 3hr slots, not hourly slots.




Cool...I'm glad to hear other games have used that method. It gives the idea some validity for me. I really need to play the recent Ultima games sometime soon


"The road of excess leads to the palace of wisdom." --William Blake

Edited by - Nazrix on July 5, 2000 1:55:41 AM

Share this post


Link to post
Share on other sites
Ingenu    1629
My need based system is based on my economics lessons at university

There was a needs/satisfaction explanation.
The system was basic but efficient, so very good for a computer game.

I think this system is/will be used in Black & White.

Nazrix and dwarfsoft, what about my previous post ?
Which system do you prefer ?


-* So many things to do, so few time to spend *-

Share this post


Link to post
Share on other sites
dwarfsoft    1229
I have not really considered the economics side, but if you are trying to simulate communtication, then the easiest way I can think of is messaging. There are probably other ways that this could be handled, but I still think that if you are going to have communication simulation then you need to have some kind of messaging. Deduction should not cover it.

I have heard a lot of good ideas from this group, I hope that you guys can give me a few more to try and stick in my game . I still have to get the UI up and running, but it is looking good .



-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft

Share this post


Link to post
Share on other sites
dwarfsoft    1229
quote:
Original post by Ingenu

Nazrix and dwarfsoft, what about my previous post ?
Which system do you prefer ?



Personally I would go with a TODO list which points out the bare minimum that should be done by the NPC (therefore eliminating any slackers! [like me ]) and then I would put a schdule layer over it. That way the tasks are updated, but there is always a skeleton to fall back on. The TODO would also allow optimisations for NPC''s that aren''t likely to be seen much, they don''t require a high priority Schedule layer.

This is a fairly basic look at a complicated system, but I think the systems that you pointed out are all good, but for different reasons and different purposes.

Maybe we should work on creating a system that will work generically so that it can be of benefit to others. I believe we have the brains here in this forum so benefiting ourselves as well as others might be a way to go.

PS. It was my birthday on Mon, I am now legal! No more waiting for that booze or those clubs


-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft

Share this post


Link to post
Share on other sites
Ingenu    1629
Messaging system is a requirement.

I think that the Schedule will be the basic behaviour guidelines and the need system will slightly modify the NPC activities.

NPC can be differentiated through modifying their ''reaction'' or needs level.
This may allow a NPC to finich is job before going to lunch, or to be often thirsty

I think that a ''module'' using the schedule/needs system will result in a very good dynamic fake world.

As I already said, I would like to work on that in C++.
This module would be available to anyone contributing to it, and maybe released under GNU licence

dwarfsoft : happy birthday ! (ok late but better late than never)

Still thinkking about it.
I''ll write a list of basic needs.


-* So many things to do, so few time to spend *-

Share this post


Link to post
Share on other sites
dwarfsoft    1229
Thanx for the thanx there Ingenu.

I personally prefer C++ and am using VC++ at the moment (however I much prefered Borland.. Bloody M$ is taking over even the most sacred areas ). But I would be very willing to contribute time and code to this module. I can''t possibly stay away from classes at the moment, they just keep becoming more and more useful .

I think that a quite complex model could be achieved using a layering system similar to the protocols for Inet and the DirectX/GDI/Hardware layers that Win uses (or OpenGL/Software Emulation/Hardware for those who like to be compatable ).

A simple model could indeed be achieved through the methods that you describe and I also agree that some quite respectable realism would result.

Goddamn! It is getting late and sleep is affecting my thought, I have forgotten what I was going to say... I''ll post again if I remember .

I have been recruiting other NPC activists from around the internet forums, including Gamasutra, Xgames3d and tdc (as soon as I can bloody well log onto the site!). They all have a link to this forum, so we may be getting some visitors here (hopefully because I like hearing the ideas that come through here!)

Cheers all!

-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft

Share this post


Link to post
Share on other sites
Ingenu    1629
Here''s alink to a doc about the AIModule.

I don''t have included basic needs now, but would do in two or three hours

I use C++ and I love class.
(In fact I love JAVA )
Layers might be interesting, don''t know how to implement this.


-* So many things to do, so few time to spend *-

Share this post


Link to post
Share on other sites
dwarfsoft    1229
Layer system would hold many benefits (ie. you could switch them on or off to optimise certain NPC''s for certain tasks) but it would need to be thoroughly designed to be as efficient as possible (M$ Internet protocol layers were so screwed, that after an overhaul they yeilded 50% faster results ).

I am not truly sure as to how a layering system would work or how to properly implement one, but (based on multiple inheritance) you should be able to create sub-layers with one super-layer that handles them all. Use initialisations with pointers and descriptors of what that layer is, and the layer talks to the super-layer, which distributes appropriate instructions to either the other layers or to the NPC (because I am tired, I haven''t though much on this ).

I realise that this is a very high level and theoretical view of the idea, but it could yeild some benefits


-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
and our eGroup:
http://www.egroups.com/group/dwarfsoft

Share this post


Link to post
Share on other sites