• ### Announcements

#### Archived

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

# Annotated objects which drive behavior

## Recommended Posts

bishop_pass    109
Objects have scripts which make them usable. People (NPCs) don''t really base their behavior on scripts as it creates inflexible behavior. An object has a functionality and if it is annotated in a data structure, it''s presence can suggest an idea to any character nearby. I could say a lot more, but I''ll just let someone else take it from here if they want. ___________________________________

##### Share on other sites
Zaei    122
If I recall correctly, this was used in The Sims. Each object would "braodcast" a message to nearby objects. For instance, the fridge would Broadcast "I''ve got Food", while the Microwave would broadcast "I cook food". When a character got hungry, he would know that the fridge had food. When he had food, the Microwave would then tell him/her to cook the food in it. Then the food could be eaten.

Z.

##### Share on other sites
bishop_pass,

So let me try and reinterpret what you''re saying in layman''s terms. Every thingy has a use, and when a character can "see" it the character "knows" its use, and "thinks about" using it.

Right?

Well if that''s what you''re saying, then this is a great idea. I can think of five uses off the top of my head.

1. Combat: You and an NPC are fighting, and some sticks and rocks are lying around. An NPC sees the sticks and rocks. The sticks say: "Use me to hit things!" and the rocks say "Throw me at things!" The result: instead of sticking to the knife in his hand, the NPC will pick up a rock and chuck it at your fleeing back.

2. More Independent Friends: You and some friends are out adventuring. You come across a locked chest. The lock says "Pick me!", so the thief who can pick locks runs over and picks it, without you even having to ask. Of course, he might spring a trap...

3. Help I''m Stuck On the Second Floor: A beastie wants to eat you. You are on the first floor and the beastie is on the second. The stairs say to the beastie "Use me to get to the first floor!" The beastie comes down to the first floor instead of just following your steps on the second.

4. Curiosity (I think this was implemented in ICO): You and your observant friend are stuck in front of a blank wall. The funny colored brick says "Poke me!" Your friend pokes the brick and a trap door opens...

5. Artificial Dumbth: (This happens to real people) A cave is closed off by a giant rock. The NPC wants to go into the cave, but the rock says "You can''t move me, I''m heavy!" The rock is made of painted wood and is hollow; anyone could move it, but the NPC doesn''t even try because the rock told him he couldn''t.

I''m sure there are better examples, and furthermore I most likely have the basic concept wrong. But this is my stab at it.

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

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

##### Share on other sites
bishop_pass    109
You have it exactly right.

___________________________________

##### Share on other sites
Wavinator    2017
This makes me think of a weird, animistic world where the spirits of the rocks and trees talk to people...

When NPC scripting fails it often seems to be because the world state the script depended on is no longer valid. A character tries to push a button that doesn't exist; or attack a foe that's already dead. Having the information imbedded in the objects themselves seems like a much more flexible way to go.

The richer the information in a given object, the more intelligent an agent could potentially appear. If an agent didn't handle an object properly, you might be able to just add more information to the object. An example I remember from the Sims: Perfect strangers would walk into your house, turn on your TV, and microwave the food in your fridge. (Quite funny, actually/) Missing was information about ownership.

A couple of interesting things to wonder about:

1) It seems NPCs would still have to be able to evaluate, weigh, and measure the information they received. Taking SpittingTrashcan's first example, rocks, sticks, and the dagger would all compete to be thrown, but the NPC would have to decide which was best.

2) Timing and progressive state changes to the world would seem to be tricky to model. World objects that send signals deal with the here and now. So NPCs would need another mechanism to deal with implications and future states if they responded to a message.

For example, the example NPC above evaluates that the best weapon to throw is the knife. But the NPC misses. Now the foe turns on the NPC, and the NPC finds himself without his best weapon, and only rocks and sticks to defend himself with. A smarter course of action might have been to throw a rock.

The sprung trap on a chest example ST mentioned is another example: You'd have to encode the potential consequence of performing any given action. If you're going for emerging complexity (combining multiple objects and effects), this would seem much more tricky to manage

3) Contradictions might naturally come about the more information rich the world objects become. For example: A fire can cook food. But a fire can also give your position away to enemies. An NPC with a need both to cook raw food and stay stealthy would have an interesting delimma.

A semi-related example, btw, someone mentioning from an old Ultima: Bodies can be thrown. Bodies can be resurrected. So in order to defeat traps, some players would let a comrade be killed by monsters, throw the body across a pit, then resurrect it on the other side. All actions were logical in a singular context, but sort of contradicted when added together.

4) Range at which object "suggestions" take effect: If an object only suggests ideas when its near to an NPC, NPC in some cases would need another process to handle dealing with the object when they leave its presence. Otherwise the NPC appears senile.

