Annotated objects which drive behavior

Started by
85 comments, last by bishop_pass 20 years, 4 months ago
Diodor: I like your idea of communication from the NPC activating responses from the objects. Sounds sort of like a submarine "pinging" to receive information about its surroundings, or like the old "Look Around" command in text games which gave you a list of items in the area. The strength of the Ping could be modified by the NPC''s perceptiveness: he''s likely to notice a Big Hammer sitting in the middle of the floor, but a key half tucked under the carpet is less likely to respond to a low-level ping. As a matter of fact this could work a lot like radar: with signal strength being the intensity of the search, and reception based on the perceptiveness of the NPC and other factors like darkness and clutter. This could even work to make NPC behavior more like PC behavior, especially if PCs also automatically "low-level ping" whenever they enter an area, and objects they don''t "notice" are simply not drawn at all! Then the PC can Search a room to send a strong ping, and hopefully find more. If a PC or NPC is specifically searching for one type of thing, he might send out a ping on the "wavelength" of that object and thus be more likely to find it. Of course, how PCs and NPCs react to this knowledge is something else again, and as mentioned rather difficult to implement.

---------------------------------------------------
-SpittingTrashcan

You can''t have "civilization" without "civil".
----------------------------------------------------SpittingTrashcanYou can't have "civilization" without "civil".
Advertisement
I think there''s one excellent advantage to this system that makes The Sims an extremely flexible game and was hinted at by Diodor:
quote:Original post by Diodor
One advantage is that the object relevant code stays with the object while the NPC relevant code stays with the NPC.

This fact is what lets us plunk any object into The Sims and have our Sims immediatly start to interact with it.

The question of object communication implies that there is some sort of "middle-man" process that goes on between the NPC and the object that translates each others messages into something both can understand and interpret. This need not be true, as we can encapsulate (oooh, fancy OOP word! ) each object with it''s own set of instructions for the NPC to carry out so that the NPC really doesn''t do any thinking on his own in that respect. I''ve read up on The Sims AI a bit and from what I recall that when a Sim wants to play with a soccer ball, the Sim doesn''t instinctively know what the heck to do with it, but the ball (or object, to be general) tells him what he can do. Here''s the process:

1) Sim is pretty bored and needs som Fun. He sends out a general query for all objects that positively modify Fun.
2) Among others, the soccer ball responds you can play with me! (I won''t go into why he chose the soccer ball for this example)
3) The Sim approaches the soccer ball. This is an action the Sim itself is capable of performing.
4) The Sim tells the ball I''m ready to play!
5) The ball broadcasts to the Sim a list of activities:

  • Kick Me

  • Throw Me

  • Punt Me

  • Head-butt Me

  • Steal Me

  • Block Me

  • ...


6) Depending on outside variables, the Sim chooses an action and then the ball instructs the Sim in performing the action.

And of course while the Sim is talking to the ball and the ball is instructing the Sim, the ball is talking to the goal and the goal is instructing the ball, which then guides the Sim towards the goal, using simple obstacle avoidance to get around other Sims (this isn''t a realistic soccer sim! ).

This is a good example of how the objects not only interact with the NPC, but each other as well. Instead of the soccer ball containing explicit information on how to get to the goal, the goal simply instructs the ball how to get to it, and then the ball instructs the NPC to kick it towards the goal, and so on and so forth. You can see how deep and complex and powerful this can get. I could describe the whole soccer game with multiple players, where a Sim would braodcast to the ball and not another Sim, that he''s open, and the ball would tell the Sim to kick it towards the calling Sim! I can only imagine the communication trees you could come up with for such a simple soccer game scenario. And the best part is that you can keep it so encapsulated so that you can just drop in items like that and have NPCs pick them up and use them without having to modify the NPC in anyway to instruct it how to use the object. Kudos to the Sims AI guy(s)!

Damn, I just got all excited writing that Thanks for pointing me to this thread, BP - hope my comments helped. Just writing that out above really blew me away, i never realized myself how powerful this AI system is!

_________________________________________________________________

Drew Sikora
A.K.A. Gaiiden

ICQ #: 70449988
AOLIM: DarkPylat

Blade Edge Software
Staff Member, GDNet
Public Relations, Game Institute

3-time Contributing author, Game Design Methods , Charles River Media (coming GDC 2002)
Online column - Design Corner at Pixelate

NJ IGDA Chapter - NJ developers unite!! [Chapter Home | Chapter Forum]

Drew Sikora
Executive Producer
GameDev.net

