DEV Community

dev game
dev game

Posted on

Why 2048 Bet on No Engine and Vanilla JavaScript: The Weekend Web Page Behind a Viral Number Puzzle

2048 looks like a game that should need an engine. It needed the opposite: a single web page with no engine, no build step, and no owner.

Nineteen-year-old Italian web developer Gabriele Cirulli wrote 2048 in JavaScript and CSS over a weekend and released it on 9 March 2014 as free and open-source software under the MIT License Wikipedia — 2048 (video game). The repository itself is blunt about the lineage: “a small clone of 1024, based on Saming’s 2048 (also a clone)” that was “indirectly inspired by Threes,” “made just for fun” GitHub — gabrielecirulli/2048. That combination — zero-dependency web code plus permission to copy it — is why a weekend toy got over 4 million visitors in less than a week and is still playable unchanged today Wikipedia — 2048 (video game).

Who this is for

You get the most from this piece if you are an indie developer choosing a stack for a small grid or puzzle game, or a player who wants to understand why 2048 feels harder than its rules look. You need no engine experience. You do need to separate verified history from my analysis: history is cited; my takes are labeled as analysis.

What 2048 actually is

2048 is a single-player sliding tile puzzle on a plain 4×4 grid Wikipedia — 2048 (video game). The original site states the rule in one line: “Use your arrow keys to move the tiles. When two tiles with the same number touch, they merge into one!” Original 2048 — gabrielecirulli.github.io.

The details matter for both strategy and solvers:

  • The game starts with two tiles valued 2 or 4. After every turn another 2 or 4 spawns in a random empty cell — 2 appears 90% of the time, 4 appears 10% of the time.
  • Tiles slide as far as possible until blocked by an edge or another tile. Equal tiles that collide merge once per move into their sum. The merged tile cannot merge again in the same move.
  • Score starts at zero and increases by the value of each new merged tile.
  • You win when a 2048 tile appears, but you can continue toward larger tiles. The largest possible tile in this ruleset is 131,072.
  • The game ends when there are no empty cells and no adjacent equal tiles.

All of the above is documented in the rules summary Wikipedia — 2048 (video game).

The lineage most summaries compress too far

Cirulli did not clone Threes directly. The chain is Threes (iOS, February 2014) → 1024 by Veewo Studio → Saming’s browser 2048 → Cirulli’s 2048. Cirulli’s README cites 1024 and Saming explicitly and calls Threes an indirect inspiration GitHub — gabrielecirulli/2048. The original playable page repeats the same attribution: “Based on 1024 by Veewo Studio and conceptually similar to Threes by Asher Vollmer” Original 2048 — gabrielecirulli.github.io.

Why this matters technically: Threes uses a 1-2-3 onboarding deck and curved personalities; 1024 and 2048 strip that to powers of two. That simplification is the whole engineering story. Powers of two need no card deck, no character art, and no tutorial — just doubling. It also removes Threes’ natural brake, which is why Threes’ creators later said they had tried and dismissed the 2048 merging variant because it made the game too easy, and claimed to have each beaten 2048 on their first play Wikipedia — 2048 (video game).

Cirulli was surprised by the traffic, said he was unwilling to make money “from a concept that [he] didn’t invent,” and still shipped iOS and Android ports in May 2014 Wikipedia — 2048 (video game).

The stack: deliberately no engine

There is no Unity, no Phaser, no canvas framework in the original. It is HTML for the 4×4 grid and score boxes, CSS for tile sizes, colors, positions and slide animations, and vanilla JavaScript for grid state, input, and persistence. Wikipedia summarizes it as “originally written in JavaScript and CSS” Wikipedia — 2048 (video game); the playable page loads as a static GitHub Pages site with no installer Original 2048 — gabrielecirulli.github.io.