Example: There's a gun in the kitchen of the NPC's house. The NPC goes into another room or outside and encounters an enemy. If the range isn't far enough, the NPC promptly forgets about the gun.

If, however, the range is too great, NPCs run the risk of acting on messages that aren't valid in the local context they find themselves in. Let's say you fix the "problem" of the NPC fogetting about a gun that's only a few rooms away by expanding the range to include the entire few blocks where the NPC lives. If the NPC is at another house down the block and is threatened, should he run back home and get his gun? We're running into a race condition (? I think) where timing, and evaluating consequences is once again required. So this would make setting the ranges tricky.

Having said all that, really like the idea, though... (Pardon the length, it's what happens when you have 6 cups of coffee and are bored to boot! )

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

Edited by - Wavinator on January 20, 2002 5:38:22 AM

##### Share on other sites
Oluseyi    2103
Absolutely fascinating!

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

##### Share on other sites
Infinisearch    2964
Great Idea I really like it. Wavinator u bring up some valid points but I think they are easy problems to solve. First off I see the "broadcasts" as sensory input nothing more. Where u go from there is up to u. U can encapsulate scripts within a state machine whose state is dependant on available broadcasts. Fuzzy Logic systems, to interpret/distort these broadcast inputs. (A thief of this skill level will recognize this hidden door) Memory systems...
For example in your range problem, your AI can still implement somesort of short-term memory, and long-term memory. The contradiction problem could be handled by some Fuzzy logic that is type based. Where battle experience for example is a variable with a range of 1 to 10 and depending on the value could choose the precomputed "better" choice. That same thing kind of applies to the timing/state change, in that a person without battle experience would throw the knife instead of the rock because of nervousness/lack of experience or forethought. And Lastly if this method is mainly for NPC''s they only need to appear intelligent enough to keep up some suspension of disbelief.
One problem that i got from what wavinator wrote though is what if the NPC has no weapons, so picks up a rock and throws it at a guy with a sword. There are no more rocks around... will he run at the guy with the sword to pick up the rock so that he/she can throw it again? That would be interesting. But again I think fuzzy logic could solve that, if the danger presented, outweighs the gain, don''t do it. Just feed the inputs into a character class based "fuzzifier", then run the fuzzified inputs through a class based fuzzy system, and your output is your output. Or you could feed it back into the input that could help deal with the timing state change problem.

##### Share on other sites
Diodor    517
In some situations, this idea would work brilliantly, in others it would fail. Just imagine that a NPC goes to a supermarket to buy a light bulb. OTOH in the case of a phone that rings (or any other event that happens to an object at some point in time), the annotated object idea works just as it does in real life (phone sends ''answer me'' messages in a certain range).

Besides, in many situations, the same reaction could be obtained by placing the script with the NPC or with the object. In the Sims example, why couldn''t the sim think from time to time "I''m hungry", run a loop through all the objects in the house, choose the one with best food and help himself. (This method works exactly like the Sims one, with the uninvited guests eating your food and all)

Another problem is that for a MMO game at least there could be _very_ many objects. Having each object look around for NPCs to send messages to would become quite costly, maybe even more than having the NPCs constantly look around for objects they may use.

A solution I think would be if there was a dialogue between NPCs and objects.

A NPC may move around the world and send ''Look around'' messages to all the objects that enter his sight. Then the object can respond. The NPC can send the objects a lot more messages, like examine, touch, knock etc. and the object would respond adequately.

In example, a NPC may try to look around at a wall with a strange brick on it (send ''look around'' message to brick). Now upon receiving the message, the brick object would examine the attributes of the NPC. If it finds the NPC perceptive enough, it can send him the "I''m Strange" message. Then the NPC (with a theatrical act) would examine the brick (send examine message). Now the brick would carefully read the NPCs resume, find out if he can read Elvish and send him either a "Rotate me" message or a "Strange text" message accordingly. Of course, if the brick can take care of other details. It may send no message at all to the NPC if the light is too dim (or send him a "Not enough light" message - upon receiving this message, the NPC can check if he wants to turn on the light - guards, etc. and if he does, he can broadcast around a "I want something that lights" message, and receive a "Light me up" message from the lantern in his pocket).

One advantage is that the object relevant code stays with the object while the NPC relevant code stays with the NPC. Another that if a NPC is stupid, bored and uninterested about anything around him, the objects don''t constantly run in the background looking at the NPC, thinking the NPC is too bored to notice me and not sending a message.

##### Share on other sites
Kylotan    9860
How do the NPCs ''understand'' what the objects are telling them? In other words, what is the interface between the objects and the NPCs?

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]

