Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Ithilion
Wanderer


Joined: 02 Sep 2005
Posts: 85

PostPosted: Fri Mar 06, 2009 4:37 pm   

#switch and large amounts of checking..
 
It seems that #switch cant process things as fast as they come up, spellups in Aard with saffects (briefdesc for affects) come to mind.. Suggestions on how to improve would be considered.. but this is a general comment, really.. I'm just wondering if large amounts of variable checks affect one #switch statement, this badly..
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Mar 06, 2009 5:06 pm   
 
Well, yeah, if you're trying to run a ton of script very many times very fast it'll cause you problems. I doubt it's anything specifically to do with #switch, but more to do with your use of it. Basically, you'll want to reduce the number of variable calls to as few as possible and use local instead of global variables. You should avoid repeating yourself as much as possible. Some ways of solving a problem will be slower than others, too - like traversing lists, or code that needs to be compiled before it can be run (like with #exec).

This is all general stuff and probably isn't terribly useful for you. If you want specific advice about your script, we really need to see it.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Ithilion
Wanderer


Joined: 02 Sep 2005
Posts: 85

PostPosted: Fri Mar 06, 2009 5:20 pm   
 
I use a variable based spellup (not my code initially); however, I'm thinking it's best if I redo it entirely; the issue is herein, if you have a status window, should you use local or global vars, because that's the only reason I need global

Only three commands are used enough to warrant #switch, as they all (used to/use) #if statements, which is why the main reason I switched to #switch, however, i'm just using one class/trigger (which is on #switch) when I check for saffects, and the variables dont get processed quickly enough, it seems to get skipped over a lot when running said alias.

If you really want the code, I would be more inclined to PM, because the person who shared his original code wanted me to not share it with anyone else, but he's not available, also has not switched over to cmud, so I cant ask him to help here.. Anyway, the point is, there are 75 some-odd, give or take a few, spellup spells that can be casted, and thus a variable check for every one of them run off saffects, which lists all spellups on you currently.. that's a lot of processing for one #switch
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Mar 06, 2009 5:33 pm   
 
Are you certain it is just this one trigger that is causing the problem? If you have lots of other triggers, it could also slow things down just trying to match each trigger against each line, when lines come fast from the mud.

Local variables don't exist after the trigger is run, so the status window cannot depend on local variables--it does need global variables.

I'm not sure what you mean by "it seems to get skipped over a lot". What is being skipped over? Nothing should be skipped over, so I guess I don't understand what you mean.
Reply with quote
Ithilion
Wanderer


Joined: 02 Sep 2005
Posts: 85

PostPosted: Fri Mar 06, 2009 5:45 pm   
 
In this case, like I said, 75 spells. I have a variable for /most/ if not all spells, if saffects shows a spell as being on, then that variable is changed accordingly. the "skipover" part is due to massive switching, as it were.. from something that could contain up to 40 spells at once to sift through. The triggers arent the issue at all here, however, I do have some that arent updating their respective variables themselves, but that isn't the issue. the issue is some spells are being skipped due to the saffects command being processed too fast.
Reply with quote
Ithilion
Wanderer


Joined: 02 Sep 2005
Posts: 85

PostPosted: Fri Mar 06, 2009 5:57 pm   
 
Edit: post edited to move it to a different topic.


Last edited by Ithilion on Fri Mar 06, 2009 9:31 pm; edited 1 time in total
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Mar 06, 2009 9:10 pm   
 
Better make the question about the mapper a completely separate post, and yet another post about the trigger you think is not firing. Try to keep each post about a single issue.

Quote:
the issue is some spells are being skipped due to the saffects command being processed too fast.

What does this mean? It does not make sense in relation to the way that Cmud processes lines. Cmud will not go on to the next line from the mud until it has finished processing the current line, or spawned a separate thread to handle it. Nothing from the mud gets skipped over. Things may run slow, and display may lag behind the actual mud output as cmud processes lines, but I do not understand what you mean about spells being skipped over.
Reply with quote
Ithilion
Wanderer


Joined: 02 Sep 2005
Posts: 85

PostPosted: Fri Mar 06, 2009 9:30 pm   
 
Rahab wrote:
Better make the question about the mapper a completely separate post, and yet another post about the trigger you think is not firing. Try to keep each post about a single issue.

Quote:
the issue is some spells are being skipped due to the saffects command being processed too fast.

What does this mean? It does not make sense in relation to the way that Cmud processes lines. Cmud will not go on to the next line from the mud until it has finished processing the current line, or spawned a separate thread to handle it. Nothing from the mud gets skipped over. Things may run slow, and display may lag behind the actual mud output as cmud processes lines, but I do not understand what you mean about spells being skipped over.


I meant the code, I'm sorry, I napped, I make more sense now. >< the actual switch code is being skipped in parts, because, again, there is one variable for each spell affected.

Like,

Code:

spell_status reset to its startup value
saffects


You are affected by the following:
Spell   : Enhanced strength (25:07)
Spell   : Giant strength (25:08)
Spell   : Levitation (13:50)
Spell   : Mental barrier (10:50)
Spell   : Armor (22:50)

It'll change the strength vars, then skip levitation, mental barrier then change armor.. so on, so forth for all the rest of the spells in list if it shows up in list

This is all handled by one switch, basically #switch (%1=Armor) {armor variable ON} (%1=Mental barrier) {mentalbarrier variable ON}, so on, so forth
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Fri Mar 06, 2009 10:41 pm   
 
The problem is that in fact you're using a switch statement, and this is how switch statements are designed to work. For example:

Code:

x=1
#switch (@x<=0) {#print 0}
  (@x<=1) {#print 1}
  (@x<=2) {#print 2}


is equivalent to

Code:

x=1
#if (@x <= 0)
  {#print 0}
  {#if (@x <= 1)
    {#print 1}
    {#if (@x <= 2)
      {#print 2}
    }
  }


And both of those will print 1 but NOT 2. Note the nesting of the if-else-if. It goes until it finds the first true expression, executes the associated commands, and then leaves the entire statement. What you want is more of:

Code:

x=1
#if (@x <= 0) {#print 0}
#if (@x <= 1) {#print 1}
#if (@x <= 2) {#print 2}

Which should print both 1 and 2.
Reply with quote
Ithilion
Wanderer


Joined: 02 Sep 2005
Posts: 85

PostPosted: Fri Mar 06, 2009 11:40 pm   
 
I converted FROM that.., ah well. :P
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sat Mar 07, 2009 5:05 am   
 
Actually, on re-reading, that's probably not the problem.

Have you double checked to make sure the values you're checking against, "Mental barrier" and so on, are correct in your script?
Reply with quote
Ithilion
Wanderer


Joined: 02 Sep 2005
Posts: 85

PostPosted: Sat Mar 07, 2009 6:05 am   
 
Yup, everything is formatted from the original #if's which checked just fine in zmud.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sat Mar 07, 2009 12:48 pm   
 
Can you run a few tests?

a) Set up a handful of spells and run your script say, five times. Note which ones it misses each time, and if they're the same ones each time.
b) Unspell or let expire or whatever the ones it -caught correctly- last time. Run the same test again.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net