#### Archived

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

# RPG NPC AI, Scheduling and Needs...

This topic is 6238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Here''s a new threads following the idea of the NPC AI in RPG (2. The topic begin to be too long to me Here''s a summary of the system: Base Schedule for any NPC. Schedule overriden by the need based system. Need system can be extended to reflect a little more than needs. (Or solutions to suppress them) AI Module written in C++. (So OO) Module since it might be used to create a DLL, or to be integrated in a game code. I''ll do the list of the basic needs. (I know I must do it since some days now ) -* So many things to do, so little time to spend. *-

##### Share on other sites
As a slight augmentation to a simple schedule, which would generally be fairly restrictive. How about a list of tasks and an associated heuristic as to when they should be carried out. Each task in a standard schedule has a list of actions which are necessary for it''s completion. For a baker a list of tasks might be something like, obtain wood, obtain ingredients, bake bread, go to pub, buy personal groceries from market etc. Each of these tasks being split up into ordered actions i.e. bake bread consists of, light wood in oven, mix dough, place dough in oven, let cook for 20 minutes.
The tasks could be ordered by a heuristic that places a value on carrying out each task, the lower the number the loaves in the shop the higher the heuristic for baking more loaves, the less food in the bakers larder the more likely they are to go to the market.
Some tasks can be more definately ordered by overriding areas of the heuristic. If it''s 5 am bake bread, if it''s past 3pm don''t.

As long as you keep it simple you can''t go wrong.
(HA)

Mike

##### Share on other sites
I repeat what I just posted on the previous thread : try not to lock yourself into DLLs.

Another thing is that you might not want to do everything in C++ in the first place. You might prefer prototyping in Java first. And I would definitely prefer using a garbage collector.

Anyway, there is a need for an Agent and a Message construct. In my opinion, it could look a bit like :

Message is

• A priority
• A "too late" delay, possibly infinite, for forgettable messages
• A "thinking thread" id, for grouping messages
• An id
• An emitter
• A range of receivers (a base class in a semantic network ?)
• Some kind of type information
• A message-dependent content of variable type (void* ?)

Agent can

• Post messages (invoked by itself)
• Think (invoked by itself, or by some kind of time-sharing facility)

What else ?

##### Share on other sites
After reading Mikes post I was thinking about how you would go about constructing a task based approach. With pre-requisites for other tasks, you could create a threaded list that requires a lower thread to have been completed before it can be started. This way the NPC could be able to switch between different threads (and different tasks) making it appear like they are multitasking.

The NPC might have a thread like so:
Buy grain -> make flour -> "flour" flag is set
Get urn -> Get Water [in urn] -> get bowl -> pour water in bowl -> "water" flag is set

flour\____> pour flour in bowl -> Make bread
water/

This kind of is threaded both ways (I realised this after starting the example). The flour and the water tasks are BOTH required to make the bread. I am not sure how this could be programmed, but Linked Lists do come to mind . Basically, the NPC might "decide" to go and get an urn, then go and get some water, then take a detour and buy some grain and then go and make some flour, go get a bowl, pour the water and the flour in the bowl. Make the bread.

Just some more food for though.

-Chris Bennett ("Insanity" of Dwarfsoft)

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

##### Share on other sites
Not to criticize but ... seems to me like an awfully complicated way to describe Petri Nets.

Ok, I wanted to criticize

##### Share on other sites

I do think there must be an easier way to do the trick.
Don''t forget we''ll need to manage dozens to thousands of NPC with that system, so that must be fast and efficient.

And easy to programm and debug

-* So many things to do, so little time to spend. *-

##### Share on other sites
I am not a bitter man, and criticism does tend to offer better results in the long run, provided it is constructive .

Personally, I have not touched Neural Networks or Genetic Algorithms. I have heard of some very interesting stuff about them. Do you know of any good sites on the net that could be useful?

Anyways, I am sure there has to be an easier way. But we don''t really need to be considering thousands of NPC''s just yet. One NPC would be an achievement. Diablo II keeps chunking up too much with NPC''s running around the screen (and getting killed ) so I rather not use them . I guess I am a hard man to please when it comes to NPC''s.

I am thinking of posting up a summary of our Posts on my site. Just a thought at the moment, but I need some material on my site. What do you think?

-Chris Bennett ("Insanity" of Dwarfsoft)

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

##### Share on other sites
http://www.gameai.com

( How concise can i get )

Give me one more medicated peaceful moment.
~ (V)^|) |<é!t|-| ~
ERROR: Your beta-version of Life1.0 has expired. Please upgrade to the full version. All important social functions will be disabled from now on.

##### Share on other sites
Here are some pointers to academic sites that might be of interest:

Autonomous Agents:

Planning:

Scheduling:

A game AI research project that covers it all:
http://www.ai-center.com/projects/excalibur/

