Metadata-Version: 2.5
Name: magmacrunch-two-to-the-n
Version: 0.1.1
Summary: 2^N - 2048, generalised. Terminal version.
Project-URL: Homepage, https://magmacrunch.com/arcade/2%5EN/
Author: magmacrunch media
License-Expression: PolyForm-Noncommercial-1.0.0
License-File: LICENSE
License-File: NOTICE
Keywords: 2048,arcade,games,puzzle,terminal,tui
Requires-Python: >=3.10
Requires-Dist: magmacrunch>=0.7.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# 2^N (terminal)

2048, generalised, in a terminal: where the game started. The third version
beside `web/` and `wii/`, on the
[magmacrunch](https://github.com/magmacrunch-media/magmacrunch) engine's
terminal backend: a cabinet in the magmacrunch arcade and its own command, the
same either way.

```
pip install -e ".[dev]"
two-to-the-n                  # or python -m two_to_the_n
two-to-the-n --mode 4         # straight to a target of 16
two-to-the-n --mode endless --play
```

## Keys

| key | |
|---|---|
| arrows (or WASD, hjkl) | slide every tile |
| left / right on the title | choose N, from 2-bit (target 4) to 16-bit (65,536), or endless |
| `R` | new game |
| `Esc` | the title (from the title, back to the arcade) |
| `Q` | quit |

Two equal tiles that touch merge into their sum, and the merge scores the tile
it makes. The game ends when a tile reaches 2^N, which is a win, or when the
board is full with no pair left. The newly dealt tile lights up for a moment.
Past 2048 the tiles cycle through the page's plasma.

## It is the browser's game

`two_to_the_n/rules.py` is `web/js/game.js` plus the three lines of
`web/js/main.js` that make a slide into a turn: slide, and only if anything
moved, deal a tile and check for the end. `tests/test_oracle.py` checks it:
`tools/js_oracle.mjs` loads the website's `adenosine-puzzle.js` and
`web/js/game.js` with `Math.random` seeded, plays a few hundred games across
every mode, some mashed and some played into a corner past 2048, and the test
replays every move through the port and requires the same board, score and
ending after each one.

The oracle needs the website, for the bundle. It finds it the way
`tools/link-shared.mjs` does: `../shared`, `$WEBSITE`, `../../website`,
`../../../web/website`. CI checks the website out beside the game.

The browser's choices are copied rather than improved, because both versions
file scores the same way:

- **One board, `2n`, with the mode beside each score** as `difficulty`, and a
  top ten per mode. A score is asked for initials only if it makes its own
  mode's ten, as the page asks.
- **2-bit mode never deals a 4**, which would be its target, while the value
  draw is still taken so the odds elsewhere match.
- **Reaching the target ends the game**, as a win, after a half-second pause
  to see the tile that did it.

Change any of these in `web/js/game.js` and here together, and the oracle will
hold the two to each other.

Needs a 67x21 terminal.

## Licence

[PolyForm Noncommercial 1.0.0](LICENSE), as the rest of this repository. See
[NOTICE](NOTICE), which also says whose game 2048 is.
