
2048 in 4D - dbaupp
http://huonw.github.io/2048-4D
======
LukeWalsh
Of all the spin offs that have been posted here this one is my favorite. Very
little of the original strategy carries over, it's almost an entirely new
puzzle.

Very creative, well done!

~~~
doorhammer
"Hoo dee doo"

"4D 2048? Well, I beat regular 2048 and I'm only like 97% totally addicted to
that. I'll try 4D out for a few minutes"

 _hours pass_

 _twitch... twitch_

------
cclogg
Can someone make an MMO 2048 that flies a flappy bird every time you combine
two numbers!?

~~~
baddox
It would be neat to create two games that appear to be different, but designed
in such a way that the winning user input is the same for both games. A simple
and obvious example would be an infinite runner game where the winning input
is a certain rhythm of spacebar presses, and a musical rhythm game that
requires the same rhythm of spacebar presses. But I'm sure it could be done
with much more complex games.

~~~
ctdonath
Tangent: I briefly worked in the "gaming" (gambling) industry. To cope with
the proliferation of laws, the backing algorithms could be changed to match
whatever games of chance which were legal in a given jurisdiction, then
topologically transformed to look like the desired game. What looked like
video poker might actually be bingo, hence legal in a "only bingo is legal"
locale.

(ETA: Sorry, no how-to details. I didn't work on that part of the code.)

~~~
mikeash
That's pretty wacky. Could you explain a bit more about how the transformation
works? I can't quite see how you run bingo behind the scenes but display
something that looks like poker. They seem too different.

~~~
ctdonath
See adjacent reply.

~~~
mikeash
Thanks much for the reply and for letting me know about it! Fun stuff.

------
tiger10guy
It's so hard to get intuitions about higher dimensions and this seems to do an
incredible job. The game is simple enough and the cardinality of the
dimensions low enough (2x2x2x2) that I can actually play it smoothly (having
played the original and with a bit of practice at the 4D version).

Does that mean I've formed 4D intuition? I think this just happens to be in a
class of 4D mechanics that's isomorphic to 2D variants, so the answer would be
no. If so, how many such 2D variants are there?

For those interested, 4d rubick's cube:

[http://www.superliminal.com/cube/cube.htm](http://www.superliminal.com/cube/cube.htm)

~~~
sp332
Any discrete set of points can be losslessly represented in any positive
number of dimensions. The 4d version has 16 spaces, so you could just have
them all in a line for a 1d representation of the same game. There are lots of
ways to lay them out in 2d, or 3d, or 4d as well. So I would say that you
certainly have developed an intuition for four dimensions! You're not cheating
or anything just by rearranging the points into 2d.

(Continuous shapes, like solid hypercubes, are tricker ;)

~~~
tiger10guy
That makes sense.

I think my intuitions for the discrete and continuous are similar for 2D and
3D. Are they fundamentally similar? How do they differ, even if only a little?
It seems that discrete 4D intuition should somehow help with continuous 4D
intuition.

~~~
sp332
It's all about how the points are _connected_ to each other. In 1d obviously
you can only have 2 connections per node - one to the left and one to the
right. In 2d you have a lot more flexibility. You can curve lines around to
make much more connected graphs.

In 2d there are still restrictions though, mainly the "3 utilities problem"
[https://en.wikipedia.org/wiki/3_utilities_problem](https://en.wikipedia.org/wiki/3_utilities_problem)
But in 3d, you don't have restrictions on connections anymore. You can
_always_ weave a new connection around the existing ones.

In a square, each corner is connected to 2 neighbors. In a cube, each corner
has 3 connections. In a 4d hypercube, the corners have 4 connections. So to
make a "4d" hypercube in 3d, just draw 4 connections between corners :)
[https://en.wikipedia.org/wiki/File:Hypercube.svg](https://en.wikipedia.org/wiki/File:Hypercube.svg)
Some supercomputers have nodes connected in a hyper-torus configuration. It
doesn't matter how you arrange the nodes physically, they just run cables
around to recreate the interconnections that would exist in a 4d torus.

For 4d, it's easy enough to do the corners. Each one has 4 connections - one
each for up/down dimension, left/right, forward/back, and... +W/-W direction.
You can see this in the game. Each corner can move two directions in its own
square, or to two other squares, total of 4 directions. If you want to do more
than just corners though, it gets more complex. Think of a 3d cube
[http://joppi.github.io/2048-3D/?utm_source=hn](http://joppi.github.io/2048-3D/?utm_source=hn)
A piece on the edge can move to two corners, or the center of two faces.
Actually, it's easier to think of it as lots of little cubes, stuck together
so you only have corners :) A 3x3x3 cube is really 8 2x2x2 cubes that share
some nodes. So the block in the very center has lots of options. Up, down,
left, right, forward, or backward - 6 options. That's twice as many as the
corners! That's because the corners are as far as you can go in one direction,
so they can only move back the other way. Pieces in the middle can move either
way - exactly twice as many options.

Let's make an even bigger hypercube, 3x3x3x3. That's 64 little 2x2x2x2 cubes
stacked in 4d. That's 8 3x3x3 cubes that make up the "faces" of the hypercube,
and each cube has 8 2x2x2 smaller cubes in it. But remember most of those
nodes are shared by more than one cube/hypercube. So the corners of our
hypercube can only move to 4 other spaces. A piece in an edge can move to
either corner, or into one of the 3 faces. (Look again if you can't imagine
all 3 faces
[https://en.wikipedia.org/wiki/File:Hypercube.svg](https://en.wikipedia.org/wiki/File:Hypercube.svg))
So that's 5 options for a piece on the edge. The middle of a face can move
(say) up and down _and_ left and right, as well as into the middle of either
cube that it's on. For a space on a face, that image is actually awful.
Remember, that outer cube is a whole other cube, it's overlapping all the
other cubes in that picture. Try this page
[http://eusebeia.dyndns.org/4d/8-cell.html](http://eusebeia.dyndns.org/4d/8-cell.html)
Anyway, a piece in the middle of a face can move (say) up, down, left, right,
or _into_ the center of either of the two cubes that it's on - one in the
forward direction, the other in the +W direction. Try visualizing this for
several different faces until your intuition kicks in :) Finally, the piece in
the very center can move either direction in each dimension, for a total of 8
directions, exactly twice as many as the corners. It will always end up in the
center of a face, because those are the only pieces it's connected to.

------
walrus
There's a subreddit for these:
[http://www.reddit.com/r/2048/](http://www.reddit.com/r/2048/)

~~~
jader201
Lol. 9007199254740992.

[http://www.csie.ntu.edu.tw/~b01902112/9007199254740992/](http://www.csie.ntu.edu.tw/~b01902112/9007199254740992/)

------
adamwong246
I expect to see 2048 in 5 dimensions tomorrow.

~~~
deletes
So 2048 in 2048 dimensions after that?

~~~
vesinisa
Unfortunately, even assuming a board diameter of 2, storing that game's any
state would require some 10^435 times more bits than there are cube Planck
lengths in the observable universe.

~~~
deletes
Undoubtfully the number is really large, but I'm not sure what exactly you
mean by cube Planck lengths. A comparison to atoms would be more clear.

Still, it wouldn't have to. Since most arrays would have pieces with lower
numbers( 2,4,8 ) you could very efficiently compress the data.

At some point you would run out of memory but it would be playable. Just like
those Game of Life implementations with seemingly infinite grid.

~~~
vesinisa
Planck length is a theoretical very small unit of length in physics. It is the
scale of quantum foam and several orders of magnitude smaller than all those
fancy particles like quarks, electrons, protons and atoms:
[https://en.wikipedia.org/wiki/Orders_of_magnitude_%28length%...](https://en.wikipedia.org/wiki/Orders_of_magnitude_%28length%29#Subatomic)

BTW you are right about compressing: you could store the initial state very
efficiently, and probably even play the to the end without trouble.

------
tiger10guy
Thanks!

(in response to
[https://news.ycombinator.com/item?id=7417294](https://news.ycombinator.com/item?id=7417294))

~~~
dbaupp
(I'd actually made it before that, but you prompted me to post it here. :) )

~~~
tiger10guy
It seemed like too short a time. I figured someone had thought of it first,
but I still couldn't help saying something. Nice work!

------
jxf
I noticed I'm doing a lot better on this version than 2D 2048, presumably
because each tile has more degrees of freedom (2 in the WASD plane, 2 in the
arrow-keys plane).

~~~
mturmon
I think you've put your finger on an interesting point, but it's not so easy.
Since every tile in the 2x2x2x2 cube is effectively in a corner, it has only 4
valid neighbors. This is the same number of valid neighbors as the 4 interior
tiles of the 4x4 game. The other tiles have 3 and 2 valid neighbors.

There's another thing. It can take more moves to put a tile next to another
tile in the 2x2x2x2 game because of these degrees of freedom.

It's not clear to me how this shakes out with gameplay, and I've already
wasted enough time on the 4x4 game that I'm scared to try the 4D game to find
out!

~~~
vorg
> every tile in the 2x2x2x2 cube is effectively in a corner

Time for the 3x3x3x3 game. The board would look like a Sudoku grid.

------
antr
Rumour is King is working on "Flappy 2048" \- in-app purchases available in
case you run out of taps or swipes

~~~
rplnt
Final release name would be Binary Saga. You can pay for spawning specified
numbers with 100% probability. You just don't know where they will spawn.

------
snake_plissken
How is this 4 dimensions? It just seems like 4 subdivisions that cuts down the
number of inside tile corners.

------
joelrunyon
Isn't time technically 4D?

So you would have to match up this puzzle with one being worked on by someone
yesterday.

~~~
maaaats
No, one is often saying the world i 3D and time makes it 4D. But there is
nothing stopping you from having something in 4D where time isn't the fourth
dimension.

~~~
satchipear
That's how Einstein defined our world. Actually it's common to see 4 (and
more) spatial dimensions in some science fiction novels, including the very
famous one called "Three Body Trilogy"("San Ti" in Chinese).

------
primitivesuave
Nothing can kill my productivity like the original could.

------
jasonpeacock
this reminds me of tic tac toe ten, where the game is a meta game of itself:

[http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-
tac-t...](http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/)

------
vorg
I find using both hands on the keyboard irritating.

If it was possible to double-hit the up/down/left/right arrows (i.e. twice in
succession quickly) to move between dimensions, then I could use it with one
hand.

------
whitehat2k9
AHHHHH MY BRAIN IS FULL OF FOUR DIMENSIONAL CLUSTERFUCK

------
clienthunter
I use the workman keyboard layout. This was a complete mindfuck until I
realised what was happening.

------
kremlin
Has it occurred to anybody else that this is the perfect way to explain how to
visualize > 3 dimensions? Using the same method for going from 3 to 4 in this
game, you can go from 4 to 5, 5 to 6, etc.

Potentially transformable into a really cool learning tool

------
Lerc
Much more playable than I expected.

Now someone do one based on taste and smell.

~~~
ctdonath
Any synesthesiatics care to chime in here?

------
freefrancisco
This is madness! The decay of western civilization is nigh! All we need is the
string theory 11-dimensional version of the game to show up and doom us all!

------
brugidou
how do you play with a phone? i can only swipe tiles but I cant change
dimension. there need to be some sort of "two finger swipe" for WASD keys.

~~~
dbaupp
I couldn't work out how to implement the extra 2 movement dimensions on a
phone. Does JS support detecting 2 finger swipes (or something similar) in a
sane way?

~~~
matthewmacleod
You can certainly grab the number of touches in an event - two-finger swipe
might be interesting. MDN has quite a few examples:
[https://developer.mozilla.org/en-
US/docs/Web/Guide/Events/To...](https://developer.mozilla.org/en-
US/docs/Web/Guide/Events/Touch_events)

~~~
dbaupp
Very cool, thanks; I've added two-finger swipe for the extra two dimensions.

------
faramarz
I can't get passed 260. It's driving me insane!

Any strategies you guys want to share?

edit: wow! Ive only been using half of the keys! 836 booya!

~~~
sreyaNotfilc
Just got 2340!

For me, its all about looking at all three panels and making moves in the
other ones that will not affect the two.

That is, if I have a choice to move up or down an the other 2 panels can only
move down, I would choose up. Then I can score another 4, 8, 16 or so points
without changing much of the board.

------
eam
I now want to see 2048 in 2048D.

------
deletes
edit: Looks ok, I'm confused :)

It is interesting. The best way to solve it is to forget about dimensions and
just learn the rules of what key does what in terms of piece movement.

~~~
dbaupp
You can move "up" and "down" along all 4 orthogonal dimensions; what's
missing?

~~~
Pyrodogg
In the original 2048 I only used the arrow keys.

In the 3D version I noticed it worked with WASD(QE). The arrow keys still
mapped to WASD.

This version separates WASD from the arrow keys, they now control completely
different movement dimensions.

I had to read the instructions a few times before it clicked that I had two
use WASD and the arrows for two different tasks.

------
elwell
It's not really _in 4D_. More like: 4 games at once.

~~~
bcherry
not true, since WASD move tiles in the 3rd/4th dimensions (try it out)

~~~
elwell
Ah, thanks. Hmm... this requires a lot more thought than the original.

------
Ambrosia
i hate this game now

------
lightblade
Now, the next challenge is to build a 2048 4D solver.

------
ShaneOG
These games are really not good for my productivity!

------
joeblau
Is this winnable?

~~~
dbaupp
Yes; I've won, and I know (at least) one other person to have done so.

[http://i.imgur.com/tBqcjSK.png](http://i.imgur.com/tBqcjSK.png)

~~~
deletes
You didn't do a lot of mashing keys right. This version really takes some
thought.

~~~
dbaupp
Yeah, very litle mashing:
[https://news.ycombinator.com/item?id=7419731](https://news.ycombinator.com/item?id=7419731)

------
blueskin_
This one seems a lot harder than the original.

I like it.

------
vittore
Now this is actually interesting!

------
tobeportable
Why would one choose wasd over ijkl if foreign keyboard layouts aren't going
to be supported.

------
squintychino
2048 - the new flappy bird

------
Gepser
836

~~~
ctdonath
7088

~~~
theon144
2048

------
nighthawk24
224!

------
the_cat_kittles
waiting on N-d

