jader201 12 years ago

There are a few differences with this version:

- The game allows a new tile to spawn even if you move in a direction in which no tiles move.

- Only 2 tiles spawn. I don't think I've ever seen a 4 tile spawn.

- Once you reach 2048, the game continues.

Does anyone know whether these are intentional, or a side effect of the 2048 byte limitation?

  • midas007 12 years ago

    Yeah, it's a super buggy clone. But at least the fonts are nice.

  • rwinn 12 years ago

    > Once you reach 2048, the game continues.

    That's a bug, it should pop up a dialog with your score. Rest is intentional.

      newtile = 2 vs. newtile = Math.random() > 0.25 ? 2 : 4
    • jader201 12 years ago

      > That's a bug, it should pop up a dialog with your score. Rest is intentional.

      Yeah, just played, and it stops after the "GG" alert.

    • stormbrew 12 years ago

      Or:

          // in setup, use everywhere you use Math.random
          r=Math.random
          // generating a new tile
          newtile=(r()*2+1)<<1
      

      That's a 50/50 chance and it's still a few more characters, obviously, but not nearly that many. Not spawning fours makes this a lot easier.

      • rwinn 12 years ago

        I'm using JSCrush (http://www.iteral.com/jscrush/) so it actually pays to write stuff out repeatedly instead of assigning short variables.

          (Math.random()*2+1)<<1
          Math.random()>.25?2:4
        

        But still too much, I only have 2 bytes to spare :)

        • stormbrew 12 years ago

          Do you have the uncrushed source somewhere?

  • cge 12 years ago

    > The game allows a new tile to spawn even if you move in a direction in which no tiles move.

    Additionally, if you attempt to move in a direction in which no tile move while the board is full, the game ends, even if there is another, valid move that's possible.

bite 12 years ago

I beat it http://imgur.com/xa0sXjX . I think this game is significantly easier than original due to the alterations in logic: - When you're unable to move (for instance when the top 2 rows are all filled with 8 blocks), you can still spawn a new block. Just lot less challenging than pressing down than up and dealing with 2/4 surrounded by high numbers. - You only spawn two's no four's this allows for a much easier strategy. I probably used the right and up key about 90% of the game, left 9%, and down <1%.

Great job though! loving all these clones.

gus_massa 12 years ago

Nice work. There is a small incompatibility when you press a key and no tile moves / collapses. In the original version it doesn't count and a move and nothing happens. In this version a new tile appears.

  • y2bd 12 years ago

    Because of this, you can make a pool of numbers in any corner by repeatedly pressing the keys in that direction (e.g. left-down, left-up, etc).

  • benched 12 years ago

    Yes, and it matters. It makes it easier.

kps 12 years ago

2048 in exactly 2048 bytes of C, counting blanks and newlines (a bit of a cheat to use indentation to push it up to 2K).

https://gist.github.com/datatravelandexperiments/9578313

Needs C99 and curses; e.g.

  cc -std=c99 2048.c -lcurses

Note: This is pretty awful code, but I'd rather go to sleep than use up the blanks to make it cleaner. Don't write like this.

  • rwinn 12 years ago

    Haha that's awesome!

Aardwolf 12 years ago

I continued playing after 2048, now I have two 2048's next to each other, they refuse to form a 4096, and the game doesn't respond to keystrokes anymore :(

The changed rule that allows spawning blocks at any time makes it easier indeed, but not that much easier, so nice modification.

  • jader201 12 years ago

    > The changed rule that allows spawning blocks at any time makes it easier indeed

    Was this change intentional, or a side-effect of the simplified code?

    • rwinn 12 years ago

      Intentional side-effect :) I had to leave it out to keep to the 2048 byte limit.

      • adito 12 years ago

        I like the colorscheme in this clone. Is there a reason choose that particular colorscheme.

        • rwinn 12 years ago

          Thanks! No not really, I just picked some colours i liked and tried to keep them easily distinguishable

pkill17 12 years ago

Buggy; Got some sort of JS alert error that stopped my game short: "GG 308", "GG -1". I'm guessing you're reporting my score here, but there are still MANY valid moves left on the board. For example, start the game, and hold the down arrow until the alert pops up saying "GG [score]" -- There's almost guaranteed to be 4-5 possible moves left on the board this way.

  • rwinn 12 years ago

    If you fill up the screen and make a move that does not make a new space for the next tile it is GG!

Cynddl 12 years ago

Not the same rules. :)

