TEST: Barbarians

Content and general development discussion, including maps, quests, and server code from the development team.
User avatar
Jenalya
TMW Adviser
TMW Adviser
Posts: 718
Joined: 22 Sep 2010, 20:28

Re: TEST: Barbarians

Post by Jenalya » 17 Jan 2012, 22:16

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. :)
User avatar
Nard
Knight
Knight
Posts: 1113
Joined: 27 Jun 2010, 13:45
Location: France, near Paris

Re: TEST: Barbarians

Post by Nard » 21 Jan 2012, 19:22

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.
User avatar
Freeyorp101
Administrator
Administrator
Posts: 754
Joined: 04 Nov 2008, 10:17
Location: New Zealand

Re: TEST: Barbarians

Post by Freeyorp101 » 23 Jan 2012, 03:57

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
(09:58:17) < tux9th> Freeyorp: your sig on the forums is kind of outdated
User avatar
Nard
Knight
Knight
Posts: 1113
Joined: 27 Jun 2010, 13:45
Location: France, near Paris

Re: TEST: Barbarians

Post by Nard » 23 Jan 2012, 04:28

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
User avatar
Nard
Knight
Knight
Posts: 1113
Joined: 27 Jun 2010, 13:45
Location: France, near Paris

Re: TEST: Barbarians

Post by Nard » 23 Jan 2012, 04:41

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
User avatar
Freeyorp101
Administrator
Administrator
Posts: 754
Joined: 04 Nov 2008, 10:17
Location: New Zealand

Re: TEST: Barbarians

Post by Freeyorp101 » 23 Jan 2012, 12:46

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
(09:58:17) < tux9th> Freeyorp: your sig on the forums is kind of outdated
User avatar
Jenalya
TMW Adviser
TMW Adviser
Posts: 718
Joined: 22 Sep 2010, 20:28

Re: TEST: Barbarians

Post by Jenalya » 02 Feb 2012, 08:20

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. :)
User avatar
Nard
Knight
Knight
Posts: 1113
Joined: 27 Jun 2010, 13:45
Location: France, near Paris

Re: TEST: Barbarians

Post by Nard » 10 Feb 2012, 10:55

I tested 5 times with no problem
"The language of everyday life is clogged with sentiment, and the science of human nature has not advanced so far that we can describe individual sentiment in a clear way." Lancelot Hogben, Mathematics for the Million.
“There are two motives for reading a book; one, that you enjoy it; the other, that you can boast about it.” Bertrand Russell, Conquest of Happiness.
"If you optimize everything, you will always be unhappy." Donald Knuth.
Post Reply