[MUD-Dev] FW: A question of message propagation

Patrick Dughi dughi at imaxx.net
Wed Jun 14 13:47:33 CEST 2000


-- Joe Kingry writes:
> I'm having trouble figuring out how to do message propagation. I believe
> that is what I want to do. Well let me present a detailed example to
> demonstrate what I want to accomplish:
> 
> |
> E----D-
> |    |
> C--A-B-
> |    |
> F--G-H
>    |
> 
> I've mapped a small section of a simple room system. I'll just assume each
> link is two-way for now, but it should be possible to have one-way links as
> well.  The problem is given a message event raised at location A, propagate
> it to all it's surroundings.

	>snipped the rest<

  First, don't think of a message as a transitory event which exists only
as the reaction items have to it (ie, your idea about storing message
id's, etc). Think of it as an object which can be passed, copied,
destroyed, and acted upon.  Generating unique id's should be simple
enough, grab some time and sprinkle milliseconds on top.  Add the ability
to store a list of messages in your room - linked lists will do if you're
in a hurry, bst's might be a better call if you're going large scale, else
I'd stick with a simple hash table. 

  So, lets say you have an event - we'll make it a bomb blast.  Your event
creates an object which it assigns to the room and calculates the results
(like damage to items/players, change of room descriptions, etc).  Then it
makes a copy of itself for each exit, and transfers it to each exit->room.
You can choose to keep track of the distance an event travels - say each 1
room, the damage is divided by half, until it reaches a distance of 4,
where it only gives a "you hear a boom" type message.  Unless you're
blowing up your entire game, you'll probably want to stop after a certain
distance.  You'll want to check if there's an event object in that room
already with the same id - or type; so you don't blow up people twice.
You'll probably also want to set a timer for the event to destroy itself -
or load a new event (flames?) - allowing for more events of that type to
occur.

  You can do this any way you'd like, iteratively, recursively, etc.  In
this case, we're assuming a radius-like explosion. If we assume that your
event is directed at something in particular; say a cry for help to the
guards, a bfs is probably the easiest way to find the shortest route on a
non-directed graph room-map like you have.  This lends itself to an object
view, as you can allow your object to choose how it propagates itself,
modifies itself, copies itself, etc. 

	If I didn't quite answer your question, sorry - I was a little
confused by some of the generalization.  I do hope this helps though.

PjD






_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list