Take the 2-minute tour ×
Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

I would like to know with what probability the number 4 appears in the grid of the game 2048. As well, is this probability the same at the beginning? I tried to find the original game's source code, but I did not succeed.

share|improve this question
7  
This strip would've been funnier if the repeating number was 4, but I remembered wrong... –  z ' Jun 5 at 18:49
18  
xkcd.com/221 where it is 4 –  mmatthews Jun 5 at 19:45
1  
@z' Only 9s appear. Only powers of two can join. Task: Score any points. –  tohecz Jun 5 at 23:43
    
@mmatthews that was the one, i got my comics mixed up –  z ' Jun 6 at 0:16
1  
100% probability, according to xkcd –  Kroltan Jun 6 at 13:50

3 Answers 3

up vote 54 down vote accepted

Extracted from the source code (line 71) :

var value = Math.random() < 0.9 ? 2 : 4;

Math.random() returns a number between 0 and 1. This formula can be read as follows : Is the pseudo-randomly generated number strictly less than 0.9? If yes the tile value is 2, if no the value is 4. Assuming Math.random() generates numbers with uniform probability over (0,1), there is a 90% chance of a 2, and 10% chance of a 4.

As for your second question: Yes, the probability is the same at the beginning. When the game starts 2 tiles are generated and their value randomized with the code above.

share|improve this answer

i believe its 10% for a 4 and 90% for a 2

share|improve this answer
15  
You're not wrong necessarily, but without providing any kind of source, it's just speculation. –  AndyPerfect Jun 5 at 22:50

I usually get a 2 65% of the time and 4 35%. It can vary, I can sometimes get alternations between the two. Sometimes the probability of the two actually swaps. You can never tell.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.