Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Rule in the 2048 game (Developers)

posted by jadoxa Homepage E-mail, Queensland, Australia, 25.07.2022, 03:22

> What the function does: in the random free cell on the board places a new
> cell - which in the 90% probability is the cell "2" and in the 10%
> probability cell "4".
> My question is: This is the same algorithm like in the original
> implementation?

Yes.

GameManager.prototype.addRandomTile = function() {
    if (this.grid.cellsAvailable()) {
        var e = Math.random() < .9 ? 2 : 4,
            t = new Tile(this.grid.randomAvailableCell(), e);
        this.grid.insertTile(t)
    }
},

 

Complete thread:

Back to the forum
Board view  Mix view
22749 Postings in 2119 Threads, 402 registered users (1 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum