• Advertisement

Archived

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

Ghosts - an idea to improve NPC AI

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ghosts are NPC-like objects generated after a NPC is killed, kidnapped, etc. A ghost cannot change the game world in any way, it has no graphic representation. The ghost performs all the actions the NPC wanted to perform. It will go to the market the NPC wanted to go to, it will go back to the NPCs village and so forth. The trick is that every time the ghost gets close to another NPC, it send the NPC object an event: "Hey, look, remember me, I should be here and I am not." Depending on how inteligent and perceptive the NPC is, how well did he know the other NPC, he could react to these events and take action (sound the alarm, go find the lost NPC, etc.). This could work very well in Thief: killing or banging the guards would create a ghost that moves around the exact circuit of the guard. The ghost would move around, creating visual and audio ghost events. If another guard would see the visual event of the ghost, he can become more alert, start looking for that guard, shout his name, ask other guards about him, sound the alarm etc. If he heard the audio events of the guard, but would not hear real audio events matching them, he can also react. This gives a bonus: the player can bang the head of a guard, then walk over a marble area at the same pace as the guard: the other guards will not mind, because they think the banged guard did it.

Share this post


Link to post
Share on other sites
Advertisement
This is an excellent idea, it would remove some of the burden of constant state checking, etc. It''s far easier to have the ai react to an explicit event than to have it "know" everything that should be happening and continuously monitor whether everything is in order. Perhaps you could set a variable delay after the ghost event which would give some leeway before someone became alarmed. You could also add counters, for example every time a character visits the market a counter is added, as this value gets higher the chances of someone in the market noticing a ghost event would be greater. Even cooler, you could have important items give off ghost triggers, so that if something is stolen the item''s ghost could remind anyone who views it that it should be there but isn''t. Then as you said you could add in modifiers for characters with better perception or higher alert status. Great idea!

Share this post


Link to post
Share on other sites
Yup, this seems to be a really useful idea.

You can then put an alertness level to each NPC, assigning how many ghost events (of what importance - visual and tactile ranking highest, audio probably lowest) it takes until he starts doing something.
You can also top it off on the other end of the scale, perceiving one or two ghost events makes you NPC alert and cautious to the events that might have happened, but if there are a huge number of different ghosts then he would become panicky.

Something like that: If you come home and a vase is missing, you might not even notice it. If the furniture is gone, you will probably call the police. If the house is empty, the neighbours are all gone, the noise of the traffic is missing and ALL the houses are empty you will probably have a nervous breakdown sooner or later.


Share this post


Link to post
Share on other sites
That''s ingenious!

You could leave a ghost as an after effect of an event. If someone takes a bazooka and blows a hole through a wall, you could leave a ghost there for NPCs to find and get excited about (as opposed to having them go there and perform some complicated scanning algorithm to check whether the wall is broken or not). A ghost for a patch of burned trees which fell victim to someone''s fireball might cause the NPCs following the PCs as henchmen to get real nervous.

George D. Filiotis
Are you in support of the ban of Dihydrogen Monoxide? You should be!

Share this post


Link to post
Share on other sites
Annotated worlds... it''s in the AI literature. Diodor has taken it a step further with ambulatory annotations. Annotations are notes or instructions left in key areas to NPCs (invisible to the player) on how to behave.



___________________________________

Share this post


Link to post
Share on other sites
Thanks for the replies. And here''s another idea: spirits. Spirits are a variation of ghost, but they appear in the world by themselves, and try to accomplish certain goals. (A thief spirit for instance would try to climb the wall of a castle, sneak inside, move around without being seen (if he is seen, the spirit will either disappear or be thrown outside the castle for a new try), stealing stuff and getting out) If successful, the spirit will then prompt passing NPC thieves that the castle needs some looting. Or they could prompt the same thief NPCs that the castle is very secure or has little value inside if the spirit fails in his attempts.

This is more of an idea for improving NPC intuition, not AI. The NPC would know that there is a way inside the castle from the spirit, but he would first need to take in game action to find game information about that route before proceeding to make everything look legal. The player would suspect nothing. From what he knows, the thief was an honest NPC, he read the secret plans of the castle, talked to the drunken guards about the back entrance, and then went on stealing.

Share this post


Link to post
Share on other sites
I dont really see the point behind the "spirits" idea, at least not in the example you provided. If you go about letting your NPCs "scout ahead" via spirits, then you have run into that age-old "the computer is cheating" problem, even if you legitimise it by what you mentioned. I think that if you want to make a NPC behave realistically, you have to do that based on the moment. The spirit would probably give more information than just the map, so it would not really serve a purpose in the sense of giving them "intuition".
The basic idea is good, but I dont believe that NPC intuition is something we need (yet), right now the main problems are NPCs being dumb as rock, getting stuck in doorways and not reacting properly to their environments.

The way I see it a spirit is essentially an optimisation routine, if you let it learn, you can let it go at the same problem again and again, until it succeeds with a certain probability. The are where I would see applications for this is AI (as in chess computer), when you let your computer-played opponent play out different strategies in order to come up with a way to surprise you.. in a fps it would amount to something like "what happens if I (the monster) run around the corner and try to shoot the player". Then you´d find a probable outcome, determinde by stuff like the monsters stats, the players average aim and lots more. If the outcome is not favorable (for the monster) then it stays back or goes elsewhere.
I think by that you could essentially avoid all kinds of "rushes", be it strategy games, the rpg-orc or the fps target.



