Annotated objects which drive behavior

Started by
85 comments, last by bishop_pass 20 years, 4 months ago
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. ___________________________________
_______________________________
"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.
Advertisement
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.
______________"Evil is Loud"
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".
----------------------------------------------------SpittingTrashcanYou can't have "civilization" without "civil".
You have it exactly right.

___________________________________

_______________________________
"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.
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
--------------------Just waiting for the mothership...
Absolutely fascinating!

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
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.

-potential energy is easily made kinetic-

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.
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 ]
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.

This topic is closed to new replies.

Advertisement