##### Share on other sites
Focus    122
You could catagorize everything into what things it can do, or rather, what resources it can affect. Examples of resources might be Ranged Weapon Ammo, Lighting Level, Magical Reserves, Gold Reserves, Energy(i.e, anti-tiredness), Nourishment, Stealth, Safety, Time e.t.c.

So, for example, an NPC in a city might be low on Energy, so he broadcasts a message to identify objects which affect his Energy in a positive way. One could be a spell, but it carries with it, amonst other things, a negative Magical Reserves modifier, and another could perhaps be an Inn, which carries with it a negative Gold Reserves modifier, and a negative Time reserves modifier. If the NPC is rich, and not in a hurry, he might prefer the Inn, ahead of the spell.

With the food example, an NPC low on nourishment might periodically broadcast a message for food, which might require a fire to be built. His nourishment might go up if that happened, but so would the Lighting Level, his Stealth would decrease as a result, an his Sfety (in bad areas) would increase. He would therefore put off his hunger, rather than risk his Safety.

Maybe, with the above example, such resources could be ranked. E.g, put Safety at the top, with perhaps something like Lighting Level at the bottem (only specifically needed in certain situations)

The resources would be calculated in a kind of ''Supply and Demand'' way. Lighting Level for example (from the NPC''s) point of veiw could be at zero, meaning either that the current lighting level was ok for his purpose, or that the current lighting level was simply not important to his purpose.

Problem is, that quite a few catagories would be needed. And ranking them would be quite difficult. Still, it''s an idea.

##### Share on other sites
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".

##### Share on other sites
Gaiiden    5710
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

• 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

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]

##### Share on other sites
bishop_pass    109
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

##### Share on other sites
alexjc    457
> 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...

##### Share on other sites
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

##### Share on other sites
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?

##### Share on other sites
Diodor    517
quote:

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.

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.

##### Share on other sites
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.

##### Share on other sites
Infinisearch    2964
***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-

##### Share on other sites
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.

##### Share on other sites
Infinisearch    2964
"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."

Agreed MadKeith, and if you read my post that is exactly what i''m saying.

"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 farmer cannot wield a sword as well as warrior. That is a function of the NPC''s skill and knowlege not the objects. Lets take the caveman example: Caveman picked up a sword, and has to fight with it. Unless caveman cuts himself or somebody else by accident, my guess is that the caveman would be clubbing people with it. So do you want your caveman slashing people like a pro the first time he picks up a sword?

As to efficiency look at Diodor''s message conversation for the get the diamond situation, then think about what I said. One message is passed, a couple of pushes and pops and a couple of checks thats pretty much it. Look at the power of the container objects controlling broadcasts. Reducing broadcast will reduce unessary processing, as will letting the NPC handle what to do. Because what it wants to do with the object has more to do with the current situation which is NPC based. Also look at it like this, if you broadcast every possible action an object could perform that means the objects have to broadcast messages even if the action only happens once in the game or even on a "weekly" basis. Understand i''m not sugesting you hardcode behavior into to source code. The class definition and Level of NPC''s will bear on its abilities. But can also be extended by a character database that could be cached based on visibility or activity in the storyline, or an event object. This will allow chosen NPC''s to get smarter as the game moves on.

-potential energy is easily made kinetic-

##### Share on other sites
quote:
Original post by Infinisearch
Agreed MadKeith, and if you read my post that is exactly what i''m saying.

That''s not what I understood from your post: you said that, for instance, a horse, would know nothing aside from it being something of the type "horse". It would be up to the NPC AI to "know" what a horse is. That''s backwards. A horse is a horse The information about what a horse does, how it acts, should be stored with the horse, not with the NPC AI.

quote:
Original post by Infinisearch
A farmer cannot wield a sword as well as warrior. That is a function of the NPC''s skill and knowlege not the objects.

But, you agree with me that most likely both the farmer and the warrior recognise the sword as a weapon? The sword affords fighting, or even more detailed, the sword affords slashing. Nothing is being said about the actual slashing - the action slashing can be performed with a sword, with certain modifiers based on the qualities of the sword (within the sword) and certain qualities of the user. Affordances do not change that at all.

quote:
Original post by Infinisearch
Lets take the caveman example: Caveman picked up a sword, and has to fight with it. Unless caveman cuts himself or somebody else by accident, my guess is that the caveman would be clubbing people with it. So do you want your caveman slashing people like a pro the first time he picks up a sword?

The caveman would not recognise the sword as a weapon, and thus NOT pick it up to fight with. Or, in a detailed example, may find the sword looks somewhat like a club, and indeed try to club with it - which is a different action altogether, where again the caveman would not be swordfighting like a pro, but clubbing like a pro with a sword

