Page 3 of 3

Re: TEST: Barbarians

Posted: 17 Jan 2012, 21:16
by Jenalya
I just updated the testserver. There is a new monster in the snow area and the scripts of the barbarian quests got some refactoring/clean-up from cody and me, so the entire quests should be tested again. The changes aren't that much visible to the player (beside of some dialogue tweaks), but the code structure got much cleaner.
Additionally I reduced the amounts of wolverns per ambush, but increased the number of overall wolverns needed for the quest.
jessyb03 wrote:My first ambush was of 3 wolverns and if I kept my distance I would survive. But after about 20 more steps, another ambush happened with 7 more wolverns and I instantly died.
After trying it again myself, I think seven are a bit much for the level it's intended for. :wink:

Everyone, thanks for testing and especially for giving feedback here. :)

Re: TEST: Barbarians

Posted: 21 Jan 2012, 18:22
by Nard
I tested again Barbarians quests and noticed the following:
  • I was still able to cheat during a certain time before I got killed: inma and frillyar. Even if fluffies killed by frilliar are not counted, killing extra mobs can help.
  • I tried to drop food items one by one and by various numbers. The probabilities to get a certain number of extra mobs while dropping n items separately or at once appears to be different and it should not be the case
I will discuss here only the second point.

The cause of the problem as we could see in a discussion I had with Jenalya is the uniform distribution generated by the function rand(). This distribution should not be uniform. I suggest the following algorithm in pseudo-code form.:

Code: Select all

// generation of a binary random variable  X with probability p of being one ( Bernouilli alternative). Each X=1 in a trial will make an xtra mob spawned.
//p belongs to [0, 1] interval and can be a function of the character level, but should stay relatively low or the quest may become unfeasible to high levels.
//I assume here that rand(0,1) returns a random real number uniformly distributed in [0, 1] as described in the wiki.
//The optional argument lets you vary the seed of the sequence .
//
if (rand(0,1)≤p) then X:=1 else X:=0; // rand(1)
//
//generation of a random integer variable Y  Y = k in {0, 1, 2 , ... n}, which will be the number of mobs spawned. 
//[i]n[/i] is the number of food items dropped. Trials are supposed to be independent, thus Y is the sum of n previous X variables (Binomial variable).
Y:=0
repeat from i  = 1 to n {
    if rand(0,1)≤p then X:=1 else  X:=0;
    Y:= Y+X;}
//
//there are faster ways to generate Y with large trial number n but I could not find  the necessary math functions in doc.
//then you call  spawn (Y [mobs #], mobmaxlevel(char(level))); 
// 
note: I'm not sure that it is necessary to have the probability of the mob number to increase if their level does.

Re: TEST: Barbarians

Posted: 23 Jan 2012, 02:57
by Freeyorp101
Nard wrote:The cause of the problem as we could see in a discussion I had with Jenalya is the uniform distribution generated by the function rand(). This distribution should not be uniform. I suggest the following algorithm in pseudo-code form.:

Code: Select all

// generation of a binary random variable  X with probability p of being one ( Bernouilli alternative). Each X=1 in a trial will make an xtra mob spawned.
//p belongs to [0, 1] interval and can be a function of the character level, but should stay relatively low or the quest may become unfeasible to high levels.
//I assume here that rand(0,1) returns a random real number uniformly distributed in [0, 1] as described in the wiki.
//The optional argument lets you vary the seed of the sequence .
//
if (rand(0,1)≤p) then X:=1 else X:=0; // rand(1)
//
//generation of a random integer variable Y  Y = k in {0, 1, 2 , ... n}, which will be the number of mobs spawned. 
//[i]n[/i] is the number of food items dropped. Trials are supposed to be independent, thus Y is the sum of n previous X variables (Binomial variable).
Y:=0
repeat from i  = 1 to n {
    if rand(0,1)≤p then X:=1 else  X:=0;
    Y:= Y+X;}
//
//there are faster ways to generate Y with large trial number n but I could not find  the necessary math functions in doc.
//then you call  spawn (Y [mobs #], mobmaxlevel(char(level))); 
// 
note: I'm not sure that it is necessary to have the probability of the mob number to increase if their level does.
tmwAthena uses a mersenne twister to generate random numbers, not rand() directly.


---Freeyorp

Re: TEST: Barbarians

Posted: 23 Jan 2012, 03:28
by Nard
cody wrote:I disagree with that. It is good to reward the braveness to fight many fluffies at once with less extra mops. After all fluffies can easiely kill a high level player, if there are many of them. Furthermore with your solution the best strategie would be to drop one food item at a time, which is only feasible with a patched client.
Cody, my intention was not to cheat with the quest when I tried small fluffy number. I wanted to see if it was feasible by a mage with low defense. As the code is, it is very difficult, and even impossible to do if the mage level is high. I am not a "restat" adept :). And yes, I used Manaplus to do this test: it allows me to switch among 9 predefined chars instead of 3, thus making the tests faster. :) By the way spawning too little fluffy numbers may make you reach the time limit with unsufficient number of kills and fail, even with the drop shortcut. Thus i still consider the the probability of getting k extra mobs when spawning n fluffies should be the same whenever you spawn them separately or at once. It does not make the small group spawning much easier.

Cordially,

Nard

Re: TEST: Barbarians

Posted: 23 Jan 2012, 03:41
by Nard
Freeyorp101 wrote:tmwAthena uses a mersenne twister to generate random numbers, not rand() directly.
what I suggest here is to generate a random number according to binomial probability distribution function instead of the uniform one given by the script function rand(). I don't want to replace the server one, which seems nice to me at the moment. Sorry if the form of the pseudo code I used could make you believe the opposite.
On another side, it could be interesting to scripters to have additional functions for random number generation without modifying the existing one. I think that this quest is an example.

Cordially

Nard

Re: TEST: Barbarians

Posted: 23 Jan 2012, 11:46
by Freeyorp101
Nard wrote:
Freeyorp101 wrote:tmwAthena uses a mersenne twister to generate random numbers, not rand() directly.
what I suggest here is to generate a random number according to binomial probability distribution function instead of the uniform one given by the script function rand(). I don't want to replace the server one, which seems nice to me at the moment. Sorry if the form of the pseudo code I used could make you believe the opposite.
On another side, it could be interesting to scripters to have additional functions for random number generation without modifying the existing one. I think that this quest is an example.
My apologies, I had misinterpreted what you were suggesting.

In the past, when there has been need to bias results away from extreme values, rand() was called twice or thrice with appropriate maximums and the result summed. Increasing the number of polls to N where N is the overall maximum is probably overkill for what you're looking for. That said, for a simple p=0.5 distribution you could optimize it somewhat by counting the bits set.


---Freeyorp

Re: TEST: Barbarians

Posted: 02 Feb 2012, 07:20
by Jenalya
On the testserver there are some fixes to Kimarr and the wolvern ambushs. They'll be put on the main after some testing. Everyone is welcome to help with that. :)

Re: TEST: Barbarians

Posted: 10 Feb 2012, 09:55
by Nard
I tested 5 times with no problem