What determines which number spawns?



  • Ìn 16384 Hex, the number that appears on the board when you make a move is usually 1, but sometimes it is 2 or 4.

    What determines the next number that will appear or is it simply random?


  • QA Engineer

    From the source code of the game (file "game_manager.js", inside the GameManager.prototype.addRandomTile function):

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

    Which works out to:

    • 75% of the time, it adds a 1, giving a 3 in 4 chance.
    • 75% of the remainder, it adds a 2, giving a 3 in 16 chance.
    • The rest of the time, it adds a 4, giving a 1 in 16 chance.

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 1
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2