From the repository history and the game’s behavior, the load-bearing pieces are small and legible:

  • Grid model, not sprites: a 4×4 array plus tile objects. Moves are pure logic — slide, merge once, spawn — before any animation runs.
  • CSS transitions for feel: movement and pop effects are DOM position changes with CSS transitions, not a game loop. That is why the game feels smooth without a renderer.
  • Keyboard plus swipe: arrow keys on desktop and custom swipe handling on mobile. The README credits contributors for swipe handling on mobile, Windows Phone, and Android 2.3 support GitHub — gabrielecirulli/2048.
  • Local best-score persistence: best-score storage was added by contributor TimPetricola GitHub — gabrielecirulli/2048. It uses browser-local storage, so scores survive refresh but stay on-device — no account, no server.
  • Static hosting: the game is hosted on GitHub Pages, which the README notes means “I don’t have any hosting costs” GitHub — gabrielecirulli/2048.

That is the niche-tech bet: for a turn-based grid, DOM + CSS is enough, and “enough” ships in a weekend.

What zero-dependency gained and cost

Gained: weekend build, tiny download, runs in any 2014 browser and still runs today. Cost: no particle system, no physics, no built-in mobile packaging; every port reimplements input.

Gained: MIT license plus readable code turned forks into marketing; undo, leaderboard, better touch, terminal and 3D variants appeared within weeks. Cost: monetized clones could publish freely; Cirulli captured attention, not revenue.

Gained: static page with local-only state means zero hosting cost, instant share link, and school-Chromebook friendliness. Cost: no anti-cheat, no cross-device save, no balancing telemetry.

Gained: powers-of-two merge rule needs a one-sentence tutorial and creates endless one-more-move tension. Cost: less strategic texture than Threes; strong players call it too easy once corner discipline is learned.

The fork point is explicit in the record: because source was available, additions including score leaderboards, undo, and improved touchscreen playability were written by other people and released publicly Wikipedia — 2048 (video game). Cirulli’s own stance was permissive: spinoffs are “part of the beauty of open source software” as long as they add creative modifications Wikipedia — 2048 (video game).

How humans actually win: corners and monotonicity

Documented strategy is to keep the largest tile in one corner with other large tiles filling that row or column, then move in three directions while keeping the anchor fixed, and never trap small tiles behind a large tile Wikipedia — 2048 (video game).

This is not folk wisdom — it is the same heuristic AI solvers use. Solver evaluations favor empty squares, merge possibilities, large tiles at edges, and monotonicity of tile sizes especially for large tiles Wikipedia — 2048 (video game). In plain language: build a one-way slope down from your corner and do not poke holes in it.

If you want to feel that slope physically, play a few rounds of Stick Merge on EasyHub. It is a different genre — merging identical pistols into rifles to shoot stick targets — but the lesson transfers: merging identical things on time compounds damage, and cluttering the inventory with unmerged low tiers chokes progression EasyHub — Stick Merge. 2048 punishes the same clutter with a full board.

If you keep breaking your corner, switch to Bad Ice Cream on EasyHub for ten minutes. It is a maze puzzle where you collect fruit while building and breaking ice walls to reshape corridors EasyHub — Bad Ice Cream. Its core tip — always plan an escape route before entering a corner — is literal corner discipline. 2048 ends the same way Bad Ice Cream levels end: you did not lose on the last move, you lost three moves earlier when you closed your own exit.

The second life: a solver’s Hello World

The mathematical neatness of 2048 made it an AI benchmark. The well-known open solver by nneonneo uses expectimax optimization with a highly efficient bitboard representation to search upwards of 10 million moves per second, with heuristics for empty squares and large values near edges and corners GitHub — nneonneo/2048-ai. It can even drive the original browser game through Firefox or Chrome remote debugging as a proof of concept GitHub — nneonneo/2048-ai.

Research results kept climbing: as of 2022 AI reached over 95% probability of making a 16384 tile and over 75% for 32768; as of 2025 a combination of expectiminimax and pre-built tablebases observed 99.9% for 16384, 86.1% for 32768, and 8.4% for 65536 over 1200 simulated games, with median score around 820,000 Wikipedia — 2048 (video game). The evaluation recipe — expectiminimax to variable depth plus transposition tables and endgame-style tables, with parameters tuned by search or temporal-difference reinforcement learning — is summarized in the same AI section Wikipedia — 2048 (video game).

