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.

In the 2048 game each move causes a new 2-block to spawn. However, I couldn't figure out the logic behind where that block spawns. Is it random? Does it depend on the direction of your last move?

share|improve this question
    
@TheifMaster I took a look at Manishearth's link and it turns out that 10% of the time 4-blocks also spawn! –  Louis Apr 25 at 20:03

1 Answer 1

up vote 19 down vote accepted

It's randomly chosen out of the available cells, as seen in the code here:

if (cells.length) 
{ 
    return cells[Math.floor(Math.random() * cells.length)];
}

(which is used here and eventually here)

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.