Skip to content
YiBoard
Play

2026-10-05

Evaluation Functions: Judging the Position

Search stops halfway, and the other half is the evaluation function. Here is what board evaluation actually does, how gomoku shapes get scored, when heuristic scoring lies, and how to turn engine numbers into your own judgement.

#gomoku#ai#strategy

Board evaluation is the function that answers a question the search cannot: the game is not over, so who is ahead? Alpha-beta pruning decides which lines are worth reading, and the evaluation function decides what those lines are worth once reading stops. If you have read how the search runs in your browser, this is the other half of the same program.

Why the search has to stop halfway

A 15x15 board has 225 intersections, and the full game tree is far larger than anything a browser tab can walk. Search has to be cut off at a fixed depth, and the position at that depth is almost never settled. It is a messy board with three or four directions developing at once. Something has to compress that mess into one number.

That something is the evaluation function. It reads only the final board of a line, not the moves that produced it, so it has to be cheap. A function costing 1 ms can run a few hundred thousand times inside a 500 ms budget. One costing 10 ms runs fifty thousand times and the search gets shallower. Speed here is not an optimisation detail, it sets how deep the engine can think.

Scoring shapes: the numbers behind board evaluation

The function does not judge whether a position looks pleasant. It counts shapes. The values below are a simplified version of the magnitudes inside our gomoku engine. The units do not matter, only the ratios do.

  • Open four, both ends empty: 100000. It cannot be defended, so treat it as a win.
  • Live three, three in a line with both ends open: 10000. One move from an open four.
  • Sleeping three, one end blocked: 1000. Still a threat, but the opponent has time to answer.
  • Open two: 100. Raw material, worth almost nothing on its own.
  • Sleeping two: 10.
  • Crossing point: both lines are scored at once, which is usually where the number jumps. That is why a double threat costs far more than two single ones.
  • Opponent shapes use the same values subtracted, with defense weighted slightly higher than attack during the opening.

A gomoku evaluation function, written out

A gomoku evaluation function in production does two things: scan for shapes, then sum them. The scan slides a five-square window along all four directions, horizontal, vertical, and both diagonals, and classifies what it finds into the shapes above. The sum applies the weights, subtracts the opponent's total, then adds a small tempo bonus, because the right to move is itself worth something.

Written on one line: score = weighted shapes for me, minus weighted shapes for you, plus tempo. It predicts nothing and understands no intent. It weighs what is visible on the board right now. That sounds plain, and paired with a deep enough search it produces play that is genuinely hard to beat in 500 ms.

Where heuristic game scoring goes wrong

Heuristic game scoring has a few fixed failure modes, and knowing them matters more than knowing the values.

  • Horizon effect: the engine pushes a loss just past its depth limit and calls the position fine. It will choose to lose slowly over losing now, because the score looks best right at the edge.
  • Double counting: a stone belonging to two lines gets counted twice, so a compact cluster outscores a spread one. That bias is usually right, and it breaks when the opponent seals you from the outside.
  • No reading of intent: a shape that only works if the opponent misses it still scores in full. The function assumes perfect vision on both sides, which is true of neither.

Using position analysis without obeying it

Position analysis from a 500 ms engine is a second opinion, not a verdict. The useful way to read it is as a check on a feeling you already have: you think that move was weak, so see whether the number dropped too. If the number disagrees with you, find which line it counted before you decide who is right.

  • Play the move you intended, then look at how the score moves. Doing it the other way round turns you into someone copying an answer key.
  • Watch the move where the score jumps, not the final number. A jump means a shape became real.
  • Review one or two turning points per game. Score-watching the whole board leaves you remembering nothing.

FAQ

What is a board evaluation function?

The part of an engine that scores a position. Once the search stops at its depth limit, this function reads the resulting board and returns a single number used to compare candidate lines.

Why not search until someone wins?

The tree is too large. Gomoku on a 15x15 board has 225 intersections, and exhaustive search exceeds what a browser tab can spend, so the search cuts off at a fixed depth and the evaluation function fills the gap.

Can engine analysis actually make me a better player?

Yes, if you use it to test your judgement rather than in place of it. Play your own move first, then watch the score move on the play page and find the shape that caused the jump.

The engine will not explain why you lost, only where the number turned against you. Closing the gap between that number and your own judgement takes games: open a match on the play page, no sign-up, and watch the score move with each shape. The rules sit on how to play, and the search half is covered in the engine in your browser.

Play a free gomoku game

Related

explore.title

YiBoard (yiboardgame.com) — 中华棋类,浏览器即玩,免费无注册。 去下一局 · 更多博客 · 玩法指南