Your argument about efficiency, I will skip, because the whole implementation of a system like affordances is something that I''m still working on. There are some very interesting possibilities, such as "affordance inheritance", which may lead to more complex "logic" on the part of NPCs, even though they have only a rudimentary AI.

##### Share on other sites
bishop_pass    109
For my "annotated cellar" thread, I have been working out some details, as of yet unposted. Here is what I am coming up with:

The data structures are broken down into actions. Ignore the low level details of how the data structure is setup for the time being. Just follow along.

We might have the following data:

ACTION: { action: "inspect [ME] to learn Russian geography" object: "Russian map" goal: "Learn Russian geography" suggestIf: agent(sees, object) or agent(knowsAbout, object) meetsWhimIf: agent(is, scholar) or agent(is, cartographer) or agent (hasTrait, curious) beforeDoing: ... whileDoing: ... afterSuccessful: ... afterFailure: ...}

Now, for the processing loop...

// query the world with the agent's parameters to see which // objects are broadcasting to him. Take into account what // objects are visible and what objects the agent has remembered.// The objects which broadcast will be based on whether the // agent's goals are satisfied with using the object or// the object meets a whim of the agent's.// Put the suggestions in a list called agentSuggestionList.getSuggestions (agent, agentSuggestionsList);// pick a suggestion for something to do. Take into account// that which is most important based on a basic priority of// things such as survival and so forth.toDo = pickSuggestion (agent, agentSuggestionList);// once something to do has been selected, have the agent// do the action listed in the beforeDoing field. This might// be verbal direction and/or changing the game state.doBeforeSuggestion (agent, toDo);// Now check to see if something has changed the agent's // decision to do what it is he was going to do. Perhaps// the player character has advised him not to. Depending on// his personality or relationship with the player character// or another character, he may still do it though.if (toDoNotNegated (agent, toDo)) { doIt (agent, toDo); if (successful (agent, toDo) doAfterSuccesful (agent, toDo); else doAfterFailure (agent, toDo);}

___________________________________

Edited by - bishop_pass on January 22, 2002 11:44:23 AM

##### Share on other sites
bishop_pass    109
As for chaining together a sequence of actions to create a sort of planning agent, I was thinking like this:

ACTION: {
object: "broom"
action: "get [ME] to use [ME]"
}

ACTION: {
object: "broom"
action: "use [ME] to push [OBJECT]"
}

ACTION: {
object: "trapdoor"
action: "push [ME] to open [ME]"
}

ACTION: {
object: "trapdoor"
action: "open [ME] to exit [cellar]"

ACTION: {
object: "cellar"
action: "exit [ME] to enter [living room]"
}

Now, in order for that to work, you have to adopt a unifying set of commands that are consistent.

Let's say the agent has the goal to "exit [cellar]". One of the above actions satisfies that. In order for that to work, the trapdoor must be opened. Assuming the trapdoor is not open already, the agent now has the goal to open the trapdoor. So, the objects broadcast their functionality to the agent again, and one of the actions will satisfy the goal of opening the trapdoor. In this case, it is: "push [ME] to open [ME]".

Now, I have left out the simple way of doing this, which is simply to push it with your hand, because that way is going to fail. Let's say that was there as an option and it did fail. But, there are other alternatives. The agent now sees a solution with the broom: "use [ME] to push [OBJECT]". Now, the agent has the goal of using the broom. So, lastly, the agent sees that to do that he must "get [ME] to use [ME]".

A chaining process works here, where the right hand side of the action string is matched to the left hand side of an already existing goal to derive a new goal.

___________________________________

Edited by - bishop_pass on January 22, 2002 11:43:21 AM

##### Share on other sites
Gaiiden    5710
quote:
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.

Solving this problem is actually quite easy. If you make the mirror an object that can detect characters within it''s visual range and area, then it queries the NPC whether or not it wishes to be reflected, upon which the NPC can be programmed to reply yes or no. This could also be used for games that involve character invisibility. When the character is invisible it can switch to telling the mirror "don''t reflect" instead of "yes, reflect me". I''m not saying this is the best solution, but it certainly works for more than one situation, and I''d call that pretty valuable.

As for the whole caveman thing, he should recognize it as a weapon from the object''s broadcasts. Like Madkeith said, you can use modifiers in the sword object to look at its wielder and take into account the damage done per hit. So a Caveman would do little or no damage due to improper handling while a Swordsman would inflict much more damage due to his level of skill. The point is that the Sword, or the object, is what determines this, not the NPC directly.

_________________________________________________________________

Drew Sikora
A.K.A. Gaiiden

ICQ #: 70449988
AOLIM: DarkPylat