[MUD-Dev] Room-based vs. coordinate-based
Brandon J. Rickman
ashes at pc4.zennet.com
Sun Jun 29 17:40:50 CEST 1997
On Thu, 26 Jun 1997, Shawn Halpenny <malachai at iname.com> wrote:
>Brandon J. Rickman wrote:
>> On Mon, 23 Jun 1997, Shawn Halpenny <malachai at iname.com> wrote:
>> >An aside--given:
>> >Room R at time t=0.
>> >An earthquake is scheduled to occur in R at t+5.
>> >Room R is spoofed at t+2, creating R' which now exists in lieu of R.
>> >Time t+5 arrives, the earthquake occurs. Are the effects of the
>> > earthquake applied to R, R', or both? Generalized: are any
>> > actions occuring on R to be duplicated on R' and vice versa?
>>
>> This is a great example of a particularly bad (and quite common) way of
>> non-atomic coding. "Scheduling" an event in this case is like declaring
>> a prophecy: "There will be an earthquake in 5 ticks!"
>
>I disagree. Every event is a prophecy since every event must be scheduled,
>else nothing ever happens (events scheduled to happen immediately may be
>exempt). The objects affected, however, usually have no idea
>about the impending event, nor do they need to.
>
>And why do you consider it non-atomic?
It is non-atomic because the state of the universe might have (most likely
has) changed since the event was first scheduled. On execution the event
is now responsible for comparing its image of the universe with the real
universe (recognizing that R' has replaced R, for example). Put bluntly,
it may in fact be impossible for a "prophecied" event to conform itself
to the changed universe. It happens all the time. How many times have
you seen this:
> north
The Bar
Ratz is behind the counter, absently rubbing teh counter with a grimy rag.
> east
The Back Room
> up
Second Floor
Ratz waves to you from behind the counter. "Hey, Shoehorn, haven't seen
you around lately."
The problem isn't that Shoehorn walked out of the room before Ratz
greeted him. How about this:
The Bar
Ratz is behind the counter, absently rubbing teh counter with a grimy rag.
> wield knife
You wield the butcher knife
> remove the arm of Ratz with knife
You chop off Ratz's right arm. He looks pissed.
Ratz waves to you from behind the counter. "Hey, Shoehorn, haven't seen
you around lately."
Or this:
The Bar
Ratz is behind the counter, absently rubbing teh counter with a grimy rag.
The bar explodes into a brilliant fireball. You have died.
Ratz waves to you from behind the counter. "Hey, Shoehorn, haven't seen
you around lately."
Maybe you want to play this game of "what if" and program in all the special
cases you can find. But once you start you can never stop.
(The typo was intentional.)
>> I'll go out on a limb and claim that events must always immedidately
>> originate from objects. There should be no indirection of events, such
>> that an event might be scheduled by an object but actually be originated
>> as a server action.
>
>I'm not sure I understand. Are you saying that for the earthquake to
>occur, the evaluation of the decision (yes, make earthquake, no,
>don't) should occur and immediately after that there either is or is
>not an earthquake? I.e. there is no concept of having an earthquake
>occur in 5 seconds?
There is no _guarantee_ of having an earthquake occur in 5 seconds. You
can delay the evaluation of the decision for 5 seconds, and if the conditions
are right cause the earthquake. The event, if it occurs, originates from
the same object that originally delayed the evaluation. But if you pass your
earthquake event on to some cleverly coded scheduler your event has
become a kind of prophecy.
If this was a magically created earthquake we can make this problem part
of the risks of casting big magics. If Bubba cast the earthquake spell, but
the location for the spell has already been destroyed, where does all that
magical energy go? If we evaluate the decision immediately before the
event, the spell will no longer have a target and maybe it strikes Bubba
instead. Or maybe it goes off in Detroit.
To go even further: Let us say that casting an earthquake spell
has two parts: summoning the magical energy/Earth forces, and directing
those forces into the earth with destructive intent. The longer you wait
before directing the forces, the more forces you can gather and the
stronger the earthquake will be. Bubba is only a level 5 wizard and only
knows how to create small earthquakes. His earthquake spell takes 30 ticks
to complete: 25 ticks to gather the forces, a 4 tick pause (a little margin
for casting errors), and 1 tick to start the quake. His spell creates two
events, the first event of a certain duration (gathering the forces), the
second intended to occur at t+30 ticks. The earthquake might take a certain
amount of time as well, but I'm not worrying about that here.
During the 25 ticks that the forces are gathering, other things are
happening in the universe. Someone might siphon off some or all of those
forces, meaning a less powerful earthquake. Or Bubba might lose his
concentration and the earthquake goes off early. Or someone funnels extra
forces into the spell, creating an earthquake beyond Bubba's control.
The "success" of Bubba's casting is still in doubt until we get to that
t+30 marker or the spell is otherwise perverted. Both the originator
(quoted text below) and any indirection (below) of the event are in
fact crucial to the actual performance of the event.
>The earthquake was likely scheduled by whatever code was responsible
>for handling the success of Bubba's earthquake spell, but the
>originator of the event doesn't actually matter. The indirection
>doesn't matter either. The event and its (spoof) target can be
>considered independently of all other elements in the game (excepting
>the non-spoof target). I think the earthquake must be propagated to
>both R and R', since (assuming the effects of the quake persist
>beyond the life of R') when R' is terminated, you can't have the
>effects of the earthquake disappear as well. The +5 delta I
>mentioned above has nothing to do with how the event is processed,
>but was intended only to show that the spoofing, the earthquake, and
>the aftereffects did not occur at the same time. I could have
>synonymously said: 'Earthquake occurs in spoofed-room R'. If R' is
>destroyed before the effects of the earthquake are completely gone
>(i.e. the fissures in the earth, etc.), does R show the same
>effects?' To which the answer, I think, is "yes, definitely."
You don't consider the effects of the earthquake as just another spoof of
the original R? If the effects of the earthquake are permanent, why don't
we "flatten" R" (the earthquake spoof) and R?
Hm, if we have R' spoofing R:
R - R'
And the earthquake is a spoof R" of R:
R - R"
We have to relate R' and R". Maybe we need an parenthetical operator?
(R - R") - R' or possibly (R - R') - R"
This is becoming messy and confusing. Never mind.
>> I'm thinking cold-like frobs provide a way to solve this. Otherwise a
>> tighter way of relating the spoofed object to the object of spoofing is
>> needed. Then R gets the event and passes it on to it's spoof. This
>> would need quite a bit of garbage collection.
>
>I know not of frobs, and in the stuff above don't see where any garbage
>collection comes in.
R' is a spoof of R. R'' is a spoof of R'. R' has an event scheduled.
The condition causing R' goes away. Do we pass R''s event to R'', to R, or
dump it? If R' is destroyed, does R'' become a direct spoof of R, or do
we destroy R'' also? If we destroy R...
Frobs are (someone will correct me) instances of objects that can be passed
around like data. Who has them besides ColdC?
- B Rickman
More information about the mud-dev-archive
mailing list