Tuesday, May 29, 2012

Understanding RNG

Mahjong Time receives occasional questions and concerns regarding  the fairness/ randomness of the gameplay on the site. While every player’s opinion and feedback is very important to Mahjong Time (we read every email and reply to nearly each one), I would like to offer the community my perspective on this issue. Admittedly, I am not a mathematician or statistician, but through the process of building the game, constantly testing and retesting the fairness and security of the site, and discussing concerns with members of the community, I have become very familiar with this issue.

How Randomness Works at Mahjong Time
Mahjong Time, just like most of other online gaming websites uses a special program called the ‘Random Number Generator’ (or RNG for short) to randomise every single game played on the site. The RNG is not a simple tool; it uses formulas called algorithms which are a series of instructions to generate the numbers that correspond to the different aspects of the game. The complexity and scope of these algorithms are beyond most of our mathematical knowledge, but through testing and analysis have proven to be accurate and dependable in generating random numbers.

The RNG works to generate the wall before each hand, and just like in real life, the tiles are then drawn from the shuffled wall in the middle of the table. This method has been been key in simulating real-life Mahjong from the very first version of the game. Mahjong Time even hosted a test a few years ago in which players joined a Mahjong Time game, the wall was generated, and players began to draw tiles from the wall as our staff sent out chat messages to make sure that the tiles did in fact come out of the wall and were not generated when drawn. This test demonstrated that the wall was in fact generated before the game.

Truly random numbers are the heart of online gaming. The entire Mahjong Time business depends on games being fair and secure, so that we may be recognised by all players as a credible and safe place to play. Mahjong Time succeeds simply by offering the best online mahjong experience for our players. I cannot imagine a reason for Mahjong Time or any other online gaming website to favor any player or group of players in any way. Favoring any group would drive away any players not in that group, and that’s simply bad for business.

While everything i’ve stated above is fact, it has still been difficult to gain the confidence of every player at Mahjong Time.

Psychology of Randomness
I believe that the concerns that players have are not rooted in the system’s programs or algorithms, but are in the psychology of pattern recognition. As humans, our brains are very good at analyzing information and developing patterns based on our observations. If we observe a common event (like having a dragon tile in your hand, for example), we recognise it as common and think nothing of it. The opposite is true for a rare event. If we observe a rare event (like starting with all four white dragons in your hand), we recognise that it seldom happens and process it accordingly. So, theoretically, rare events in Mahjong should happen rarely. However, the term “rare event” is not defined.

There are many examples of “rare events” in Mahjong, such as:
-Starting with all four dragons in your hand
-Assembling an All Kongs hand
-Winning five times in a row (assuming properly matched skill levels)
-Picking the same tile from the wall three or four times in a row
-a few self mahjongs in a row
the list can go on, and on, and on. So because there are so many examples of “rare events” any player is bound to see one eventually, making all of them, as a group, not rare at all. Even the rarest of events (lets say 1 in 10,000 chance) will statistically happen at Mahjong Time today in the tens of thousands of hands that will be played at Mahjong Time today. So it’s no surprise that many players see rare things happen constantly while playing.

Let’s take an extremely rare example of winning the lottery twice in one year. Statistically, this will never happen to you or me (I don’t buy lottery tickets :) ). But, when the very small chance of winning a certain lottery (1:5,153,632) is expanded to the scale of everyone who plays the lottery, one person ends up winning twice in one day: http://usnews.msnbc.msn.com/_news/2012/04/24/11370933-lucky-mistake-virginia-woman-wins-1-million-lottery-prize-twice-in-one-day?lite

A common question I receive on this topic is “When playing real-life Mahjong I see a self-mahjong 2-3 times in one evening, but at Mahjong Time is see it happen 5-6 times in a evening. What’s going on here? Is Mahjong Time favoring the self-mahjong?” Well, when I play Mahjong in real life, a hand can take 20-30 minutes, with setting up the wall by hand, throwing dice, talking with my friends and family at the table. One great thing about Mahjong Time is that the set up is automated, there is a move timer, etc., which means that you can play a hand twice as fast. Therefore, you can play twice as many hands in a evening, and consequently, see twice as many self-mahjongs.

Another example of player feedback we have received addresses a perceived increased rate of self-drawn wins: “The game has flaws, too many self mahjongs” I don’t know what the “ideal” rate for self-drawn wins is supposed to be. In my experience it has always varied depending on the style I’m playing and the skill level of my opponents. More skilled players tend to not throw “hot” tiles (tiles that someone can use for Mahjong) as often. I am a player of moderate skill level, and even I have felt a sixth sense for tiles to absolutely NOT throw in order to not give my opponent Mahjong. So perhaps, when players improve in skill and start playing against more advanced opponents, they see more self-drawn wins.

One thing that cannot logically cause more self-drawn wins is the RNG or Mahjong Time program in general. As I said above, the wall is generated before the game, so there is no way that the RNG can decide who gets what kind of Mahjong. This kind of logic is akin to blaming the person who shuffled the tiles in real life for the series of moves each player makes during a game that lead to Mahjong. And once again, there is no imaginable business reason we would favor any players.

You win some, you lose some...
Unfortunately, bad outcomes seem to stick out in one’s mind far more than good ones. it would be fantastic if our minds worked the other way around. Everyone loves to win, and wants to win all the time, but we are disappointed at our losses.  I found it curious that in all the years that Mahjong Time has been operational we have never received an email saying “I won 5 times in a row, your Random Number generator is broken!” However, “I lost 5 times in a row, there is a problem with the RNG” is quite common. And as I said, all feedback is read and appreciated, but I assure you, Mahjong Time is never responsible for your win or loss.

I would love to hear your opinions and perspectives on this issue. This article is meant to be an open discussion. Do you feel that Mahjong Time is fair? Are you confident in how the wall is generated? Have you seen any interesting, rare or even bizarre outcomes in a game?

Thank you for reading, please let us know if you found this interesting or if you have any opinions you want to share below.

Best regards,
Slava Novozhenya
Mahjong Time CEO


Anonymous said...

Many thanks for this post.

This has been quite a wonder to me, how RNG in reality works. What I’m concerned of is that if it works like it works with real tiles. I think not. But on the other hand, I haven’t played games with real tiles that often that I could say it really differs. The feeling of draws are different, though.

Is that bad thing? I’d say no. As long as it is really random, it is good as anything. I was under impression there was some magic, since draws seemed to favor players at some point of scores, always. But must be me...

Greg said...

I witnessed really bizarre events in real life Mahjong, and luck is a cruel joker there too. So, I can't objectively say MT works oddly with randomness. Even if it looks so!

Anonymous said...

I agree 100% with Slava, and as a (former) cognitive scientist can affirm how powerful is the phenomenon of misperceiving randomness. Indeed, even statisticians who specialize in probability are often caught off-guard and know to be wary of their intuitions. Probability (randomness) is notoriously counter-intuitive.

These all-too-human misapprehensions about randomness are especially pernicious in the context of gaming. Ask any programmer who creates Backgammon or other games involving dice. They receive similar complaints and accusations of bias, and nothing they can say or do will convince some people that they use a RNG to create the dice rolls.

Some time ago, I suggested to MJT that they run a game of "duplicate" MJ, borrowing a procedure from duplicate bridge that removes randomness from the game. Paradoxically, this might -- and I emphasize "might" -- help to convince some that the people who they perceive as benefiting from a biased game are actually those with greater skill... when they see those same people winning when everyone is playing the exact same deals and "luck" cannot be a factor.

Best, Atticus

Greg said...

Wow I'd really like to test duplicate bridge in Mahjong!

Slava Novozhenya said...

Greg, Thank you for the suggestion on "duplicate" MJ. This is very interesting, indeed. I looked up the rules of duplicate bridge on wiki: http://en.wikipedia.org/wiki/Duplicate_bridge This is how I see it working in MJ. Please correct me if I am wrong:

Lets run through the easiest scenario which is 16 players, and we have 4 game rounds.

1. Each game round has an identical wall for every table in the tournament.
2. At the end of the first round we calculate the relative performance of each player playing the same hand. In our case there are 4 players that competed in the first round.
3. In the second round one has to change the opponents, and we calculate the relative performance of another 4 players at the end of the second round, and that goes on for another two rounds. So, one gets to 'meet' every player in the tournament.
4. At the end we summarize all relative performances to calculate the winner.

Please let me know if I understood this tournament model correctly?