PUZZLTHINK

DEV NOTE

12 Janggi

12 Janggi AI dev notes

Too strong, toned down, then made strong again on purpose.

12 Janggi is played on a 3×4 board with four kinds of piece: general (將), minister (相), king (王) and man (子). The board is tiny and captured pieces can be dropped back in, so a computer can read very deep. Most of this AI’s story is therefore about how much *less* to read.

This note runs from the game’s launch on 16 November to the Very Hard level on 24 November and the retune on 26 November. It states exactly how many plies each level reads and where it adds randomness.

Play now

Published · 2026-11-26

A search AI from the start

12 Janggi launched on the evening of 16 November, and unlike Wallgo its AI searched from day one: it tries each move, follows the replies to a fixed depth and keeps the move that leads to the best result — iterative-deepening negamax with alpha-beta pruning. On a 3×4 board there are few moves, so even deep searches finish quickly.

The evaluation is plain material: man 1, minister 3, general 4, feudal lord (侯, a promoted man) 4.5, and pieces in hand at 0.9 of that. The king scores 0.35 for every row it has advanced instead, because a king that enters the enemy camp and survives wins. Captures of valuable pieces are searched first so alpha-beta cuts more.

At first the levels differed only in depth: Easy 1 ply, Normal 3, Hard 7 (within 0.9 s), each with a little noise added (2.5, 0.6 and 0.05) so games vary.

You could repeat the same moves forever

A fix at 1:30 the next morning started with a player’s report: the same moves could be repeated endlessly. The show’s rules have no draw by repetition, and the site only had a 200-move draw. So a move that brings the same position (board, both hands and side to move) back a third time became illegal, following the Korean janggi convention of not playing the same move three times.

The ban applies to players, the AI, friend rooms and timeout auto-moves alike; the board hides those targets and says why. In the rare case that every move would repeat, the ban is lifted so nobody is left without a move. The Easy–Hard AIs check it only for the move they are about to play; Very Hard models it inside the search (more below).

Hard was too strong: 7 plies → 5

On 20 November the levels were checked against real records (signed-in players’ games against the AI) for the first time. The target was human win rates of 80% on Easy, 50% on Normal and 25% on Hard. Reality was the other way round: people won 82% against Normal and only 5% against Hard. A 7-ply Hard was close to unbeatable.

  • Hard: 7 plies → 5, noise 0.05 → 0.2, 0.7 s to think.
  • Normal: 3 plies → 4, noise down to 0.35.
  • AI-vs-AI games the same day confirmed the Easy < Normal < Hard order.

It was tuned once more on 26 November. Hard hit its 25% target, but a 4-ply Normal was a little strong at 34%, and 3 plies was too weak. Today’s Normal reads 3 plies on about a third of its moves and 4 on the rest, with noise back up to 0.6. Any level plays an immediate win when it sees one, without noise.

LevelDepthNoiseTime
Easy1 ply2.5 (more than a piece)0.45 s
Normal3 plies (35%) or 40.60.45 s
Hard5 plies0.20.7 s
Very Hardusually 13–19 pliesrandom among moves within 0.12 of a man of the best1.5 s desktop / 1 s phone

Very Hard: built like a chess engine

The hell-mode AI, added on 24 November in the same commit as Russian Janggi’s.

With Hard toned down to 5 plies, a genuinely strong opponent had to live somewhere else. Very Hard was written as a separate engine. The old AI built a new board object for every move and was slow; the new one edits a single 12-cell array in place and undoes it, and computes attacked cells as bit masks. According to the commit it looks at about 2.5 million positions a second and reaches 13–19 plies per move.

PVS + transposition table

Principal variation search: the first move is searched exactly, the rest only checked for "is it better?". Each position has a 64-bit (two 32-bit halves) Zobrist hash so nothing is computed twice.

Killer and history ordering

Quiet moves that caused a cut elsewhere are remembered and tried first. Late quiet moves deep in the tree are searched one ply shallower.

Quiescence search

Evaluating right at the depth limit misses "about to be captured". At the leaves it follows captures until the position is quiet, and when in check it reads every escape for the first 6 extra plies.

