|
BlackSmith Apprentice
Joined: 08 Dec 2002 Posts: 152
|
Posted: Sun Mar 26, 2006 7:15 pm
Trying to calculate the average of last 100 things |
There is numerous things that have regural outcome and a special out come and i try to get zMud to calculate them.
To make it to keep record average trough all time is easy but i want to keep track just the last 100 times the thing has happened.
I was thinking to simply make a data record that has running number and boolean if it was a special/critical, then use a for/while loop to calculate the true booleans.
The problem is, i not sure how to do it with the zMuds looper.
e.g. I hit a monster in the game for 53134th time and i score a critical hit.
How could i keep track how many criticals hit i have made betwean 53034 and 53134 swings? |
|
_________________ BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient. |
|
|
|
BlackSmith Apprentice
Joined: 08 Dec 2002 Posts: 152
|
Posted: Mon Mar 27, 2006 1:15 am |
Never mind, i found nice function to do it. Now it looks like.
Code: |
(A special hit is triggered) // Pattern part
#Addkey Special @Running_number true // Marks that this hit was truly a special one
#Variable Special.Counter 0 // Resets the counter for coming loop
#Variable accuracy 100 // Defines the accuracy
#LOOPDB @Special {
#If (@accuracy-@Running_number < %key & %val) {
#Add Special.Counter 1 // If the special hit is inside the accuracy range, it is counted
}
}
#Math Special.Average %float(@accuracy)/@Special.Counter // Counts the % for special hits and stores it
#Substitute {Special hit! (@{Special.Average}%)}
|
Now, the finishing touch would be to show that Special.Average in two decimal format instead the dozen or so, but i cant get the %format work.
%format(2, @Special.Average) gives simply null.
Help? |
|
_________________ BatMUD Best MMORPG around since 1990 telnet://bat.org:23
~ Magic & Mind beats Chrome & Meat anytime ~
Pattern(s) in PERL. Using Cmud 1.34/2.09 & BatClient. |
|
|
|
|
|