JS1k demo details: 2048
js1k.com
js1k.com
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.
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.
Got nuked for some reason by HN's algorithm dropping it from nr 4 to the second page :(
Crappy algo, I would think that lots of comments indicates that people find it interesting... Next time I won't reply to peoples comments :/
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/....
Good code though! :)