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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: Wed Jun 30, 2004 5:47 pm   

Data Crunching - a matter of speed
 
Short version is, I have a script that works flawlessly, but takes 2-3 precious seconds to run. I'm looking for an alternate method that will speed up this process.

In DragonRealms, there are 65 different skills (and more coming!). For each skill, there is the name, how many ranks you have, what % to the next rank you are, and "field experience". You gain field experience by performing the skill, and over time, the field experience is "absorbed" and becomes part of your ranks. If you perform a skill a lot, say by using a shield in combat, your field experience moves from clear, to learning, to thoughtful, etc, and eventually becomes "mind locked". When a skill is mind locked, you cannot learn any more of that skill until some of it absorbs into the ranks. This in mind, it is very helpful to know what your field experience is at in a skill you're working.

My script checks experience, breaks it down into individual skills, then compares each skill's current rank and field experience with the last time it was checked (i.e. what's stored in their respective variables), and if they're different, it updates the variables and shows the new values in a different window.

Here is an example of experience output:
quote:

Circle: 11
Showing only skills with field experience.

SKILL: Rank/Percent towards next rank/Amount learning
Shield Usage: 31 23% learning Light Chain: 31 97% learning
Parry Ability: 30 99% learning Multi Opponent: 30 82% learning
Heavy Edged: 11 36% learning Brawling: 30 50% learning
Primary Magic: 60 25% thoughtful Harness Ability: 63 07% thoughtful
Power Perceive: 57 77% mind lock Magical Devices: 40 98% perplexed
Evasion: 35 75% learning Perception: 36 58% learning
First Aid: 40 60% learning Foraging: 31 22% learning
Scholarship: 49 88% learning Mechanical Lore: 49 95% learning
Appraisal: 70 59% mind lock Teaching: 42 11% thoughtful
Empathy: 48 91% learning

Time Development Points: 51 Favors: 5 Deaths: 1
Overall state of mind: clear


I've tried several methods to speed this process up, but to no avail. Granted, my computer is several years old, and sports a wimpy PII 450 Mhz processor.

In previous incarnations of this script, I've used individual triggers to gag most of the output, and 2 triggers to capture the actual data - one for the first column, and one for the second. All of these triggers were in a single class that I would turn on momentarily, then it would turn itself off on the {Overall state of mind} trigger. I used arrays, one for each skill named in the alias by using %replace(%1," ",""), with the ranks, %, and field exp as indices 0, 1, and 2 respectively.

I tried using a single trigger that uses %copy to figure out each value, and passing on both skills per line to the alias at the same time.

I turned all of the different gags into a single multi-state trigger, using LoopLines to capture all the data.

I replaced the arrays with individual variables, so each skill has 3 variables associated with it, using the scheme "#VAR %eval(@Skill)Rank %1", etc.

I changed the %copy trigger into a Perl regular expression.

I'm open to any new suggestions of how I might speed this up. I'm not entirely sure if the slow-down is happening while examining the data, storing the data, or displaying the data, but if zMUD gets hung for 2-3 seconds when I'm updating in middle of combat, that can be potentially really bad.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jun 30, 2004 6:48 pm   
 
Probably the easiest way to speed things up is to stop comparing values before updating. Just update everything to the current value whether it changed or not.

You might also consider making this a user-initiated action instead of running it off a trigger or alarm. That would prevent any chance of it causing an unexpected slowdown during combat.

One trigger should be sufficient for all the lines which have two skills. Use a stringlist to match the "Amount learning". You would need a second trigger for lines which only contain one skill. The pattern would look something like this:

(*):%s(%d) (%d) ({clear|learning|thoughtful|perplexed|mind lock}) (*):%s(%d) (%d) ({clear|learning|thoughtful|perplexed|mind lock}))
Reply with quote
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: Wed Jun 30, 2004 7:12 pm   
 
Thanks, that's something I didn't think about. I still want the script to output only those skills that have changed. I took the #VAR statements out of the #IF loop, and it sped up the whole process immensely.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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