To train the think-ahead muscle that solvers automate, try Master Chess on EasyHub. It is full-rules HTML5 chess with AI levels and local two-player EasyHub — Master Chess. Chess and 2048 share the same discipline: control the center (or corner), develop without trapping yourself, and evaluate the opponent’s reply — except in 2048 the opponent is randomness itself.

My analysis: three contrarian takes

These are my interpretations, not Cirulli’s claims. They go against the usual “simple equals easy to copy, hard to sustain” summary.

1. Removability was the distribution strategy. Most postmortems say MIT licensing “allowed” clones. I think it caused distribution. By shipping readable code with permission attached, Cirulli turned every clone from theft into an ad. A monetized iOS clone certainly captured revenue Cirulli refused, but it also cemented “2048” as the generic name for the whole merge-tile family. Giving up ownership was how a no-marketing page won the naming war. The cost was real, the tradeoff was intentional.

2. 2048 feels hard because failure is permanent, not because math is hard. Threes designers are right that doubling is strategically easier than their deck. Yet players experience 2048 as crueler. My read: no undo in the original plus exponential tile values creates visible regret — one wrong swipe buries a 1024 behind a 2, and the board remembers. Difficulty here is emotional persistence, not combinatorial depth. That is why community forks immediately added undo: they were patching regret, not rules.

3. Zero-engine is anti-fragile in a way 2014 Unity WebGL was not. A DOM-grid game from 2014 still loads on a 2026 Chromebook with no migration. Contemporary WebGL exports from the same era often do not, because plugins, APIs, and hosting changed underneath them. For real-time 3D that tradeoff favors engines; for turn-based grids it reverses. If your game can be a web page, make it a web page — future compatibility is a feature you get for free by refusing dependencies.

What indie developers can steal

  • Prototype the rule, not the juice. If doubling tiles is not fun with gray squares and CSS slides, particles will not save it. 2048 proved the loop in a weekend.
  • Ship the repo, not just the link. Readable code plus MIT turned players into porters, teachers, and solver authors. Teaching use and MATLAB-contest AI entries extended the game’s life far beyond virality Wikipedia — 2048 (video game).
  • Design for solver legibility. Small state, deterministic moves plus one random spawn, and a monotonicity-friendly goal make your game streamable, analyzable, and bot-friendly — which is free content.
  • Decide your regret policy early. Undo, leaderboard, and touch improvements all came from forks because the original left them out. If permanent loss is your aesthetic, say so; otherwise ship undo on day one.
  • Credit the chain in public. “Based on 1024, conceptually similar to Threes” defused clone drama and reads as confidence. Attribution is cheap crisis management.

FAQ

Is 2048 still playable in its original form?
Yes. The original version remains live as a static page with the same one-line how-to-play and links to the official iOS and Android apps, warning that other versions are derivatives Original 2048 — gabrielecirulli.github.io.

Was 2048 a copy of Threes?
It is a clone of a clone by its author’s own description — 1024 and Saming’s 2048 in between, Threes as indirect inspiration GitHub — gabrielecirulli/2048. Commentators at the time called it “a clone of a clone” while also calling it viral and addictive Wikipedia — 2048 (video game).

Can I reuse the code?
The repository states 2048 is licensed under the MIT license GitHub — gabrielecirulli/2048. Check the license file and give attribution; the project welcomes forks via pull requests into master.

What is the best beginner strategy?
Pick one corner for your largest tile, fill that edge with descending tiles, prefer three directions, and spawn-check before every fourth-direction move. The solver heuristics formalize the same idea: empties, edge bias, monotonicity Wikipedia — 2048 (video game).

Where can I practice the underlying skills in a browser?
For merge timing try Stick Merge on EasyHub; for lookahead try Master Chess on EasyHub; for grid-space control try Bad Ice Cream on EasyHub. Each isolates one 2048 skill without copying 2048.

Top comments (0)