Exact wins

Can take the king: win. Own king survived in the enemy camp: win. King can step into an enemy-camp cell they do not attack: win in two plies — computed directly.

The evaluation is much richer (in units where a man = 100): general 380, minister 330, lord 470 on the board, and pieces in hand are worth more than on the board (general 420, minister 360, man 120), since a piece in hand can go anywhere. The king earns 35 per row advanced and 60 more one row from the enemy camp. Add 6 per attacked cell, 14 per attacked cell around the enemy king, and 35% of the value of an enemy piece that is attacked and undefended, counted as already won.

The repetition ban inside the search

Very Hard keeps the hashes of every position in the game so far. A move that would make one of them appear a third time scores as unplayable inside the search. So it is never dragged into a line that relies on repetition, and it counts positions where the ban stops *you* from playing your best move.

"Winning tips" from the same search

On the morning of 17 November a "winning tips" button was added to the loss screen. It walks the game backwards and runs the AI search on each of your moves (about 0.3 s per position), looking for the last point where your move lost by force while another move would have won or at least held. It shows your move and the better one side by side, never suggesting a move the repetition ban forbids. Only your last 10 moves are checked, so a game that tipped earlier may show no turning point.

Real win rates

Signed-in players’ games against the AI as of 2026-11-26, 14:00 KST. Most were played before the 26 November retune.

LevelHuman win rateGames
Easy96.2%26
Normal33.3%681
Hard25.9%740
Very Hard1.6%500

People won 8 of 500 games against Very Hard, and 4 players hold its hell certificate — the lowest win rate of the six hell-mode games. Counting everyone, 12 Janggi had been played 7,266 times, 6,773 of them against the AI.

Gaps a human can use

Easy

One ply only

Easy sees one move ahead with heavy noise, so two-move traps — offer a piece as bait, then go for the king — work at once.

Normal

Some 3-ply decisions

A third of its moves are read only 3 plies deep. Lines whose point (a drop that checks the king) appears on the fourth ply work well.

Hard

Camp entry beyond 5 plies

Hard’s evaluation is only material and king advance. A king march into the enemy camp that takes six plies or more may not be stopped in time. It also checks the repetition ban only for the move it plays now.

Very Hard

The most honest opponent

Quiescence means it does not miss hanging pieces, and camp entry is computed exactly. The only gap is that it picks at random among moves within 0.12 of a man of the best, so the longer a balanced game lasts, the more chances it has to pick a slightly worse one. On phones it thinks for 1 s.

Where this comes from

This note is written only from the code, the commit history and the aggregate numbers below.

  • `src/lib/janggi.ts` — Easy/Normal/Hard AI (evaluate, negamax, chooseAiAction) and winning tips (scoreActions, turningPointAt)
  • `src/lib/janggiHell.ts`, `src/lib/janggiHellClient.ts`, `src/lib/janggiHell.worker.ts` — the Very Hard engine
  • `scripts/hell-janggi-selfplay.mjs` — Very Hard vs Hard self-play
  • Commits c611a3b (11/16 12 Janggi), c9e2ba8 (11/17 third-repetition ban), 0a24120 (11/17 winning tips), 1fe2d84 (11/20 retune: Normal 82%, Hard 5%), eb8f15e (11/24 Very Hard and self-play results), e227318 (11/26 Normal retune)
  • DB aggregates (2026-11-26 14:22 KST): game_results (mode = ai, game = janggi) win rate by level, hell_clears count, game_plays_daily totals

Read next

  • How the Wallgo AI plays

    From a reach-first territory estimate to alpha-beta with a transposition table: what each Wallgo AI level computes, and where it is weak.

  • Russian Janggi AI dev notes

    Even the Very Hard engine that reads to the end must lose to a first-move large cup in the centre — and how that shaped the AI and its win rate.

  • Blind Gomoku AI dev notes

    AIs that remember only the last 3, 8 or 36 moves, and a Very Hard one with full memory and VCF/VCT threat search — and how forgotten stones become a weakness.

All dev notes →