Best python way to do 'object messaging'
Philip Swartzleonard
starx at pacbell.net
Mon Feb 11 16:19:30 EST 2002
Patrick K. O'Brien || Mon 11 Feb 2002 11:59:17a:
>
> Philip,
>
> You might find this code helpful:
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/87056
Well, yes, that does look useful, but for a different problem. (When i
rip things apart and seperate the UI and data stuff, i could probably
use it :).
What i'm doing is pretty much modling stimuli (sort of a vague cousin of
the 'command' pattern), as one-way messages into an object that is
simulating some entity (like an orc :). A good example would be a sound.
A sound would be a message... actualy a lot of messages. They would be
propigated through the envorment with some function
(apply_message_radius or somthin'), and for each cell (assuming a grid
map) covered by the radius (or until the volume passes below some range)
a copy would be sent to that cell with it's volume property affected by
1/r^2 falloff. That cell would copy the messages to each of it's
objects, which could do whatever they want with it. For example, if
there was a functioning ear attached to some creature, it could recieve
the message (with a chance for garbling and a check against hearing
thresholds), and pass it along to the AI of the creature.
It needs to be copied because various things in the depth of the passing
can filter and modify the message, and this must not affect other things
in the breadth of the passing. Creature A's fire ring has to reduce the
value of a fire damage message for the creature, but must not do so to
the message that Creature B will see.
I already have a solution to this problem, however, see the 'Is
this...evil?' thread for more ;).
Sorry if it's hard to follow... i'm sick, muddled, and short on time. :)
(brain->page with less filtering than usual :)
--
Philip Sw "Starweaver" [rasx] :: www.rubydragon.com
More information about the Python-list
mailing list