1. RE: weights of nested containers
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Feb 16, 2004
- 550 views
> -----Original Message----- > From: Michelle Rogers [mailto:michellerogers at bellsouth.net] > Subject: weights of nested containers > > > > I am writing a mud progam in Euphoria. Currently I have each > character with > a certain amount of strength. Depending on their strength, > they can pick up > a certain amount of weight. They can even pick up other > characters, if they > are strong enough to pick up the weight of the other character. > > The way I currently do this is that the weight of the person > being picked up > is evaluated. If they are too heavy, a message is given. If > they are not > too heavy, the person picks them up. > > However, here's the problem, what if you are trying to pick > up a person, who > is carrying a person, who is carrying a person, who is > carrying a person, > etc..etc.. > I cannot get a logic in my head that would allow you to go through an > unspecificed number of "carriers" and check the weight of > everything they > are carrying. This COULD be solved by just saying you can't > carry someone > who is carrying someone else....However, I will have the > problem again, when > I have to deal with things like....a backpack that contains a > pouch, that > contains a bag...etc..etc... How about something like this... function CalcWeight( object pHolder) atom lWeightSoFar lWeightSoFar = pHolder[kWEIGHT] for i = 1 to length(pHolder[kCarrying]) do lWeightSoFar += CalcWeight( TheWorld[ pHolder[kCarrying][i] ] ) end for return lWeightSoFar end function TotalWeight = CalcWeight ( theObject ) This assumes you have a sequence that holds all the data for an entity, and that sequence has a weight attribute and a list of things (an index into the 'world') that the entity is carrying. > Can someone help me figure out a logic for this. > > There is a variable on every object in the mud that I call a "roomin" > variable. I started it to tell which room a player or object was in. > However, each "thing" in the mud has a unique id. So, I've > changed it so > that the "roomin" variable doesn't have to point to a room. > This is how you > can be carried by another player. Instead of your "roomin" > variable having > the id number of a room, it has the id number of the person > carrying you. > So, in theory, you are "inside" the person carrying you > (according to the > data structure, anyway) > > So, here's how it would work. To know if someone is carrying > someone, I > have to check all players and see if their "roomin" variable > is the id of > the person I am checking. That's easy enough and I can add > the weights of > ...let's call them the "first generation of people being > carried". However, > it's when I start to check the roomin variables of everyone > to see if they > are carried by the first generation carriers, that I start to run into > problems. Sure, I can do that. It's basically the same thing. > > But, how do I tell the code to keep checking until I've > gotten to the end of > everyone who's being carried (i.e. the "last generation" of > people being > carried)? > > hmm...as I actually typed out an explanation..I'm getting a > sort of a hazy > idea..so I may figure this out..but I'm still going to post > the message, > just in case. > > Michelle Rogers > > > > TOPICA - Start your own email discussion group. FREE! > >
2. RE: weights of nested containers
- Posted by "Elliott S. de Andrade" <quantum_analyst at hotmail.com> Feb 16, 2004
- 532 views
>From: Michelle Rogers <michellerogers at bellsouth.net> >Subject: weights of nested containers > >I am writing a mud progam in Euphoria. Currently I have each character >with >a certain amount of strength. Depending on their strength, they can pick >up >a certain amount of weight. They can even pick up other characters, if >they >are strong enough to pick up the weight of the other character. > >The way I currently do this is that the weight of the person being picked >up >is evaluated. If they are too heavy, a message is given. If they are not >too heavy, the person picks them up. > <snip> I think what you can do is, when a person picks up something, its weight increases by the weight of the picked up thing. That way, you don't even need check any other objects. When you stop carrying the object, you just decrease the carrier's weight by the object's weight. >But, how do I tell the code to keep checking until I've gotten to the end >of >everyone who's being carried (i.e. the "last generation" of people being >carried)? > Well, you could possibly do some recursive thing, but some people find it somewhat confusing. >hmm...as I actually typed out an explanation..I'm getting a sort of a hazy >idea..so I may figure this out..but I'm still going to post the message, >just in case. > >Michelle Rogers >
3. RE: weights of nested containers
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Feb 16, 2004
- 522 views
> -----Original Message----- > From: Michelle Rogers [mailto:michellerogers at bellsouth.net] > Subject: Re: weights of nested containers > > > > That was part of the problem. I only have each thing being > carried have a > number that marks what they are being carried by... I don't > have a sequence > that holds everyone/thing that is being carried. Will I need > to have it > like that? I didn't WANT to do it that way. But, am I going > to have to? > > Currently to find out what is being carried by a person, here is an > example....when the person enters the room, the message say > "<Name> enters." > however I wanted it to say this if they were carrying someone........ > "<name> enters, carring <othername> over their shoulder." This is the > function that generates the part of that message from the > comma on.....This > is how I check to see who's being carried. > > function carrymessage(integer whichplayer) > sequence thecarrymessage,hisher > integer foundit > > > --This is just to determine gender of person entering the room > if mudthings[whichplayer][8][22]=1 then hisher="his" else > hisher="her" end > if > > --Foundit determines if they are carrying anyone at all, so > as to finish the > message, if they are > foundit=0 > thecarrymessage="" > > --mudthings include players, mobiles, objects, and rooms > for x=1 to length(mudthings) do > > --mudthings[x][5] is what "room" this one is in > --mudthings[whichplayer][1] is the id number of the person being > checked, which determines if the "room" is actually that > person, which would > mean they are > carrying this person > if mudthings[x][5]=mudthings[whichplayer][1] then > if length(thecarmessage)<0 then > thecarrymessage=thecarrymessage&", carrying > "&mudthings[whichplayer][2] > else > thecarrymessage=thecarrymessage&" and > "&mudthings[whichplayer][2] > end if > foundit=1 > end if > end for > > if foundit=1 then > thecarrymessage=thecarmessage&" over "&hisher&" shoulder" > end if > > return thecarrymessage > end function > > > To be able to do nested weights...am I going to HAVE to put it into a > sequence, instead of checking each time? > No, of course you don't HAVE to do it that one. I was just suggesting a more efficient method than checking the entire world every time somebody moves into a room. It was just a bit of optimisation. The key thing is to have a way to determine who is carrying what, and you have that already. My algorithm for calculatin the weight will work in either case. -- Derek
4. RE: weights of nested containers
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Feb 17, 2004
- 502 views
> -----Original Message----- > From: Elliott Sales de Andrade [mailto:quantum_analyst at hotmail.com] > Subject: Re: weights of nested containers > > > > >From: Michelle Rogers <michellerogers at bellsouth.net> > >Reply-To: EUforum at topica.com > >To: EUforum at topica.com > >Subject: Re: weights of nested containers > >Date: Mon, 16 Feb 2004 18:24:52 -0500 > > > >OH Wait!! I hadn't thought about it like that! > > > >I think what you are saying is this.. > > > >If a player weighs 50 stones.... > > He picks up an apple that weighs 1 stone... > > Now, his weight is reset to 51 stones > > > >Is that what you are saying??? *rolls her eyes* I ask > because it was so > >easy I'm slapping myself...*smirks* I was trying to make it > too hard. > > > > Yep, that's exactly what I meant. Be aware that when you drop an article, you need to subtract its weight from *all* the effected carriers of the article. For example, if a man (100 units) is carrying bag (3 units) that contains a box (10 units) that contains a gold nugget (25 units). When he is carrying all of this, the box weighs(10+25=35), the bag now weighs (3+35=38) and he weighs (100+38) =138. When he drops the gold, its weight must be subtracted from the box, bag and man. -- Derek