term2048 is a terminal-based version of 2048.

Related tags

CLI Tools game python cli
Overview

term2048

Build status Coverage status Pypi package

term2048 is a terminal-based version of 2048.

https://github.com/bfontaine/term2048/raw/master/img/term2048.png

Install

pip install term2048

To upgrade a previous installation, use:

pip install -U term2048

To install via snap:

sudo snap install term2048

Install from source

git clone https://github.com/bfontaine/term2048.git && cd term2048
[sudo] python setup.py install

Play

term2048

Then use arrow keys to move. VI keys (h,j,k,l) are also supported.

Use -h to check the list of available options, and --rules for the game rules. Press at any time during the game to pause it. You can resume it later using term2048 --resume.

Tests

Clone this repo, then:

[sudo] make deps
make check

Note: while term2048 should work on Windows, tests are meant to run on UNIX-like OSes and term2048.keypress-related tests may fail on Windows.

Contributions

  • --version flag added by @aminb
  • --rules flag added by @cardern
  • Short -r and -v flags added by @yankuangshi
  • Resume feature added by @pravj
  • Snap installation method added by @LaughingLove

v0.2.0

  • Python 2.6 and 3.x support by @shaunduncan
  • Tests instructions fixed by @olafleur
  • Spawn probabilities fixed by @frankh
  • Colors improved by @idosch
  • hjkl keys support by @aminb
  • Windows support by @valtron
  • AZ mode by @JosephRedfern
  • The first file-related tests were added by @taeram
Comments
  • Tiles randomly disappear when played in PowerShell

    Tiles randomly disappear when played in PowerShell

    When two tiles are paired into one, a tile may disappear completely from the field.

    Reproduced on PowerShell in every game.

    Cmd works all right though.

    bug windows 
    opened by moigagoo 8
  • implement 'resume' feature for a running game

    implement 'resume' feature for a running game

    this commit implement a feature to pause a running game session and resume it again. the game will start from where you left it.

    on pressing spacebar, a running game session will get paused and game's score and position data will be saved. command term2048 --resume will resume the game and start it from where you paused the game.

    opened by pravj 5
  • Your code is too weak for PEP8. You lack DISCIPLINE

    Your code is too weak for PEP8. You lack DISCIPLINE

    Good morning how are you? This is Arnold! Nice to meet you. I like your project, but your code looks gurly and lacks discipline! Here is a pull request to pump it up. You must apply it, do it now!

    opened by pyarnold 5
  • Please add offline installation tutorial

    Please add offline installation tutorial

    Hi bfontaine,

    term2048 is an amazing app, I like it.

    But someone may want to install it offline instead of pip installing.

    I have figured out term2048 can be installed offline by following steps:

    1. download term2048 repo
    2. make deps
    3. make check
    4. sudo python setup.py install

    Many beginners don't know the fourth step as it's not mentioned in current readme. It will be of great help to many people if you add the fourth step in your readme.

    Thank you.

    opened by 01joy 4
  • add: link to replit run

    add: link to replit run

    i think it would be pretty cool to let people see how this code works (and edit the program) right in their browser, without any manual downloads or installation. i'm thinking we can add a 'run on repl.it' button, which redirects to something like this:

    image

    opened by hyperupcall 3
  • Hide the cursor

    Hide the cursor

    it will hide the cursor

    import subprocess
    subprocess.call('echo  "\033[?25l"', shell=True)
    

    and when quit the program

    subprocess.call('echo -e "\033[?25h";clear', shell=True)
    

    it will display the cursor

    enhancement 
    opened by taizilongxu 3
  • "2"s with different colors ?

    I just noticed this. I don't think it's intended to be this way. The 2 at the top left corner is a different green than the rest. screenshot from 2014-03-14 18 39 06

    P.S. I'm not home right now, or I would have a taken a look and submitted a PR for it myself.

    bug 
    opened by bandali0 3
  • Mavericks:

    Mavericks: "UnboundLocalError: local variable 'm' referenced before assignment"

    Everything installs okay via pip, but after running the process dies with the following:

    Traceback (most recent call last): File "/usr/local/bin/term2048", line 8, in load_entry_point('term2048==0.2.0', 'console_scripts', 'term2048')() File "/Library/Python/2.7/site-packages/term2048/ui.py", line 33, in start_game Game(mode=args.mode, azmode=args.azmode).loop() File "/Library/Python/2.7/site-packages/term2048/game.py", line 153, in loop self.incScore(self.board.move(m)) UnboundLocalError: local variable 'm' referenced before assignment

    macos 
    opened by lukifer 3
  • New piece spawns after no movement

    New piece spawns after no movement

    In the original implementation of this game, a new piece will not spawn if a move does not move any pieces.

    Board to reproduce:

          8   4   4   2
          .   2   2   .
          .   .   .   .
          .   .   .   .
    

    If you press up, nothing should happen. Instead a new piece spawns.

    bug 
    opened by pd0wm 3
  • option for pause/resume

    option for pause/resume

    Hi @bfontaine, first of all :clap: for building term2048

    actually some time ago when I was in love with this game, I made some change to source of installed game and made a new feature to pause/resume the game. It was just a afternoon hack but worked well.

    What's your opinion, If I say I want to make a pull request adding that hacky feature. here I will take care of coding style obviously :smile:

    opened by pravj 1
  • Game.end()

    Game.end()

    Hi,

    I think in the Game.end() function, it should be:

    return (self.board.won() or not self.board.canMove())
    

    instead of

    return not (self.board.won() or self.board.canMove())
    

    This function is never used but could be used in the test in the Game.loop() function.

    opened by Phyks 1
  • UI Dissappears while playing game

    UI Dissappears while playing game

    When playing on an Ubuntu 16.04 machine and an Ubuntu 17.10 machine the UI dissappears while playing the game. In order to make it re-appear you need to press the arrow keys. Then the UI will re-appear and you can continue playing (until the UI disappears again).

    Please see herefor a demo of this bug.

    bug 
    opened by LaughingLove 6
Owner
Baptiste Fontaine
Baptiste Fontaine
ddgr is a cmdline utility to search DuckDuckGo (html version) from the terminal

ddgr is a cmdline utility to search DuckDuckGo (html version) from the terminal. While googler is extremely popular among cmdline users, in many forums the need of a similar utility for privacy-aware DuckDuckGo came up. DuckDuckGo Bangs are super-cool too! So here's ddgr for you!

Piña Colada 2.5k Dec 25, 2022
CLabel is a terminal-based cluster labeling tool that allows you to explore text data interactively and label clusters based on reviewing that data.

CLabel is a terminal-based cluster labeling tool that allows you to explore text data interactively and label clusters based on reviewing that

Peter Baumgartner 29 Aug 9, 2022
Bear-Shell is a shell based in the terminal or command prompt.

Bear-Shell is a shell based in the terminal or command prompt. You can navigate files, run python files, create files via the BearUtils text editor, and a lot more coming up!

MichaelBear 6 Dec 25, 2021
Bear-Shell is a shell based in the terminal or command prompt.

Bear-Shell is a shell based in the terminal or command prompt. You can navigate files, run python files, create files via the BearUtils text editor, and a lot more coming up!

MichaelBear 6 Dec 25, 2021
Terminal-based keyboard testing

kbdtest kbdtest is a simple Python program that tests keyboard input using an interactive, terminal-based, visual keyboard display. It was originally

Ruunyox 12 Jul 19, 2022
jenkins-tui is a terminal based user interface for Jenkins.

jenkins-tui ?? jenkins-tui is a terminal based user interface for Jenkins. ?? ⚠️ This app is a prototype and in very early stages of development. Ther

Craig Gumbley 22 Oct 24, 2022
A simple terminal-based localhost chat application written in python

Chat House A simple terminal-based localhost chat application written in python How to Use? Clone the repo git clone https://github.com/heksadecimal/c

Heks 10 Nov 9, 2021
A terminal utility to sort image files based on their characteristics.

About A terminal utility to sort image files based on their characteristics. Motivation This program was developed after I've realized that I had too

José Ferreira 1 Dec 10, 2022
TUIFIManager - A cross-platform terminal-based file manager

TUIFI Manager A cross-platform terminal-based file manager (and component), mean

null 142 Dec 26, 2022
A python-based terminal application that displays current cryptocurrency prices

CryptoAssetPrices A python-based terminal application that displays current cryptocurrency prices. Covered Cryptocurrencies Bitcoin (BTC) Ethereum (ET

null 3 Apr 21, 2022
MiShell is a multi-platform, multi-architecture project based on the first version (MiShell32)

MiShell is a multi-platform, multi-architecture project based on the first version (MiShell32), which offers super super small reverse shell payloads great for injection in buffer overflow vulnerabilities, written in assembly with a lot of tools written in python.

Kamyar Hatamnezhad 0 Oct 27, 2022
Interactive Redis: A Terminal Client for Redis with AutoCompletion and Syntax Highlighting.

Interactive Redis: A Cli for Redis with AutoCompletion and Syntax Highlighting. IRedis is a terminal client for redis with auto-completion and syntax

null 2.2k Dec 29, 2022
A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.

mycli A command line client for MySQL that can do auto-completion and syntax highlighting. HomePage: http://mycli.net Documentation: http://mycli.net/

dbcli 10.7k Jan 7, 2023
Python commandline tool for remembering linux/terminal commands

ehh Remember linux commands Commandline tool for remembering linux/terminal commands. It stores your favorite commands in ~/ehh.json in your homedir a

null 56 Nov 10, 2022
Open a file in your locally running Visual Studio Code instance from arbitrary terminal connections.

code-connect Open a file in your locally running Visual Studio Code instance from arbitrary terminal connections. Motivation VS Code supports opening

Christian Volkmann 56 Nov 19, 2022
Darkdump - Search The Deep Web Straight From Your Terminal

Darkdump - Search The Deep Web Straight From Your Terminal About Darkdump Darkdump is a simple script written in Python3.9 in which it allows users to

Josh Schiavone 264 Dec 30, 2022
Random scripts and other bits for interacting with the SpaceX Starlink user terminal hardware

starlink-grpc-tools This repository has a handful of tools for interacting with the gRPC service implemented on the Starlink user terminal (AKA "the d

null 270 Dec 29, 2022
asciinema - Terminal session recorder 📹

asciinema - Terminal session recorder ??

asciinema 11.1k Dec 27, 2022
Rich is a Python library for rich text and beautiful formatting in the terminal.

The Rich API makes it easy to add color and style to terminal output. Rich can also render pretty tables, progress bars, markdown, syntax highlighted source code, tracebacks, and more — out of the box.

Will McGugan 41.4k Jan 3, 2023