Best,
Alex

Edited by - Alexander Nareyek on July 11, 2000 11:39:41 AM

##### Share on other sites
are you people actually programming this stuff yet? or just theorizing? i''d love to play anything you guys have!

anyways
dos: stay forever!

scheduling. I never played the sims or anything but i guess this is sorta like it
what about npc emotion? And dialogue? I mean depending ont he type of game and setting, what if I(the player) wants to keep an npc?(join party, whatever) how are npc''s gonna remember stuff?

I remember the goblin and dwarves thing somebody mentioned.

I was playing with a sims type game but never made it(no skills)
where all the npc''s had ratings of everybody and thought good or bad of somebody in specific area, like trust, love, and some others and dialogue would be by events, npc''s remembered events
and passed (told,gossiped) them along to others

heard, seen, experienced.
who what where when idea. and that also affected ratings and their todo list. they had priority as in they wouldn''t go do something for the player unless his rating met the requirments...

I wish i could but now that i see these posts it makes me think my idea wasn''t as dumb.

just offering ideas that''s all

##### Share on other sites
again.

About the elves and goblins not liking each other, maybe that''s just a stereotype(int he game) and once they get to know each other that will change?

About npc''s and food. (I''m basing my thoughts on final fantasy type games) Maybe it''s not that person that has the food, but the house that has the food, so people living in the same house can split chores, such as wife gets this, husband gets that, while the kids just play all day, who they play with and where they shop (if multiple shops) is determined by the rating of the shop?

Well i''m not gonna post till i see good or bad replys...bye

##### Share on other sites
I love the idea (expressed earlier) of NPCs being scheduled, and if anyone cares to hear my opinion, I have another interesting idea regarding messaging between NPCs. I''d say one would just want to represent speech as a universal communication that is recieved by all nearby NPCs and the player: An NPC who wanted to buy bread or whatever, would walk into a bread shop, and approach the counter and say, "I''d like to buy some raisin bread." Which would be broadcast to nearby players and NPCs.

The baker would respond via speech, such as, "That''ll be 4 gil," or "Sorry, I sold the last raisin bread a little while ago," or whatever, and the hungry NPC would get the idea and give money to him, upon which the baker would give him the bread. With messages and transactions being broadcast that way, NPCs could react to things happening around them. If another NPC is just outside and the door is open, she may hear the man buying bread and think, "Hmm, now that you mention it, I could really go for a loaf of bread right about now." Essentially my thought is that we need to make NPCs react more *visibly* to one another than just passing silent messages and objects from one NPC to another with little more than perhaps a "hungryman buys a loaf of bread."

Think of it this way: you don''t just walk into a bakery, hand some money to the guy behind the counter, and take a loaf of bread. (at least, I don''t.) More often, you walk in and if there''s not many people there, he says, "Hi, how can I help you?" Or if the room is packed, he might not even notice until you come to the end of the line. It''s always a dialogue rather than a plain old exchange, and if you tell the baker "gee, my dog died and I''m really depressed," someone else may overhear you and comment on it or be affected by it.

I doubt this makes any sense really, because I''m not sure what I''m saying myself, but owell. O;.

+------------------------------------------------
| Thp :: Threep2742@worldnet.att.net
| "Nature uses only the longest threads to
| weave her patterns, so each small piece
| of her fabric reveals the organization of
| the entire tapestry." -- Richard P. Feynman

##### Share on other sites
I don''t think i want to play a bakery sim.

##### Share on other sites

If anyone wants to subscribe to the mailing list then NPCAI-subscribe@egroups.com is the address to send to. The main page for the group is http://www.egroups.com/group/NPCAI/ and to post you send to NPCAI@egroups.com.

second : gosh ! I forgot the children...
That''s not really a problem but this make me think we''ll need to have modular/configurable NPCs.

I think the idea of writing dialogs on screen are optionnal, so the system will propose some kind of dialogs but it''ll be up to the programmer to choose if he wants the dialogs to be visible on screen.

About the idea of the house containing food...
Good idea.
I''ll note that somewhere

Rating the shop and keeping everyone status to each other is something interesting.
And yes something like that is included in the porject.
see : http://www.multimania.com/ingenu/IAModule.txt this text file for more informations on what is or isn''t included

NPC have 5 senses like us real humans.
So they are able to hear any message send near them.
Maybe this message can change his task...
I''ll talk about that in the mailing list.

Please remember the NPC are for a RPG, not a sim''s like game

-* So many things to do, so little time to spend. *-

##### Share on other sites
You could have NPC''s in sims... That would be memory innefficient, take ages to update etc. You may, however, put AI on the other player (ie, NPC) so that a computer could play. But I think that is way out of our grasp for a while

-Chris Bennett ("Insanity" of Dwarfsoft)

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