Share this post


Link to post
Share on other sites
Guest Anonymous Poster
great idea

Share this post


Link to post
Share on other sites
I really like the ghost idea, Diodor. If the ghost followed the same rules as an NPC, the player might be able to count on what he knows about the world and its workings in order to implement some strategy (e.g., player thinks, "Better get moving, this guard will be noticed missing in 10-20 minutes" because he knows the guard''s route)

Another factor to possibly add: How routine is the NPC? If the NPC is always jetting off to Paris or Myth Drannor or whatever, his absence could have another excuse.

I''d love to see something like this implemented for a murder mystery cRPG



--------------------
Just waiting for the mothership...

Share this post


Link to post
Share on other sites
quote:

Original post by Wavinator

Another factor to possibly add: How routine is the NPC? If the NPC is always jetting off to Paris or Myth Drannor or whatever, his absence could have another excuse.



And the cool thing is the ghost should be responsible for knowing how routine it''s NPC was. The ghost will send the NPCs it meets in Myth Drannor messages like "Hey, I should be here, but don''t worry, I could be in Paris as well." - the NPCs can even pretend to be smart after such messages: "Hey, have you seen Korba lately?", "No, but don''t worry, he prolly is in Paris again!". And if for instance the killed NPC used to travel a lot but would always come back home after a week or so, the ghost would know that and start spreading worrying messages only a week later.

Share this post


Link to post
Share on other sites
a very nice idea..
but i would imagine something like this would use a TON of system resources..


-eldee
;another space monkey;

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The ghost and spirit ideas are both excellent. The spirit idea in particular, could be incrediably usefull to simulate NPC''s assessing weaknesses of buildings. In the thief example, a successful spirit could represent the planning before the theif executed a job. Whilst for fixed structures, weakpoints could be calculated beforehand, if a structure was to be built by the player (think Dungeon Keeper) this could be very effective.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Diodor,

Is this your original idea? If so, do you realize that you may have just revolutionized NPC behavior in games??? *I* plan on using this technique as needed!

RJ

Share this post


Link to post
Share on other sites
quote:
Original post by eldee
a very nice idea..
but i would imagine something like this would use a TON of system resources..


-eldee
;another space monkey;


Not if it was done properly, I think. Think about it... The ghost would use the AI time left over by the dead NPC, and replace things like targetting and stuff with deciding whether a friendly NPC was close enough to "talk to". Also, the ghost would not have to be rendered. I think the whole idea is really cool.


---------------

I finally got it all together...
...and then forgot where I put it.

Share this post


Link to post
Share on other sites
quote:

Original post by Anonymous Poster,

Diodor,

Is this your original idea? If so, do you realize that you may have just revolutionized NPC behavior in games??? *I* plan on using this technique as needed!



Thank you! Apparenly, as bishop_pass pointed out, much of the idea isn''t new. As for revolutionizing the NPC behaviour, the merits go to those that do all the hard work of implementing the system. I don''t believe there is any simple magic solution that will make the NPCs intelligent, but every bit can help. Good luck with your game and keep us informed about how it works out!

Share this post


Link to post
Share on other sites
Sounds cool...reminds me of a thread we once had a long time ago about things dropping triggers only this would be kind of like autonomous triggers I suppose


A CRPG in development...

Need help? Well, go FAQ yourself.

Share this post


Link to post
Share on other sites
I can see this idea leading to some other nifty things as well. Consider an RPG: all the NPCs can have ghosted routines. If you change the world, you change people''s routines and they can then talk about it without further prompting. Instead of having preprogrammed "events" which NPCs are preset to "hear" about, you can actually have a non-predetermined effect on people''s lives, and they will notice and talk about it. Thus you can have a reactive plotline instead of a rigorous step-by-step progression. You gain nonlinearity without losing storyline. Sweet!

-SpittingTrashcan

You can''t have "civilization" without "civil".

Share this post


Link to post
Share on other sites
This may only be an evolutionary step in AI, but it is nonetheless a very big and important step. Diodor, you are too modest!

I too plan to implement this. Not in my current project, I can't really see how this would carry over to a strategy very cleanly, but most likely in my following project.

Once again, commendable work! Have a cigar!

[Added: Okay, actually, now I can see where this can be used in my game. The spirit idea can be applied along with a few other techniques to gauge the security and strength of an opponent's base, but only to provide intel to the player, whether human or AI. This allows for a better planned attack, rather than just throwing hordes of tanks, soldiers, etc. at the enemy stronghold and praying to Bob that you don't get kicked in the nuts. And seeing how strongholds are an important part of my game and all... Mwahahahaha...]


Chris Charabaruk (aka coldacid)

Meldstar Studios - Creation, cubed.


Edited by - coldacid on December 5, 2001 6:13:34 AM

Share this post


Link to post
Share on other sites

  • Advertisement