We should not be able to make new card appear when no other one can move.

  • deletes 12 years ago

    Intentional? It is till not trivial to win, but is (much) easier. I actually had more fun with this version.

    Actually not that easy, but much more fun.

    • effn 12 years ago

      I found it way harder. I'm struggling to reach even a score of 1000 when I rarely score under 10000 in the original.

      • deletes 12 years ago

        Agree, I think it is easier if you do a slow approach to it. The original is more mashing and luck imo.

    • pkill17 12 years ago

      The game is arbitrarily winnable now. Press down until you get rows of 2-4-8-16, then collapse all the way to the left. Repeat this procedure until you get to 256/512.

      • deletes 12 years ago

        That doesn't work, you get to 128 with some nice patterns and then the algorithm fills the screen. Maybe some clever play from then on would work, but the random pieces always mess with your strategy.

        If you have a static solution, please show it.

  • rwinn 12 years ago

    Hehe, yeah.. I had to rip that out to make it fit in 2048 bytes. It takes a (relatively) big chunk of code to know if a move is possible.

    • noiv 12 years ago

      Have a system for the original, which sometimes fails if the board gets crowded. With this one it never fails and the board is mostly always half empty, need the 4096/8192 tiles, too.

eudox 12 years ago

I really like the design of this one more than that of the original.

doorhammer 12 years ago

Good job!

I won't point out the bugs/differences that've been mentioned. I dug it, either way.

What really hit me, playing this version, is how much relatively small changes in a really simple game can dramatically alter the strategy and difficulty of the experience

Dug it either way though

_yfoe 12 years ago

Something seems wrong with this picture: http://i.imgur.com/nTL4DZi.png

(Just keep on pressing right to reproduce)

  • MJR 12 years ago

    And on top of that, when you get to that point, up and down don't do anything. You should be able to combine those tiles vertically.

  • raimue 12 years ago

    Experienced the same on the first try, just kept on pressing in one direction. Not much fun to play with such a bug.

rwinn 12 years ago

Updated it to follow the original better. You try the updated version here:

http://johan-nordberg.com/2048/

(or if you're in the future the js1k crew might have updated my submission already, in that case, forget you read this, it was perfect from the start, whoa i need a break, my brain is trying to find ways to write this comment using fewer characters, commas are nice, sleep)

feelstupid 12 years ago

Basically, the 'check' to see whether you have any moves left isn't in fact whether there are moves left, it's just a simply 'if no more space for new block = game over'

The addition of the block being added no matter the move is an escape round the original (and obviously more verbose, probably why excluded) method of calculating moves remaining.

All in all, decent effort, but it's not 100% true to it's aim

Dorian-Marie 12 years ago

Maybe there should be some standard rules for 2048, because I tried three games, the original, the Android one and this one, and everytime there are different rules: - Is it a valid move to not make any tile move? - What is the order of tiles merging (top-first? left-first?) - Can we merge multiple tiles in the same row/column in one move? - ...

joering2 12 years ago

Can someone please make a 4096 version, or 8192 ?? I love this game, but I ended up with almost empty board with one 2048 tile and 2 x 2.

I want to be able to go on! :)

EDIT: I bet this would be a smash hit in Apple Store (at least I checked and couldnt find exact replica). I bet there are few people working on it right now...

icefox 12 years ago

Every move causes the whole page to flicker in Chrome on my box which makes it pretty unplayable.

  • rwinn 12 years ago

    I've been seeing that as well. Does not happen when outside of the js1k frame (http://johan-nordberg.com/2048/).

    I think it is some hisenbug related to that js1k loads all entries by injecting the script in a iframes src attribute.

    EDIT: clicking anywhere to focus the iframe makes it stop

  • stormbrew 12 years ago

    Yep. Also the tiles sometimes initially appear well off from where they actually are, which is an additional disorientation.

feelstupid 12 years ago

If I press UP and only UP, it will have the 16's in the top row, 8's in the 2nd, 4's in the 3rd, and 2's in the 4th without fail. It then says GG 272 even though I have more moves.

Out of 3 times playing, it has some this 3 times.

Schiphol 12 years ago

This should probably be in the thread for the original program, but I didn't do it then, and I feel I'm missing out: my arrow keys do nothing, and NoScript is allowing the whole page. This is FF 27. Am I missing something?

PanMan 12 years ago

Unfortunaly doesn't work on iPad (no swipe support) while the original does

  • rwinn 12 years ago

    Heh, i'll accept a patch for swipe support. You have to keep it below 2 bytes though :D

shakeel_mohamed 12 years ago

Somehow, I beat this version my first try! Partially because I got a 3x4 deadlock, but a new tile spawned in the empty row and I could keep going.

mschuster91 12 years ago

Bug: GoodGame with:

    2 2 4 2
    32 16 8 4
    64 128 64 16
    1024 512 256 128
  • deletes 12 years ago

    You must have pressed up or down. It doesn't check for invalid move. That is expected with the 2048 source limit.

akst 12 years ago

Woo, Good Job Johan!