I never knew the Sims used such mechanisms. I have never played the game, seen it in action, or read anything about it other than what you find on the box cover. For those interested, I took my inspiration from a paper in the AI field titled Agents in Annotated Worlds.

On a side note, in searching for this article just now to provide the link above, I came across this PDF article titled The Cooperative Contract in Interactive Entertainment which seems to dovetail nicely with what Oluseyi is talking about in his Narrative Interpolation thread.

___________________________________



Edited by - bishop_pass on January 20, 2002 12:48:33 AM
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
> each object would "braodcast" a message

All this is known as Affordances. A ball can afford to be kicked, for example.

This is 30/40 year old research I think, so looking into academic work for ''Affordance'' is a good start.

Alex


Artificial Intelligence Depot - Maybe it''s not all about graphics...

Join us in Vienna for the nucl.ai Conference 2015, on July 20-22... Don't miss it!

A VERY basic text pertaining to affordances.



Note that in the very first example, they are already talking about taking "affordances" relative to the observer, something which the Sims seems to have abstracted (because it was not important in the context). Using things like this in CRPGs makes it more important to use "relative" affordances, i.e. the possibilities of an object need to be described as relative to the observer.

Eg: Weapon affordance in your typical run-of-the-mill fantasy CRPG:
- Sword: If the observer's strength is greater than 10 then I'm a weapon to him.
- Battle Axe: If the observer's strength is greater than 15 then I'm a weapon to him.

That's just a quick thought on my part, I haven't read more than the first page of that document yet! Thanks for the brilliant heads-up Bishop_pass! I'm integrating it into Goblin 2.0 (yep, it still hasn't really left my mind yet).

Edited by - MadKeithV on January 21, 2002 4:13:22 AM
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Don''t tell me this thread has lost interest already! Come on people, there''s lots more to discuss.

Let me start:
The idea of "annotated objects" or "affordances" really stuck in my mind yesterday. It''s a great way of programming "intelligence" into your NPCs without actually making your NPCs intelligent (you make your objects smarter instead).

I did figure out some serious issues with them though, and here they are:

1. Object Exceptions: In a "magical" world, a conflict can exist between one object''s basic properties and the objects to which it applies.
An example: say you have a normal game world, with mirrors. After using it for a while, you decide to introduce a new NPC class into the game: vampires. However, you run into a problem, because all your mirrors have been programmed to reflect whoever looks into them. You have no means to override this behaviour for Vampires.

2. Observer-relative affordances are not always correct: most of the time, an observer will be interested in an object''s properties/affordances relative to itself. For instance, a bayleaf is a seasoning to a cook. However, there are instances, specially with more detailed reasoning, where an observer would like to know an object''s affordances with respect to another entity than itself! In a mystery game, it could be very useful for an NPC to know that to a horse, a bayleaf is in fact poison.

A possible solution for the second issue is parametrising affordances with at least two items: the observer, and the subject. The object being observed still does all the deciding on which information to give to the observer though.

For instance, if a cook would examine a bayleaf, with respect to horses ( so, bayleaf.Affordance( cook, horse ) ), chances are that he wouldn''t get much, because a cook knows little about horses. If a stable owner did so, he''d get "poison"! However, a stable owner would not get "seasoning" when examining bayleaves for himself, because he''s a crummy cook.

Thinking about this - perhaps it''s useful to NOT pass the "subject" to an affordance, but rather have a set of subjects for each observer, about which the observer may know less or more. Each object has a list of affordances, organised by subject. What you get out of the list depends on the observer''s subject list. Does that make sense?
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
quote:
Original post by MadKeithV

1. Object Exceptions: In a "magical" world, a conflict can exist between one object''s basic properties and the objects to which it applies.
An example: say you have a normal game world, with mirrors. After using it for a while, you decide to introduce a new NPC class into the game: vampires. However, you run into a problem, because all your mirrors have been programmed to reflect whoever looks into them. You have no means to override this behaviour for Vampires.


Actually, I thought handling such exceptions was a strong point of this system. All you have to do is add an extra check to the examine message handler of the mirror so that examine messages coming from a vampire will get an appropriate response. There is no way around hard-coding the vampire-mirror rule somewhere anyway.

A simpler example would be text written in a different language / alphabet. The text object would first check the literacy of the character examining it and then issue a message accordingly (the actual text or "Strange symbols" or even a missinterpreted text)

quote:
2. Observer-relative affordances are not always correct: most of the time, an observer will be interested in an object''s properties/affordances relative to itself. For instance, a bayleaf is a seasoning to a cook. However, there are instances, specially with more detailed reasoning, where an observer would like to know an object''s affordances with respect to another entity than itself! In a mystery game, it could be very useful for an NPC to know that to a horse, a bayleaf is in fact poison.

