Analysing eqemu RNG

Discussion in 'General Discussion' started by surron, Jun 30, 2016.

  1. Pithy

    Pithy I Feel Loved

    Messages:
    2,620
    Pythagoras speaks truth. In a million independent rolls of three 100-sided dice, you'd expect to see three equal rolls about 100 times. 83 streaks of three in your data isn't weird, surron.
     
    Last edited: Jul 2, 2016
  2. Bum

    Bum I Feel Loved

    Messages:
    2,647
    Haynar be haytin
     
  3. Bum

    Bum I Feel Loved

    Messages:
    2,647
  4. varren

    varren New Member

    Messages:
    1
    You are calculating the chance of getting a given number three times in a row, not any number.

    For example, the chances of getting two coin flips with the same face up (heads or tails) is 50%. The chance of getting heads twice in a row is 25%.

    Edit: oh pythagoras already said this...
     
  5. Lenas

    Lenas I Feel Loved

    Messages:
    2,968
    That's a little mean, there's only one person trying to get this change made.
     
  6. surron

    surron People Like Me

    Messages:
    552
    okay wise wizard pythagoras ty you are right my math was off.

    no where did i tell the devs to change it, it can not be argued that our RNG is not streaky and all i was trying to do was show that.

    haynar still wont answer me to say if p99's RNG class is different.
     
  7. robregen

    robregen Administrator Staff Member

    Messages:
    8,370
    Mambo and Lenas like this.
  8. cavedude

    cavedude Administrator Staff Member

    Messages:
    1,893
    I don't want to to get involved in this argument, but the reason why he won't answer is because P99 is a closed source project that he isn't in control of. Speaking as a developer, you tend to keep your mouth shut in these cases even if it is something relatively minor like RNG. From information that I have, their RNG is not much different than our own or stock EQEmu.
     
  9. Haynar

    Haynar Administrator

    Messages:
    3,637
    There are many cases on p99 that used to use for example, rand() % 100. I didn't like the distribution in many cases. So they were expanded often to go 10 x the values. So its expanded more over larger ranges. So instead it will do rand()%1000.

    I found the more constrained you were, the worse results. So I tried to use randoms up to 1000 usually.
     
  10. eldrich-family

    eldrich-family Member

    Messages:
    42
    sorry for the thread necromancy, but i figured i'd chime in on a few things.

    i would posit that the problem isn't the RNG or seeding itself. it's quite probably the hashing. typically, using modulo as a hashing function will give aberrant performance unless the table size (in this case, the number of sides on the virtual die being tossed) is a prime number sufficiently far form a power of 2 boundary. since most of these "rolls" are going to be modulo some form of 10^x (100, 1000, 10000) to produce some form of percentile PRN, it pretty much follows that there will be "chaotic" (in the fractal sense, where the model falters) events (streaks, holes, etc.).

    i suggest, when the dust settles from delivering PoP, that some experimentation be done around finding a better hashing function than modulo for creating PRN dice rolls in the server. obviously, performance will play an issue, no one wants to wait 3 seconds for a dice roll when the server has to generate (potentially) millions of dice rolls per second during heavy load.

    caveat emptor
    your mileage may vary
    void where prohibited by law
    past returns are no guarantee of future performance
     
  11. Mokli

    Mokli I Feel Loved

    Messages:
    2,455
  12. eldrich-family

    eldrich-family Member

    Messages:
    42
    ROFL @Mokli

    Futurama holds a special place in my heart. well played!
     
    Mokli likes this.
  13. showstring

    showstring I Feel Loved

    Messages:
    3,332
    Let's see
    100000000000x worse performance for an arguably 'better' RNG
    or
    deal with it?

    hmmmmmmmmmmmmmm
    Hmmmmmmmmmmm

    [​IMG]
     
    Sketchy and Manstache like this.
  14. Cadsuane

    Cadsuane People Like Me

    Messages:
    815
    It does make one wonder when the guild has destroyed 100 (figuratively) copies of Ancient: Lifebane, but can't get 6 copies of Ancient: Starfire of Ro to drop for the active mains to use.
    Both have the same listed bossed to drop from on AllaClone.
    I know that RNG be like it do, but muh P values!
     
    Last edited: Feb 25, 2020
    showstring likes this.
  15. Mokli

    Mokli I Feel Loved

    Messages:
    2,455
    That's what we need, more P hacking
     
  16. eldrich-family

    eldrich-family Member

    Messages:
    42
    i don't recall anyone after the necromancy requesting a "better RNG". the point i was trying to make is that the RNG is most likely fine, the problem could very well stem from the use of mod (% operator) IF that is what is being done. i'd have to look at the "dice roll" code to know for certain, so i'm going on a hunch and some hints given in earlier posts. using mod effectively strips (depending on the precision of your random range) 25-58 bits of randonmess to just dump out 5-6 bits, which could provide "interesting results", e.g.

    hypothetical random sequence: 3456690, 9490, 12939490. if you mod 100 each of those you get the same value, even though it could very well be a perfectly legitimate pseudo random sequence. hence, potentially legit RNG produces unintended streakiness.

    the modulus (%) operator is generally accepted as an operator with poor performance, and there are many suitable replacements with better performance, but you have to be careful because you can introduce other statistical anomalies depending on your usage.

    ultimately, it could be an interesting exercise, best left for after PoP goes live. wouldn't want to get the natives all riled up.

    for anyone interested (far from exhaustive but gives some beginning points to explore the idea):

    https://arxiv.org/pdf/1805.10941.pdf
    https://cs.stackexchange.com/questi...a-prime-number-as-a-mod-in-a-hashing-function
    https://en.wikipedia.org/wiki/Hash_function (lists other methods besides "division hashing" [mod operator])
     
    Last edited: Feb 25, 2020
  17. solar

    solar Administrator Staff Member

    Messages:
    1,194
    I can't tell if you're trolling and trying to rile people up or if you're serious.
    https://en.wikipedia.org/wiki/Poe's_law

    Random numbers and cryptographic hashing are interesting especially for generating secrets but for a video game it's sufficient to create an outcome that's not known in advance. Consider a function that simply takes the base 60 seconds from the wall clock and partitions it into above/below 30 to decide between 2 loot drops. If people don't know that it uses the wall clock, this is good enough to provide excitement when looting. If they do know, and they can influence the outcome, they're not gambling anymore and the excitement is gone - it just becomes another element of strategy to kill the NPC at the correct time, and it's pretty easy with a 30 second window for error. Now consider the most basic random() function seeded with the wall clock time. Do you think players can predict what loot will drop or how hard their melee round will hit for?
     
    Sketchy and Palarran like this.
  18. Loraen

    Loraen Well-Known Member

    Messages:
    266
    Eldritch I like your comment because it made me think! But I believe it is wrong. No hash function is perfect: if you have a 257 element hash table and all of your data happen to be divisible by 257, you are simply out of luck. The prime numbers are just less susceptible to this, because a nonprime number is vulnerable to any pattern in any of its divisors, e.g. if your data is divisible by 2 and you have a 256 element hash table, half of the buckets will be empty. But in this case the inputs should be very close to random, and therefore this effect is not MONK AC important.

    Also, I guess that the RNG is seeded once per thread, which means that you have the extra randomness created by the actions of the players. In other words, the BigLoot rolls you get are not consecutive from the RNG's perspective, but interspersed with thousands of other rolls for attack rounds and tradeskills and resistance rates and so on, and intuitively that should make them even more random. I suppose there is theoretically some sort of security vulnerability there!

    All that being said, considering that EQ mostly has fixed divisors, you might get a speed improvement by writing a macro that replaces the (moderately expensive) modulus with a multiplication and direct comparison.
     
    showstring likes this.
  19. Fadetree

    Fadetree People Like Me

    Messages:
    532
    The thing that gets me is the regularity of the streakiness. As was pointed out, you expect streakiness to some extent. There's no actual way to say that even an unreasonably long streak is somehow 'not random'. But after doing various tedious hours of TS skillups or the last 20 years, I find that I *always* see this pattern : a long streak of fails, followed by a short period of nearly every or every other is a skillup, then the next long streak of fails. Unless there is some kind of other machinery running in the process that is manipulating state (such as lowering the odds based on how many consecutive fails I've had, for instance), I should not see that same pattern every time I am skilling something up. The RNG seems to be streaky in a consistent pattern, and that's odd. That's what has me wondering, not just that the RNG is 'streaky'.
     
  20. showstring

    showstring I Feel Loved

    Messages:
    3,332
    Not streaky

    [​IMG]


    [​IMG]
     
    Last edited: Mar 2, 2020
  21. Fadetree

    Fadetree People Like Me

    Messages:
    532
    well, it always is for me.. I mostly notice it on spell skillups trying to learn abj. But also on getting various chars up to medium levels of baking, pottery, etc, its always as I described. I will post logs next time I do it.
     
    Last edited: Mar 2, 2020
  22. solar

    solar Administrator Staff Member

    Messages:
    1,194
    This line of thinking is similar to worrying about black cats, ladders, breaking mirrors or opening umbrellas and such. Maybe some people are just joking, I don't know.

    Consider how you would even go about implementing a system that assures 'streakiness'. This is hard, you have to record state, and each time you want to pull a random outcome for something, you have to consider the state and the history. Where do you partition it, is it by character, by guild, by race/class, on combining gloves in a sewing kit, on abjuration skill ups? All of them? Are some activities going to have longer streaks? Do streaks time out or reset after a while?

    One game I know of that does do something like this is Diablo III. It appears to be random at first glance, and some of the drops really are, but with there being so many items and stats, if it was fully random it would take people 10 years to get a BiS set, so it's not random, it just gives you random crap in between the assured upgrades. This is also done for the profitable pay-to-win mobile phone games. Apparently, to get people addicted you need to give them a reward but you also need to deny them 'randomly' to maximize the effect. So imagine how much worse this game could be if it really was tweaked for maximum addiction effect..

    EverQuest is pretty old and low tech compared to these modern psychology manipulating games with curated randomness. Even really crappy randomness is good enough for a game to be entertaining though, because gambling is a thing.
     
  23. Placer

    Placer Well-Known Member

    Messages:
    577
    Some of these streaks that are being seen in loot are not the result of the RNG. Unless the code has changed since the discussions I had a few years back, two drops that should be independent or say 50-50% might not be even if the expected percentages are being used.