Skip to content

mamachanko/2048

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status 2048

This is a Python game engine implementation of the rather popular game 2048.

Usage

>>> from p2048 import Board
>>> board = Board()
>>> board
<Board [[0, 0, 0, 0], [0, 0, 0, 0], [0, 2, 2, 0], [0, 0, 0, 0]]>
>>> def pretty_board(board):
        print '\n'.join(map(str, board.state))
>>> pretty_board(board)
[0, 0, 0, 0]
[0, 0, 0, 0]
[0, 2, 2, 0]
[0, 0, 0, 0]
>>> board.move_left()
>>> pretty_board(board)
[0, 0, 0, 0]
[0, 0, 0, 4]
[4, 0, 0, 0]
[0, 0, 0, 0]
>>> board.move_right()
>>> pretty_board(board)
[0, 0, 0, 0]
[0, 2, 0, 4]
[0, 0, 0, 4]
[0, 0, 0, 0]
>>> board.move_down()
>>> pretty_board(board)
[0, 0, 0, 0]
[2, 0, 0, 0]
[0, 0, 0, 0]
[0, 2, 0, 8]

Features

  • adds new elements (2 or 4) after each move
  • counts moves
  • raises GameOverException once no more move is possible

Todos

  • fix coverage report via travis
  • add score report

About

"2048" Python game engine

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages