:tada: 2048 in your terminal

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 <space> 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
A Simple 2048 Game Built Using Python

Game 2048_Python Dựa trên trò chơi nổi tiếng 2048 của Gabriele Cirulli. Mục tiêu của trò chơi là trượt các khối được đánh số trên một lưới để kết hợp

Le Phuong Anh 3 Dec 13, 2021
MCTS (among other things) for 2048

2048 Created by Chad Palmer for CPSC 474, Fall 2021 Overview: This is an application which can play 2048 and simulate games of 2048 with a variety of

Chad Palmer 1 Dec 16, 2021
The repository that hosts the code that teaches a reinforcement learning - based bot to play 2048

The repository that hosts the code that teaches a reinforcement learning - based bot (based on policy gradients method) to play 2048

Maxim Rud 1 Dec 16, 2021
Blackjack-Py is a terminal based game of blackjack within your terminal playing against CPU.

About Blackjack-Py is a terminal based game of blackjack within your terminal playing against CPU. Usage Clone the repo and run it with whatever pytho

Eccentrici 1 Dec 28, 2021
A terminal-based number guessing game written in python

A terminal-based number guessing game written in python

Akshay Vs 15 Sep 22, 2022
Simplerpg - python terminal game made from scratch.

Simplerpg - python terminal game made from scratch.

reversee 3 Sep 17, 2022
A Pygame Hangman Game coded in Python 3. Run Hangman.py in a terminal if you have Python 3

Hangman A Pygame Hangman Game coded in Python 3. Run python3 Hangman.py in a terminal if you have Python 3.

null 1 Dec 24, 2022
A minimal open source mtg-like tcg game made in python that can be played on a terminal emulator using a keyboard.

A minimal open source mtg-like tcg game made in python that can be played on a terminal emulator using a keyboard.

Amos 3 Aug 29, 2021
Wordle for the terminal, writen in python

Wordle Wordle in the terminal, written in python Simply run bash run.sh in your terminal to run. This creates a virtual environment, installs the depe

Matthew Lidell 1 Feb 9, 2022
Wordle Tas Tool is a terminal application for solving Wordle puzzles

Wordle Tas Tool Terminal application for solving Wordle puzzles Wordle Tas Tool (WTT) is a Python script that iterates over SCOWL95 to solve Wordle pu

null 1 Feb 8, 2022
Termordle - a terminal based wordle clone in python

Termordle - a terminal based wordle clone in python

null 2 Feb 8, 2022
PLVRA is a TUI (Terminal User Interface) implementation of wordle / termo in portuguese, written in Python

PLVRA is a TUI (Terminal User Interface) implementation of wordle / termo in portuguese, written in Python

Enzo Shiraishi 1 Feb 11, 2022
MCRPC (Minecraft Resource Pack Comparator) checks your resource pack against any version of Minecraft to show resources missing from your pack for that version.

Minecraft Resource Pack Comparator MCRPC checks your resource pack against any version of Minecraft to show resources missing from your pack for that

null 3 Nov 3, 2022
Track your favorite minecraft servers' (too bee too tee) queue at any time at your own convenience!

2b2t Queue Monitor Track your favorite minecraft servers' (too bee too tee) queue at any time at your own convenience! Compiled Usage go to https://gi

Addi 1 Feb 5, 2022
Setup minecraft server (Tuinity) to your directory

hapeshiva server-setup Setup minecraft server (Tuinity) for you. Support for optimization Create optimized yml Customazible server port and view dista

null 3 May 11, 2022
Automatically prepare your Minecraft maps for release

map-prepare Automatically prepare Mineraft map for release. Current state: kinda works Make sure you have backups for your world before running this p

null 11 Oct 11, 2022
View your VALORANT performance in different areas of every map in the game!

Valorant-Zone-Stats Inspired by Leetify's awesome Map Zones Tool for CS:GO A simple desktop program to view your VALORANT performance in different are

Louis 76 Jan 1, 2023
Overview: copain, your friendly AI framework to learn and play games

Overview: copain, your friendly AI framework to learn and play games Interface fceux with python and run reinforcement learning. Compatibility Current

fcharras 1 Dec 16, 2021
This a Chess PGN saver which allows you to save your game pgns, in a .pgn file

PGN Saver This a Chess PGN saver which allows you to save your game pgns, in a .pgn file This can be a very useful tool for the people using chessbase

null 3 Jan 6, 2022