Skip to main content

C2048

C2048 is a Python library that implements the 2048 game written in Rust.

The game loop should look like this

from c2048 import C2048, Move
game = C2048()

while True:
    print(f"Score: {game.score()}")
    print(game)
    # pick a random move
    move = Move.random()
    game.move(move)
    
    if game.has_moved:
        # Probability of getting a 2
        game.spawn_tile(0.9)
        # resets the game.has_moved
        game.reset()
    
    if game.is_win():
        print("You win, max tile: ", game.highest())
        break
    elif game.is_lose():
        print("You lose, max tile: ", game.highest())
        break

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

c2048-0.1.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

c2048-0.1.0-cp312-none-win_amd64.whl (162.2 kB view details)

Uploaded CPython 3.12Windows x86-64

File details

Details for the file c2048-0.1.0.tar.gz.

File metadata

  • Download URL: c2048-0.1.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.1

File hashes

Hashes for c2048-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0a822c129f3ad16543e90a9cacecc8f473f54faab7d0643f39c1fe5e3364100b
MD5 acb2d1df797c99cec382487ef8db3dac
BLAKE2b-256 dc96e68619b0cc8824669a3de551754328fe83c744fe637b726841359da3aca9

See more details on using hashes here.

File details

Details for the file c2048-0.1.0-cp312-none-win_amd64.whl.

File metadata

  • Download URL: c2048-0.1.0-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 162.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.1

File hashes

Hashes for c2048-0.1.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 0e9a98cfdbc53e5073b765739d6e5e8f0aa62fabb2d0ec4c4794ab3166d1670c
MD5 e45aa3e4771c3b70fc9a55955201ca26
BLAKE2b-256 27b1ffc84e61d0d1bceae1177c92b91e26485a6e906bd7cbb6deacd9b5e57c0a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page