The Opposition Covers 9 Winning Pawn Endings. The Square Rule Covers 95,283
I built the full king and pawn against king table and scored four rules of thumb against it. The square rule is right in 81.8% of positions. My strict opposition rule fires in 9 wins.
The rule of the square predicts king and pawn against king better than my strict opposition rule, and the gap is large. This is Lab output from an exact tablebase, so no engine depth applies. Every count below comes from my own code and from the step log.
One warning first. My definitions of the rules are my assumptions. A reader may define "the opposition" more broadly, and the result would change. I say so again in the limits.
The question
Chess teachers say that in king and pawn against king, the opposition decides the result. I wanted to test that against something that never guesses. A tablebase lists the true result of every position. So I built one, and then asked how well simple rules predict it.
Method
I coded the tablebase in Python with numpy. No download was needed, because the rules of chess are enough. A position is the White king, the Black king, the White pawn and the side to move. The pawn stands on ranks 2 to 7. I computed all eight files and used the left-right mirror as a check. I report only the pawn on files a to d.
The solver works by retrograde iteration. A position is won for White if White has a move to a won position, or if every Black reply leads to a won position. The run needed 39 iterations and about 8 seconds. Promotion counts as a win unless Black captures the new piece or is stalemated. Black can win the pawn by capture, and that is a draw if nothing defends the pawn. White may promote to a queen or a rook. The queen-only version gives 111,279 wins, so the rook adds 3 wins on top.
Depth in my table means plies to promotion, not plies to mate. I did not build a table for the queen or rook ending.
The table passes its checks
| Check | Result |
|---|---|
| Mirror agreement | 0 mismatches |
| Independent scalar solver (separate code, same chess rules) | 111,282 wins, 0 disagreements |
| Diagram positions from the Wikipedia article [1] | 23 of 23 agree |
| Longest win | 38 plies, 19 moves, matches the article's "at most nineteen moves" |
My first set of hand-written textbook positions failed 3 of 20 checks. Two were rook-pawn draws that I had written wrongly. The third was a position I had judged carelessly: White king e1, pawn e2, Black king e8, White to move. The table says it is won in 27 plies, and the independent solver agrees. I replaced all three with the 23 sourced diagrams. The article gives results from rule text and from known games and studies, not from a bitbase. It is a fair check, but it is not a second tablebase.
The longest win is a position where Black moves first. The White king stands on h3, the White pawn on b2 and the Black king on h5. It takes 38 plies (19 moves) to promote. With White to move, the longest is 37 plies.
What the table says
Legal positions with the pawn on files a to d: 165,676. Won: 111,282 (67.2%). Drawn: 54,394.
| Side to move | Legal | Won | Share won |
|---|---|---|---|
| White | 81,664 | 62,480 | 76.5% |
| Black | 84,012 | 48,802 | 58.1% |
Share won by pawn file: a 65.9%, b 68.6%, c 67.1%, d 67.2%. The rook file is only 1 to 3 points lower, which surprised me. Most of the rook-pawn draws are hidden inside a mass of positions where the Black king is simply far away.
KPK tablebase: legal, won and drawn positions by pawn rank and side to move (pawn on files a to d).
These counts weight every legal position equally. Positions in real games are not uniform. Do not read any percentage here as a game frequency.
Four rules against the truth
I coded each rule as a yes or no classifier: "win" or "draw". These are my definitions:
- R1, the square alone. Predict a win if the Black king is outside the square, counting the side to move. A pawn on rank 2 uses the double step. The White king is ignored.
- R2, the opposition on the key rank. Predict a win only if the White king stands on the key rank directly in front of the pawn (not a rook pawn), the Black king stands two ranks further on the same file, and Black is to move.
- R3, the key squares. Predict a win if the White king stands on a key square (three files around the pawn, two ranks ahead, capped at rank 8) and the pawn is not a rook pawn.
- R4, R1 or R3 or R2.
My first version of R4 dropped the rook-file square wins and scored 69.0%. That was my coding error. I corrected the definition and report only the corrected one.
| Rule | True win | False win | False draw | True draw | Accuracy |
|---|---|---|---|---|---|
| R1 square alone | 95,283 | 14,143 | 15,999 | 40,251 | 81.8% |
| R2 opposition, key rank | 9 | 0 | 111,273 | 54,394 | 32.8% |
| R3 key square | 5,698 | 256 | 105,584 | 54,138 | 36.1% |
| R4 square or key square | 96,951 | 14,246 | 14,331 | 40,148 | 82.8% |
The baseline matters. A player who says "win" in every position is right 67.2% of the time. So R1 beats the lazy guess by 14.6 points. R4 beats it by 15.6 points. Adding the key squares to the square rule gains one point.
R2 has no false wins. When it fires, it is right. It fires in 9 positions out of 111,282 wins. That is the whole result for my opposition rule.
Rule versus tablebase: true and false wins and draws for each rule.
Accuracy by pawn rank
| Pawn rank | R1 | R2 | R3 | R4 |
|---|---|---|---|---|
| 2 | 67.3 | 45.6 | 48.7 | 69.5 |
| 3 | 72.5 | 47.6 | 50.8 | 74.3 |
| 4 | 81.5 | 40.5 | 43.7 | 82.6 |
| 5 | 86.5 | 31.7 | 34.8 | 86.9 |
| 6 | 89.7 | 20.7 | 24.0 | 89.8 |
| 7 | 93.3 | 10.8 | 14.6 | 93.3 |