A possible solution for the second issue is parametrising affordances with at least two items: the observer, and the subject. The object being observed still does all the deciding on which information to give to the observer though.

For instance, if a cook would examine a bayleaf, with respect to horses ( so, bayleaf.Affordance( cook, horse ) ), chances are that he wouldn''t get much, because a cook knows little about horses. If a stable owner did so, he''d get "poison"! However, a stable owner would not get "seasoning" when examining bayleaves for himself, because he''s a crummy cook.


Or three items: the observer, the subject and the action. Let''s say a stable owner seeks a way to heal his horse. He broadcasts an (action = Heal / subject = Horse / observer = Stable Owner) around. He may get an response from some medicine plants (provided the plants find the owner knowledgeable enough). But if he wants to kill the horse, he sends a (Kill/horse/stable owner) message and gets a response from the bayleaves. Likewise, a (Feed/Horse/Little boy) may get both the medicine plants and the bayleaves to respond (because both are green, the plants ''know'' a kid couldn''t tell the difference)

quote:
Thinking about this - perhaps it''s useful to NOT pass the "subject" to an affordance, but rather have a set of subjects for each observer, about which the observer may know less or more. Each object has a list of affordances, organised by subject. What you get out of the list depends on the observer''s subject list. Does that make sense?


If I understood correctly, this doesn''t sound like the best idea, because the objects would then have to send out very complicated answers, and then the NPC AI must make the difference again.



Here''s an example where an object can serve different purposes. I tried to write everything implementation like. Sorry for making it so long.

Objects: Small room, window (cannot be opened), locked door, strong glass case, diamond inside glass case, key in NPCs pocket. The NPC wants to get the diamond and split.

NPC broadcasts Get Diamond message.

Diamond receives Get Diamond (from character) message. The Diamond has a scripted ''Inside Case'' flag, and because of this flag it issues a ''Gain Access'' message to the Glass Case.

Glass Case gets a Get Access (from character) message. Glass Case examines character, finds it pretty dumb, and offers the NPC the solution to break the case with bare hands.

NPC gets the solution and accepts it, sending the Case a ''Break'' message. The Case directs the NPC to hit case, but this is to no avail. The Glass Case gets a ''Get Hit'' (by character) message (probably from the game engine), and it remembers that the character tried to hit the Case.

The NPC broadcasts the Get Diamond message again. Everything repeats.
Glass Case gets the Get Access (from character) message. Glass Case examines character, but since the character already knows breaking won''t solve anything, the case broadcasts a ''Break Me With Object'' (breaker = character, broken object = Glass Case) and a ''Scratch Me with Object'' (scratcher = character, broken object = Glass Case) message to all the objects.

The Chair responds to the Break Me message and offers the player a solution (''Break Case with Chair'' - noise + 5)
The Key responds to the Scratch Me message and offers the player a solution (''Scratch Case with Key'')

The NPC chooses the Key solution (lesser noise). It sends the Key a ''Scratch'' message (scracther = character, scratched = Case). The Key directs the NPC into doing this.

The Case gets a ''Get Scratched'' message from game world, and change it''s internal flags accordingly.

The NPC still doesn''t have the Diamond. He issues the Get Diamond message again. All repeats.
The Glass Case now knows that bare-handed breaking will work, so it sends the player this solution again.

The player gets the solution message, and sends the Case an ''Break'' message. The Case directs the NPC into breaking it. This time it works.

The game world sends the Case a ''You are Break'' Message. The Case sends the Diamond a ''You are Free'' message. The Diamond changes it''s internal flags.

The NPC still doesn''t have the Diamond. The NPC sends the Get Diamond message again.

The diamond sends the NPC the ''Take Me'' solution.

The NPC accepts the solution and sends the Diamond a ''Take'' message. The Diamond directs the NPC into takeing it.

The NPC has the diamond and now wants to get out. It broadcasts a ''Get Out'' message.

The door gets the message, but since it is locked, it broadcasts an ''Unlock me'' message
The window gets the message, but since it is closed, it broadcasts an ''Break Me'' message.

The Key gets the Unlock me message, and sends the player a proposed solution (Unlock door with key)
The Chair gets the Break Me message and sends the player a proposed solution (Break window with chair, noise +15)

The player chooses the Key solution and sends the Key the Unlock Door message. The Key directs the player into unlocking the door.

The NPC completed the solution, and is still not outside. He broadcasts the ''Get Out'' message again.

