Re: Modeling events that occur in a game world
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Mon, 23 Apr 2007 10:20:25 +0200
On 22 Apr 2007 19:04:45 -0700, Aaron J. M. wrote:
On Apr 22, 12:29 pm, "Dmitry A. Kazakov" <mail...@xxxxxxxxxxxxxxxxx>
wrote:
Not necessarily. Others would sense the creature using their own sensors,
which might be less inaccurate than the self-feeling, or reverse. (What
irritates me in some RPGs is that when you do something, like stealing a
thing, all NPCs become instantly aware of your action. Why should they?)
Could you explain how these sensors would work/go? With the event model I've
been wrestling with above an AI would poll the event queue and pick an action
for its Creature depending on any events it had interest in.
The difference is that you attach the queue to the object. But in "reality"
objects don't communicate directly except than when they are talking to
each other, which is also an abstraction of some complex short-range
process. The objects communicate with the local environment. You already
have it in the form of the map where the objects are located. It is a form
of communication. I guess the objects will have get-my-X,Y,Z-co-ordinates
and set-my-X,Y,Z-co-ordinates. The first is "sensor", the second is
"actuator." You could implement the most of physics this way, by adding
forces applied at the position X,Y,Z, terrain constraints etc.
The Creature's
actions would generate more actions to go on the queue.
This has a problem of determining the queue into which the action need to
be placed. An object has to know too much about what it is going to do
that. This is why the event abstraction is not that good for more or less
elaborated physics. It would make the design of objects way too complex.
When an object is thrown, it is not a collaboration between it and the
thrower. It just flies, it need not to know what has thrown it. You could
still use it for higher-order things like speech, which are hard-wired
rather than simulated. I mean it is a trade-off, more complex your
simulation becomes, less the model of objects "talking" to each other pays
off.
Of course there has
to be a way of getting rid of old events that everyone has already seen before.
If you want broadcast events, then in your model you just put the event
into each and every queue. You don't need to get rid of it, it is the
problem of somebody who reads the queue out. You will need handles (smart
pointers) to the event parameters which aren't marshaled, to prevent them
from disappearing before the event gets dequeued. And you will have a hell
with race condition problems, which are typical for any event-based system.
An alternative design for broadcast / multicast events is the blackboard.
You put the event there and everybody scans the blackboard for the news.
The blackboard is a large ring buffer which gets overridden. Events in the
buffer have the sequence number so that the consumers can detect the last
event when they scan the buffer. This has less problems with non-marshaled
parameters, which live until the ring buffer overrun. But it consumes more
memory and race conditions are all yours anyway.
As for the thievery example, I'd add a line-of-sight check to eliminate any
omniscience. ;)
I.e. you will need to filter the events.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: Modeling events that occur in a game world
- From: Aaron J. M.
- Re: Modeling events that occur in a game world
- References:
- Modeling events that occur in a game world
- From: Aaron J. M.
- Re: Modeling events that occur in a game world
- From: Dmitry A. Kazakov
- Re: Modeling events that occur in a game world
- From: Aaron J. M.
- Re: Modeling events that occur in a game world
- From: Dmitry A. Kazakov
- Re: Modeling events that occur in a game world
- From: Aaron J. M.
- Modeling events that occur in a game world
- Prev by Date: Re: Modeling events that occur in a game world
- Next by Date: Re: Modeling events that occur in a game world
- Previous by thread: Re: Modeling events that occur in a game world
- Next by thread: Re: Modeling events that occur in a game world
- Index(es):
Relevant Pages
|