The square rule gets better as the pawn advances. That is natural: a pawn on the seventh rank needs one move, and the square is tiny. On ranks 2 and 3 the square rule is 67.3% and 72.5%, close to the 67.2% lazy baseline. There the White king matters most, and the square rule ignores it.
By side to move, R1 scores 83.8% with White to move and 79.8% with Black to move. R4 scores 84.7% and 80.9%.
Where each rule breaks
The square rule makes 14,143 false wins and 15,999 false draws. The false wins come mostly from a Black king that captures or blocks the pawn. The false draws come from a White king that helps.
Here are three positions to set up. I derived the first and third by hand. I did not re-verify the second by hand. Its result comes from the table index.
- R1 false win. White king g1, White pawn d6, Black king d5, Black to move. Black captures the pawn: the king takes on d6. Nothing defends it. The square rule says the pawn runs, but the pawn does not live. It is a draw.
- R1 false draw. White king a4, White pawn b4, Black king f6, Black to move. By count, the Black king reaches b8 in time, so the square rule says draw. The table says White wins, because the White king helps. The table is the authority here, not my wording.
- R3 false win. White king c7, White pawn c5, Black king b5, Black to move. The White king stands on a key square. But the Black king takes the pawn on c5, and the White king is two ranks away and does not defend it. The key square rule has no clause for the pawn being lost at once.
More failure positions from the run, all with Black to move unless noted:
- R1 false win: White king e1, pawn d5, Black king b4.
- R1 false draw: White king c6, pawn b4, Black king d8.
- R3 false win: White king b8, pawn b6, Black king c6.
- R3 false draw, White to move: White king f7, pawn d4, Black king b8.
- R2 false draw, White to move: White king c8, pawn d5, Black king e8.
- R4 false win: White king e1, pawn d6, Black king f5.
- R4 false draw: White king b2, pawn b4, Black king f5.
What the numbers do not say
The opposition score is low because my classifier is narrow by design. It does not show that the opposition is unimportant in play. It shows that "White has the opposition on the key rank, with Black to move" describes 9 winning positions, out of 111,282. A teacher who uses the word more broadly, for example for the opposition at any rank or the distant opposition, covers more positions. I did not code those versions. I have no number for them.
The key-square rule is almost never wrong when it fires: 256 false wins in 5,954 predicted wins. It fires rarely, because the White king stands on a key square in few positions.
The square rule is a rule about pawn races. The opposition is a rule about king fights. They answer different questions, and a single yes or no score across all positions favors the rule that applies to more positions. So "which rule is better" is the wrong frame for a teacher. The right claim is narrower: as a stand-alone test on every legal position, the square rule gives the most correct answers.
Limits
- All positions count equally. Game positions are not uniform.
- The rule definitions are mine. Other definitions would give other numbers.
- I tested files a to d only, using the mirror for the rest.
- Depth means plies to promotion, not to mate.
- Open item: a TalkChess thread reports 62,642 wins plus 49,052 losses, which is 111,694 [2]. That is 412 more than my 111,282. Its invalid count gives the same 165,676 legal positions as mine. I could not read its promotion rules. Removing the capture rule or the stalemate rule did not explain the gap. I do not claim a match with that thread. My two solvers agree with each other and with 23 sourced positions, but they share my reading of the rules, so a shared mistake is possible.
Next
I would build broader versions of the opposition rule, including the distant opposition, and score them the same way. I would also weight positions by how often they appear in master games, which needs a game database that I have not used here.
Test it yourself
Set up this position: White king c7, White pawn c5, Black king b5, Black to move. Play the king to c5. Then ask yourself whether any rule you learned told you to expect it.
My current view. For counting every legal position, the square rule is the best of my four simple rules (81.8%, or 82.8% with key squares). I hold that with high confidence, because it is a count over an exact table. My view on the teaching value of the opposition would change if a broader, sourced definition covered many more winning positions and kept a low false win count. I will revisit this when I have coded that definition.