Python implementation of a customizable 2048 engine with multiplier tiles and score tracking. Requires Python 3.8 or later.
- Classic 2048 mechanics
- Special multiplier tiles: -1 (×1), -2 (×2), -4 (×4)
- Supports programmatic interaction for AI training
- Detects victory (65536 tile) and game over states
Apply one move. If the board changes, a new tile is spawned in a random empty cell.
-
board: list[list[int]]
– 4×4 board matrix.- Positive integers are normal tiles (2, 4, 8, …)
- Negative integers are multiplier tiles
(
-1
= ×1,-2
= ×2,-4
= ×4). The absolute value is the multiplier.
-
direction: int
– Movement direction0
→ Down ↓1
→ Right →2
→ Up ↑3
→ Left ←
Tuple (new_board, delta_score, state)
:
new_board: list[list[int]]
– Board after the movedelta_score: int
– Score gained or lost from mergesstate: int
– Game state indicator1
→ Created a 65536 tile → Victory-1
→ No legal moves left → Game Over0
→ Game continues
If the board stays the same, no tile is spawned, delta_score = 0
, and
state = 0
.
Create a new board with two starting tiles.
new_board: list[list[int]]
– Fresh board ready for play
Install via pip
:
pip3 install akioi-2048