The Door gets the Message, and offers the NPC a solution (open door).
The window and the chair offer the break solution again.

The NPC accepts the door solution and sends the door an open message. The Door directs the NPC into opening the Door.

The NPC is still not outside, and so it broadcasts the Get Out message again.

The Door offers the ''Get Out'' solution.
The Window offers the Break solution.

The NPC accepts the ''Get Out'' solution, and sends the Door a message. The Door directs the NPC into getting out.

The NPC is out.

The End.


quote:Original post by Diodor
There is no way around hard-coding the vampire-mirror rule somewhere anyway.


That''s what I was implying really After "deploying" the software, you cannot change the behaviour of objects in the world. Actually, that''s probably a good thing, because it makes cheating a whole lot harder!



And reading the rest of your post, I realise I''ve made a critical mistake in how I view affordances. I had assumed that an Actor does no more than send an "I''m here" to all the objects within range, and all the objects that feel like replying just dump all the available information on him. Looking back, that''s pretty silly of me, because it''s highly inefficient.

I''ll have to think a bit longer, keeping in mind that an Actor is querying objects around him for help concerning his current goal.

It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
***Warning Long Post

Why is everybody sending messages back to the Object from the NPC in these examples? And why is everybody associating possible actions with the object not the NPC? Why send multiple messages beyond, "i''m here...and i''m a horse". After that it up to the NPC''s AI as to the immediate and later significance of the object. Which of course is affected by the NPC''s knowlege. And more importantly the current context. If the NPC is currently Running for its life, why do all the processing of multiple messages when the NPC isn''t gonna/suppose to notice at the moment?
The problem Diodor proposes can be solved with a stack based "things to do" list and allowing the announce message to say "I''m in this object". This is if the case had a glass face with the diamond visible, if it isn''t visible then no message is sent at all. So you must define types of objects more over a container object. Container object would take over broadcasting message for the objects contained and could be modified as a part of the container object state. i.e. A cabinet is left open, so it will broadcast the messages for its contained objects. You can even further the announce message to include a volume. A thief and a warrior walks into said room, the threshold value for the thief is lower than the announcement volume. The "notice" function "fires" and the thief notices the object, the warrior has not noticed the jewel yet. Getting a little more complex you can make the notice function a function of time with a Minimum value. (the longer in the room the more stuff u notice)
Anyway on with the example:
Assumptions: NPC knows it has key to case, NPC ''saw'' or knew the diamond was there in the case, and is currently in a "get the diamond mode". Operation Push Get diamond, Push Open case, -can i open case:=yes- (get key) Pop open case, pop Get diamond, pop whatever i was doing before i went to get the diamond.
What a NPC can do with an object has more to do with the knowlege of the NPC than the object itself. If a caveman NPC came through, and there was a diamond and a steak... i''m betting he''d go for the steak. Lets say there are two steaks, the NPC''s AI calls its Examine Function with a parameter of ''steak'', the steaks data stucture is examined and the NPC''s temporary memory is updated to moldy steak... If the cave man doesn''t know that the moldy steak is gonna give him food posioning, eat it. I guess the examine function could be implemented through multiple threshold values, one for each sense but to much processor time is getting eaten up as is so i''ll stop here.

feel free to comment


-potential energy is easily made kinetic-

-potential energy is easily made kinetic-

quote:Original post by Infinisearch
What a NPC can do with an object has more to do with the knowlege of the NPC than the object itself. If a caveman NPC came through, and there was a diamond and a steak... i''m betting he''d go for the steak.


No, you see, that''s exactly what we are trying to reverse. What an NPC can do with an object has more to do with the functions of the object than the knowledge of the NPC. A steak can be eaten by anything humanoid. It doesn''t matter if you are Einstein or Conan, a steak will feed you (not counting vegetarians).

What makes the difference is the NPC motivation. The Caveman NPC has no interest in wealth. When he comes through, he''s not looking to accrue any wealth (he probably doesn''t even know the concept), but he IS trying to survive most likely. Food is a big part of that, so after the steak he goes. The diamond is just an annoying shiny thing in the way.

However, the thief is not very hungry, and more importantly, knows that he could get a three-star meal with the proceeds from that diamond! So the thief''s motivation causes the diamond to call out with "Hey dude, I''m REALLY expensive", while the barbarian''s motivation causes the steak to call out "Hey bob, I''m REALLY tasty."

It allows you to introduce new objects into the game, and having your NPCs react to them seemingly intelligently, without having to change a line of code in the NPC''s AI. The new object simply does all the work.

It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.

This topic is closed to new replies.

Advertisement