Bruna Worlds
Devlog · Momiji Go

How Lord Tsukikage plays Go at seven strengths

Momiji Go's opponent is a Go program that thinks inside your browser, on your own device. Making it strong was the easy half. The harder half was making it weak in a way that feels like a person across the board, and keeping each level the same strength on a phone, a laptop and a Meta Quest.

Lord Tsukikage, in a fox mask and court hat, seated behind a Go board in an autumn garden, seen from the player's seat
Lord Tsukikage across the board, from the player's seat. Every move he makes is worked out on the device you are playing on.

How he thinks

Lord Tsukikage is a Monte Carlo tree search, the family of methods that made computers good at Go in the years before neural networks. To judge a move, the program plays the rest of the game out many times, quickly and a little at random, and counts how often each side wins. A move that wins more of those quick games, called playouts, looks better. The search keeps a tree of the moves it has tried and spends more of its playouts on the lines that look promising.

Two additions make it far stronger for the same effort. Both are used by open-source Go programs such as Pachi and Michi, which Momiji Go's engine follows in spirit:

  • Shared statistics. A playout teaches the search about every move played in it, not only the first. If a point keeps turning up in games that Black wins, it rises in Black's estimation everywhere in the tree. This is known as RAVE, or "all moves as first".
  • Go sense before any search. Each candidate move starts with a small bias from simple knowledge: capturing and saving stones are good; a move near the last one is often urgent; the third and fourth lines are good places to start in an empty area, while the first and second lines are poor ones early in the game; a move that puts your own stones in atari is suspect.

The engine is written in TypeScript and runs in a Web Worker, a separate thread of the browser. The board and the garden keep moving while he thinks, nothing is sent to a server, and he plays just as well with no connection at all.

Why a shorter clock is not a weaker player

The obvious way to make an easier opponent is to give it less time to think. On a 9×9 board, that barely works. A search like this one comes close to its best on a small board after a few hundred playouts, and a browser runs a few hundred in a fraction of a second. Levels that differed only in thinking time played almost the same moves, and a beginner could not tell them apart.

What a person across the board does notice is how far ahead the opponent reads, how often it plays its second-best idea, and whether it sees a capture coming. So each level is set by five dials rather than one:

  • Playouts. A cap on playouts, in proportion to the size of the board. It grows by about three times from one level to the next, so each step up reads visibly further. This is the dial that matters most.
  • Thinking time. A limit as well, so that a slow device never keeps you waiting. The search stops at whichever limit it reaches first.
  • Choice. A strong level always plays the move its search visited most. A weaker level picks among its best few moves at random, weighted towards the better ones, so it regularly plays its second or third choice. Of all the ways to be weak, this one looks the most human.
  • Quick moves. At the lower levels, some moves are played with no search at all: a quick pick among the moves that look reasonable at a glance.
  • Blind spots. Quick moves are never allowed to put his own stones in atari or fill one of his own eyes. And at every level but the lowest, there are no quick moves while a group of two or more stones hangs in atari, for either side: a random move then looks broken rather than weak, so the search decides. The Novice alone may overlook a group in atari, because losing a group you forgot about is exactly what a novice does.

The seven levels

These are the settings on a 9×9 board. On larger boards each level gets more time, and its playout cap grows with the number of points.

LevelNamePlayouts per move, at mostThinking time, at mostChance of a quick move
1Novice240.12 s55%
2Beginner810.2 s32%
3Casualabout 2800.32 s16%
4Clubabout 9700.6 s6%
5Strongabout 3,2001 snone
6Expertabout 11,3001.8 snone
7Masteras many as fit in the time2.8 snone

The choice dial moves the same way: the Novice strays from his best move often, Casual now and then, Strong rarely, and Expert and Master never. On a 19×19 board the Master thinks for up to 6.5 seconds a move.

The same opponent on every device

A gaming PC can run many times more playouts in a second than a phone or a headset. If time were the only limit, Lord Tsukikage would be a stronger player on a fast computer than on a Meta Quest, and a level would mean something different on every device. The playout cap prevents that: up to Expert, he reads the same number of lines wherever he plays, and a slower device only takes a little longer to reach them.

The Master is the exception, on purpose. He has no cap and uses all of his time, so he is at his strongest on the fastest device. If he beats you on a phone, he will beat you on a desktop too.

Knowing when to stop

A program that reads thousands of games still has to know when one is over. Late in a game he checks whether every point on the board is settled, and passes if it is. After you pass, he passes too if he would win even with every unsettled point going to you. And at the higher levels, once one move has won 97 percent of at least 4,096 playouts, or lost that many, he stops thinking early rather than spend the rest of his time confirming it.

The same playouts do two more jobs. After each move, a short run of them estimates who owns each point, which is the estimated score you see beside the board. When the game ends, a longer run decides which stones are dead before the count. In a game between two people online, one device makes that judgement once and sends it to the other, so the two can never disagree about the result.

Which level to choose

Your first game is at level 3, Casual. If you have just learned the rules, the last of the twelve lessons sends you to a 9×9 board at strength 1, the Novice, and the Novice and the Beginner are there to be beaten while capturing and counting become familiar. Our advice is simple: when you win most of your games at a level, move up one. Each step reads about three times as far ahead, and you will feel it.

The rules are in How to play Go, and the ideas that beat the lower levels are in Go strategy for beginners. Or sit down with him now on the Momiji Go page.