Skip to content

jasonxue1/akioi-2048

Repository files navigation

akioi-2048

Python implementation of a customizable 2048 engine with multiplier tiles and score tracking. Requires Python 3.8 or later.

Features

  • 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

Python Public Functions

step(board, direction)

Apply one move. If the board changes, a new tile is spawned in a random empty cell.

Parameters

  • 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 direction

    • 0Down
    • 1Right
    • 2Up
    • 3Left

Returns

Tuple (new_board, delta_score, state):

  • new_board: list[list[int]] – Board after the move
  • delta_score: int – Score gained or lost from merges
  • state: int – Game state indicator
    • 1 → Created a 65536 tile → Victory
    • -1 → No legal moves left → Game Over
    • 0 → Game continues

Notes

If the board stays the same, no tile is spawned, delta_score = 0, and state = 0.

init()

Create a new board with two starting tiles.

Returns

  • new_board: list[list[int]] – Fresh board ready for play

Installation

Install via pip:

pip3 install akioi-2048

About

Resources

License

Stars

Watchers

Forks

Packages

No packages published