Skip to main content

cursed-2048

This is a simple clone of the game 2048 in Python. It is designed to run in a console or terminal, and (apart from a dev-only dependency on pytest) has no dependencies apart from the Python standard library. In particular, the curses module is used to create the text display. This does mean that the program will not work under Windows, though in the future I might add an OS-specific dependency on windows-curses to allow it to work there.

Installation

If you just want to play the game, you can install it in a virtual environment via pip install cursed-2048, or globally via pipx install cursed-2048 (requires that you already have pipx installed.)

For development, you can clone this repository and run pdm install to create a virtual environment with an editable install, then pdm run c2048 to run the version installed in that venv. This of course requires the pdm package manager to be installed already.

Then again, since this program doesn't have any non-standard-library dependencies, you should be able to run it without installing anything. Just run python cursed-2048/main.py or python -m cursed_2048.main from the root directory of this repository. The PDM install is convenient, however, because it automatically adds the c2048 command.

Running

Once the game has been installed, you can play by typing c2048 from the command line. There is also an optional command line argument, -d (or --difficulty), which takes an integer between 0 and 100. This sets the difficulty by determining what percent of new tiles are 2 tiles instead of 4 tiles. The default is 60% 2-tiles.

Gameplay

The game is played on a 4 x 4 board. When the game starts, the board will be empty save for two random cells, which will each be populated with either a 2 or a 4 tile. Each turn, you play by selecting a direction in which to shift the board. This "smooshes" all of the tiles toward the edge of the board in that direction, so that no empty cells remain between populated cells. Additionally, if the smooshing would result in two adjacent cells along the direction of travel containing tiles of the same number, those two will be replaced with one tile having double that number, and your score will increase by that doubled amount. After the tiles have been smooshed, one random empty cell will be randomly populated with either a 2 or a 4, according to the probability set by the --difficulty option.

If the board reaches a state where all cells are populated, and there are no adjacent identical tiles that could be merged, the game is over.

The object of the game is to obtain the 2048 tile. At this point, you can either call yourself a winner and end the game, or keep going to try to reach the coveted 4096 tile. Once that has been reached, the game is over and you have won for real.

If you make a mistake at any point, you can hit u to undo your last move. There is, however, only one move's worth of memory, so once you undo a move you cannot undo again until you make another move.

Contributing

This game was really intended as a solo hobby project to get more practice with curses programming, and to implement a fun, fully playable game using only the Python standard library. While I might decide to add some features to it later, I consider it a completed project.

That said, I welcome bug reports and feature requests, as long as you understand that I am under no obligation to respond to any of them. Additionally, pull requests are welcome, though I can't say how quickly I'll address them. Again, this is a solo hobby project.

I do, however, have one strict rule: No large language models or AI code assistants may be used in this project. This means don't contribute any AI-generated code, don't submit any AI-generated bug reports, don't even ask Copilot for help understanding my code. Pretend it's 2019 and nobody's heard of Claude. If the thought of approaching a piece of software without your Big Tech-funded resource hog of a pair programmer fills you with trepidation, why not give real programming a try? You might like it, and you might learn something! If you're hopping mad at my strict anti-LLM stance, this project isn't for you, and any complaints may be directed to the nearest brick wall.

And before anyone asks: yes, local models still count as LLMs.

Metadata

Release files for cursed-2048 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cursed-2048 0.1.2
File Size Uploaded Provenance
cursed_2048-0.1.2.tar.gz 9.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cursed-2048 0.1.2
File Interpreter ABI Platform
cursed_2048-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.1 kB

Release files / cursed_2048-0.1.2.tar.gz

Download URL cursed_2048-0.1.2.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0bc673025174072cadc0d0048fd7f8f09e42ba4565807a2a427423a67846a115
BLAKE2b-256 checksum
How to use checksums
4245c819e3478200f8d2464fa9e68354211b8614519b71180a0d2728c1799185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.28.0 CPython/3.12.13 FreeBSD/15.1-RELEASE-p2

Release files / cursed_2048-0.1.2-py3-none-any.whl

Download URL cursed_2048-0.1.2-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c5ddc94616a3009d1b5c431245f896a90544329c956ddc8d77599644bc21c96
BLAKE2b-256 checksum
How to use checksums
aca03d5b0fc9d7200ee2091794604cdb01827d99fe5a76fc3ba00d00ecfea7a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.28.0 CPython/3.12.13 FreeBSD/15.1-RELEASE-p2

Security for cursed-2048 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page