Skip to content
← Back to Community
2048 (In Python Console)
Profile icon
h
has Hacker Plan
CodingCactus

2048


What it is:

If you've never heard of it, basically, you have to put 2 squares of the same number together, which will combine those squares into a new square which is those numbers combined. That probably makes no sense because of my explanation skills, but it will all become clear (hopefully)

A new 2 square is added every move


Controls:

It's just the wasd keys:

  • w to go up
  • a to go left
  • s to go down
  • d to go right

How to win

It's simple, just make a square of the value 2048.

Disclaimer: I have never actually won this game lol.

Tip: either never press down or up (except from at the start) if you press up at start: try to not ever press down, or if you press down at the start: try not to ever press up.


How to lose

This is also very simple, just fill the board up until you can't move anymore.


Credit as usual to @xolyon for their colour tutorial (here) which I think pretty much everyone uses now instead of colorama and stuff.


Also, I do realise that it doesn't work exactly like the normal 2048 game, I'm working on that.
Any game breaking bugs, I would love to know about


That's about it!

Have fun and if you do, don't forget to upvote! :)

Voters
Profile icon
fireboar04
Profile icon
Minerva11
Profile icon
qianyy
Profile icon
FrancisPan
Profile icon
G0RG3
Profile icon
Lubasik17
Profile icon
E-Sheep
Profile icon
bogdankiforuk28
Profile icon
spate1
Profile icon
davidyu9
Comments
hotnewtop
Profile icon
Coder100

Nice work! This is awesome :)

Profile icon
CodingCactus

@Coder100 thanks!

Profile icon
Coder100

no problem :) @CodingCactus

Profile icon
julia562
Profile icon
CodingCactus

@julia562 wow, well done!

Profile icon
mserrano258

This is some really interesting and fun code! However, I have had some trouble with the game in that some of the squares don't fuse at the very beginning. I attached some screenshots to show this. Please fix this, this game is really good!
error1
error2

Profile icon
CodingCactus

@mserrano258 yh, sorry i'm working on that :)

Profile icon
chippycoder08

@CodingCactus, don't worry! You did a really good job on this!

Profile icon
BobTheTomatoPie

This is so cool!

Profile icon
CodingCactus

@BobTheTomatoPie Thank You!

Profile icon
JBloves27

@CodingCactus It really is cool!

Profile icon
CodingCactus
Profile icon
henryeth

In the original game, players begin with 2 squares filled rather than one. Apart from that small thing, it is great and true to the original. Upvoted.

Profile icon
CodingCactus

@henryeth ah, ok, i'll do that

Profile icon
CodingCactus

@henryeth done! :)

Profile icon
gpr2

I hold the world record [out dated]

Capture

Profile icon
CodingCactus

@gpr2 why does it say the score like 5 times?

Profile icon
JBloves27

cool! @gpr2

Profile icon
gpr2

@CodingCactus the progression of my scores im guessing

Profile icon
CodingCactus

@gpr2 it should just print it once

Profile icon
RiazuMacroni

Great game! I am not good at 2048 but this is very close to the actual game. Good job :D

Profile icon
ayush2007
Profile icon
mo2409

I wish we could make a Repl with like tons of different programmers, that would be so cool.

Profile icon
studentAlfredAl

You can. Just create a new repl and invite a bunch of people. Preferably people who code the same language :) @mo2409

Profile icon
pkTheBest

It doesn't work for me :(

Profile icon
CodingCactus

@pkTheBest hmmm, what are you using? (wasd keys)

Profile icon
pkTheBest

@CodingCactus Yes I was

Profile icon
CodingCactus

@pkTheBest what os?

Profile icon
skull_is_dull

i had a 1024, 512, 256, 128, 64, 32, 16, 8 , 4 and two 2's on screen when i died... does that still count?

Profile icon
Pipepelaez

@CodingCactus you are the best

Profile icon
DynamicSquid

2 plus 2 is 4 minus 1 is three - squid maths

Profile icon
Bookie0
Profile icon
PizzaMan21
Profile icon
Jakman

Cool. Would work better if made in Java swing.

Profile icon
studentAlfredAl

Hello, fellow Java coder! I couldn't find anybody else who coded Java :) @Jakman

Profile icon
Jakman

@studentAlfredAl ey man. Most people here only know python and html. We gotta stick together man.

Profile icon
studentAlfredAl

Yep :) @Jakman

Profile icon
fireboar04
Profile icon
[deleted]

this is a good game :) hi score 10948 fail
image

Profile icon
theroadtocode
Profile icon
codingduck

add 4096! (yes i have gotten 4096 ligit)
image
on clone:
i won
ignore the score i played a mode where any adjacent numbered tile could spawn and shoved 2048 in a corner and spammed w so 2048 spawend, then 4096 spawned, 8192,16384, on until 262,144

Profile icon
thedankboi

I think I broke it. The 128 is not supposed to be there, is it?
61838DB1-4C9D-471D-8564-FC8A218BB18C

Profile icon
CodingCactus

@CodingAndMemes why shouldn't it be?

Profile icon
dabs364

YAY! I lost!

Profile icon
Wilke000
Profile icon
Wilke000
Profile icon
SpaceFire

Hey, with your permission can i use the code in an OS project i've been working on. if you want to see it so far it's here: Stellar 2.0

Profile icon
CodingCactus
Profile icon
SpaceFire

@CodingCactus Thanks! I will let you now when it is compatible with the OS so you can see it.

Profile icon
SpaceFire

@CodingCactus Done, if you want to see it it's at the same link. You are credited in the description.

Profile icon
SpaceFire
Profile icon
dontbanmeplz

i got 2636 and then it stoped working but otherwise just like the original

Profile icon
goshan
Profile icon
CodingCactus

@goshan you can go up can't you?

Profile icon
SushiPython

Great job on this!

Profile icon
CodingCactus

@SushiPython THANKS!

Profile icon
lighteningboltb

you can get new look if you clear then press w

Profile icon
lighteningboltb

you shold add a leaderbord like this one https://pypi.org/project/django-leaderboard/

Profile icon
mo2409

I made it to 516 but I couldn't move anymore :[, I still did good :].

Profile icon
DungeonMaster00

i broke the game wow dont know how
Screenshot_2020-05-13 2048 (In Python Console)