Hacker News new | past | comments | ask | show | jobs | submit login
JS1k demo details: 2048 (js1k.com)
19 points by mxfh on March 15, 2014 | hide | past | favorite | 14 comments



Detection of the game-over state seems buggy: I had moves left on a full board then got the 'GG' modal.


I got 4 x 16s first row, 4 x 8s second row, 4 x 4s 3rd row and 4 x 2s on last row just by pressing up.

Then it says game over.

This is wrong because I should be able to shift left / right and merge those same numbers that are matching in a row.

It seems it is game over if all 16 cells are filled in regardless if a move is still possible.


No, the problem is the it think it's over when you do a move and no numbers can merge. The board may be full, and you may have possibilities but you did a move where no numbers could merge.

Also; this version does not implement the random spawn (10% chance to spawn a 4 instead of a 2)

Still impressive for it's size though.


Wow, compressing the code further by doing find-replaces on the code. That is hardcore.


I still see a lot of redundancy there (e.g. "class", "Math", "font"). Maybe a real LZ packer could shrink it even more...


My original submission is here: https://news.ycombinator.com/item?id=7406605

Got nuked for some reason by HN's algorithm dropping it from nr 4 to the second page :(


More comments than votes?


Something like that. I think it had more comments than votes all the way up, it was when it hit 40 comments it got dropped.

Crappy algo, I would think that lots of comments indicates that people find it interesting... Next time I won't reply to peoples comments :/


I wrote a <1k version of Threes, a similar game, for js1k:

http://js1k.com/2014-dragons/demo/1667


Nice work, but unfortunately it doesn't seem to implement the card draw algorithm correctly, which leads to unplayable games pretty quickly (the card draw algorithm must pick the same number of 1s and 2s over a short time horizon for the game to be playable).

The actual algorithm used by Threes is as follows:

1. At start, shuffle a deck containing 4 each of ones, twos, and threes.

2. For each round, roll a 21-sided die. If it's a one and the largest value on the board V is >= 48, choose a tile that is randomly chosen from the range 3 to V/8 inclusive. Otherwise, take the next tile off the stack.

3. If the stack is empty, refill it as above.

Here's a Scala implementation of this logic: https://github.com/mwylde/Threes.scala/blob/master/src/main/....


Yeah, I know- it's just drawing a random number. I didn't have space to improve on that.


Good, but it's not the same game. Any move places a two. The original places a two or a four, and only if you can make a combo during that move.

Good code though! :)


So, it places another block even if you don't move blocks, which vastly simplifies the game.


I noticed this too... it means you don't have to risk getting pieces on the wrong side of your pile just to keep moving things along.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: