A rough implementation of 2048 in python.
src
├── main.py
└── utils.py
The src
folder contains two files:
main.py
: This is the main entry file to start the game.utils.py
: This contains functions used in the game of 2028.
git clone https://github.com/EteimZ/2048-rough-sketch
cd 2048-rough-sketch
python src/main.py
0| 0| 0| 4
0| 0| 0| 0
2| 0| 0| 0
0| 0| 0| 0
Please press key(w⬆|s⬇|a⬅|d➡|e to exit):
Four keys are used to play the game w
, s
, a
and d
.
w
moves the grid up.
2| 0| 0| 4
0| 0| 0| 0
0| 0| 0| 0
0| 0| 2| 0
Please press key(w⬆|s⬇|a⬅|d➡|e to exit): w
s
moves the grid down.
0| 2| 0| 0
0| 0| 0| 0
0| 0| 0| 0
2| 0| 2| 4
Please press key(w⬆|s⬇|a⬅|d➡|e to exit): s
a
moves the grid left.
2| 0| 0| 0
0| 0| 0| 0
0| 0| 0| 0
8| 0| 4| 0
Please press key(w⬆|s⬇|a⬅|d➡|e to exit): a
d
moves the grid right.
0| 0| 0| 2
0| 0| 0| 0
0| 0| 2| 0
0| 0| 8| 4
Please press key(w⬆|s⬇|a⬅|d➡|e to exit): d
Tests have been implemented using doctest. Use the command below to run them.
python src/utils.py # Non verbose test
python src/utils.py -v # verbose test