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?


1 Answer 1


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)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .