Share your repls and programming experiences

← Back to all posts
2048 (In Python Console)
h
CodingCactus (2823)

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! :)

Commentshotnewtop
codingduck (8)

add 4096! (yes i have gotten 4096 ligit)

on clone:

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

CodingAndMemes (28)

I think I broke it. The 128 is not supposed to be there, is it?

uhmansoori (42)

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

SpaceFire (101)

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

SpaceFire (101)

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

SpaceFire (101)

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

dontbanmeplz (2)

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

lighteningboltb (21)

you can get new look if you clear then press w

mo2409 (14)

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

studentAlfredAl (451)

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

mo2409 (14)

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

pkTheBest (1)

It doesn't work for me :(

nk1rwc (86)

i broke the game wow dont know how

syflexer (467)

HAHAHAHAHA my upvote got rid of that 69 yeet yeet

skull_is_dull (40)

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?

UniqueOstrich18 (246)

How come when I made the same thing two months ago, I didn't get 50+ upvotes?
https://repl.it/talk/share/2048-In-Python/31140

Anvaysharma (50)

I loved this game its awesome! It must have been hard to code! I'm a beginner at coding and I'm just exploring :)

CodingCactus (2823)

@Anvaysharma it's actually just a massive if elif chain, look at the code if you want :)

CodingCactus (2823)

@Anvaysharma yh, it's really inefficient lol

HahaYes (1051)

lol this exploded quite quickly

Axrevyn (179)

Awesome project! Here's a bug though:
Look at this picture:


Here I'm about to press D.
Look at the result (Ignore the 2 at the bottom left, that is the new number that spawns in every time you move):


The bottom right shouldn't have an 8. There should be two 4 tiles. A newly merged tile shouldn't be able to merge twice in one turn.
Other than that, awesome game, and it earned an upvote from me.

CodingCactus (2823)

@Axrevyn i am aware, i'm working on it

sakethpilli (0)

AWESOME. the only thing is that if i have 2 2 2 2, i get 8 instead of 4 4, but this whole game is awesome

nt998302 (173)

This is sick, it must've taken you forever tho. This stuff is HARD to make. Good job bro

2millionkittens (0)

In the original game, if you had a row 8, 4, 2, 2, and you pressed "a", you would end up with 8, 4, 4, 0 and need 2 more left presses to reach 16. However, in this game it immediately goes from 8, 4, 2, 2 to
16, 0, 0, 0.

CodingCactus (2823)

@2millionkittens ik, i tried to do that, but it did some wrong stuff, i'll be working on that

[deleted]

:( i got 1849 and i lose
cool game!