##### Share on other sites
My thoughts on basic AI for an RPG are as follows:

Firstly shouldnt everything by based upon Stimuli and associated Responses? Stimuli can be external (man sees a bear), or internal (man becomes hungry).
Each response (corresponding to a stimulus based upon choices) is then broken up into goals. Hunger could be broken up into 3 high level goals. Find Food. Prepare Food. Eat Food.
Find food could then be broken down into sub-goals and so on. Goals would have relationships assigned to them (could be simple AND/OR/XOR operations).
Using this method, goals can be reused for different stimuli.
Plus new associations between Stimuli and responses can be made (based on viewing stimuli and responses from other entities) which creates learning.
And this all lends itself nicely to OOP.

Just a thought.

##### Share on other sites
That''s the knid of system we are talking about and trying to programm

-* So many things to do, so little time to spend. *-

##### Share on other sites
yeah, I like that...

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

"The road of excess also just ends making me tired because I'm too lazy" --Nazrix

##### Share on other sites
If you don''t already joined us, I hope you will :o)

-* So many things to do, so little time to spend. *-

##### Share on other sites
Yes, I have

I haven''t had enough time to read all of them though. I should do that.

One idea I had last night for a more non-linear game:

What if we had a need-based system combined w/ a schedule, and the non-linear plots would only happen when NPCs actually come near each other in the world.

So, say one NPC is scripted to murder another NPC at some point of the game. And, the player is then told to avenge the death of the murdered NPC.

....(lame, but simple)....

Instead of this happening at a set point in the plot, it could only happen when the 1st NPC comes in contact w/ the 2nd NPC. And, since we''re using a need-based w/ a schedule, the NPCs would meet at different times each time you play because they''d probably have different needs each time you play. So, they''d find each other at different times.

This could also work with the NPCs exchanging information like dwarfsoft was speaking of. If the 2nd NPC is scripted to tell a confidential secret to another NPC, (and that''s why he gets killed) then he won''t get killed until he finds the NPC to tell the secret. And THAT would happen at different times in the game too. So, it may be a bit chaotic, but it would seem like the NPCs were more alive.

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

"The road of excess also just ends making me tired because I'm too lazy" --Nazrix

##### Share on other sites
Nice idea Nazrix and non-linear game devices as a whole are a good concept to avoid stale FFVIII style adventures. However there is the problem that, in a chaotic world, the situation could turn against the intention of the game designers. What happens if, because of a certain series of unlikely but possible events, the NPC''s don''t bump into each other for days? This leads to a fairly long-winded boring episode for the player.
The less constraints placed upon the plot the more chance there is for circumstance to conspire against the designers and lead away from good, tight game play.
On the other hand the more constraints placed upon the game the more linear the plot development and the more likely you are to end up with a scene-by-scene forced storyline.

I think main plot lines should be more directly scripted in terms of player circumstance (where the player is at a given time, not where an NPC is) leaving the non-linearity to minor plot-lines and less consiquential occurences.

From my point of view I''d love to see a world expand based on the intelligences of the NPC''s and what they decide to do at any given time but unless you want the possibility of a meandering experience then you have to have some form of constrained sequencing to the game.

Just my \$0.02.

Mike

##### Share on other sites
Yes, MikeD, good point. An idea like this would have to be compromised a bit. It couldn''t be too far on the side of chaos.

However, the way that I''m envisioning this, the player wouldn''t be simply waiting for the situation where the 2 NPCs come together. If there are a lot of NPCs then the chance of something happening would pretty good. Furthermore, one situation of 2 NPCs coming in contact may trigger a few other plots w/ it which would keep the player busy.

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

"The road of excess also just ends making me tired because I'm too lazy" --Nazrix

##### Share on other sites
On the point of chaos avoidance, here''s a suggestion...

What if the computer told the NPCs involved that due to a scripted plot event (ie. a murder needs to happen in the story), they have a certain amount of time to make this "chance meeting" happen.

One NPC could be at the bakery, while the other is on his way to the barber. Although the barber might be on the other side of the town, the second NPC knows that he needs to perform this scripted plot sequence within a certain amount of time, so he makes a detour to walk past the bakery on his way to the barber.
If it has run out of time to perform the plot sequence, he just goes straight to the bakery for no good reason at all, and hopes that the player won''t think this strange.

Either way, upon reaching the bakery, the other NPC senses this and knows that she must perform her part of the plot sequence...

Not sure how this could be implemented, but it''s an idea...

Samah

"...the grave is no bar to my call..." - The Horn Of Valere

##### Share on other sites
What about a simple new need : "Kill X NPC" in the system ?

It would be easy to add and will give you the expected result.

Just an idea :p

(Since needs are prioritized, you can give it a low priority to have it done sometime in the future, or a high one to have it done in a few minutes )

-* So many things to do, so little time to spend. *-