@terminalgames/ink-2048
v0.1.0
Published
Terminal 2048 built with Ink.
Downloads
14
Maintainers
Readme
Ink 2048
Terminal 2048 built with Ink. Turn-based, no timer — slide the board, merge tiles, and chase the 2048 star. The board renders as a real square grid of chunky tiles, the freshly spawned tile is highlighted each turn, and you can resize the board (3×3 to 6×6) on the fly. Your best score persists between sessions, tracked per board size.
Install
Requires Node 20+.
The unscoped name ink-2048 is already taken on npm, so this package publishes as @terminalgames/ink-2048. The command is still ink-2048.
Run without installing (easiest)
npx @terminalgames/ink-2048Global install
If npm install -g fails with EACCES, your npm global prefix is probably system-owned (/usr/local). Either use npx above, or point npm at a user-owned directory:
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
npm install -g @terminalgames/ink-2048Then:
ink-2048Controls
The essential controls are always shown in the sidebar, so there's nothing to memorize on a first run.
| Key | Action |
| --- | --- |
| h / ← | Slide left |
| l / → | Slide right |
| k / ↑ | Slide up |
| j / ↓ | Slide down |
| + / = | Grow the board (up to 6×6) |
| - / _ | Shrink the board (down to 3×3) |
| c | Keep playing (after reaching 2048) |
| r / enter | Restart |
| ? | Toggle the full help reference |
| q | Quit |
Resizing the board starts a fresh game at the new size. Your best for the size you're leaving is saved first, and the new size loads its own best.
Command-line options
ink-2048 --size 5 # start on a 5×5 board (3–6, default 4)
ink-2048 --seed 12345 # reproducible tile spawns
ink-2048 --help # usagePersistent best scores are written to $XDG_CONFIG_HOME/ink-2048/scores.json (falling back to ~/.config/ink-2048/scores.json). Set INK_2048_DATA_DIR to override the location. If that file can't be written, the game plays fine and simply skips saving.
Rules
- Played on a square grid (default 4×4, configurable 3×3 to 6×6) that starts with two random tiles (90% are 2s, 10% are 4s).
- Each slide pushes every tile as far as it can go in that direction; equal adjacent tiles merge into their doubled value, and each tile merges at most once per move.
- A new tile spawns in a random empty cell after every move that changes the board (highlighted so you can see what changed). Moves that change nothing are ignored.
- Score is the sum of all merged tile values; Best is your saved best for the current board size; Moves counts board-changing slides.
- Reach the 2048 tile to win — then press
cto keep playing toward higher tiles. The win target is 2048 at every size, so the smaller boards are a real expert challenge. - You lose when the board is full and no merges remain.
Development
npm install
npm run build
node dist/cli.jsnpm test
npm run typecheckGame logic lives in pure TypeScript modules under src/game/ (deterministic, seeded RNG); Ink UI is under src/ui/.
Publish
Maintainers only. Requires access to the @terminalgames npm organization:
npm login
npm publish --access public