1. Objective

In an earlier experiment, I generated a table of legal king-and-rook versus king (KRK) endgame positions, together with their distance to mate (DTM). The next step was to investigate whether a small neural network could learn a useful decision from the board representation.

The initial task is deliberately limited: given a legal KRK position with White to move, predict whether an optimal continuation should begin with a king move or a rook move. The model does not yet predict a destination square or a complete chess move.

The experiment produced a model of approximately 66 KB after about one minute of training. These figures describe the size and training cost, not its generalization performance.

2. Preliminary Results

The reported output order is [King, Rook]. The examples below are individual predictions; they should not be interpreted as a substitute for held-out evaluation.

2.1. Position A: Rook preference

KRK position A

8/8/3k4/8/8/8/8/KR6 w - - 0 0

Reported DTM: 13

  • King: 3.56%

  • Rook: 96.44%

The network strongly favors moving the rook, consistent with the intuition of restricting the opposing king’s space. The exact optimal-move classification should be checked against the DTM table.

2.2. Position B: King preference

KRK position B

8/8/8/8/7R/2K5/8/k7 w - - 0 0

Reported DTM: 2

  • King: 99.90%

  • Rook: 0.10%

Here the network strongly favors a king move. Whether this is the only optimal move category can be verified using the precomputed DTM table.

2.3. Position C: Mixed

KRK position C

8/8/8/2R5/8/2K5/8/1k6 w - - 0 0

Reported DTM: 2

  • King: 58.56%

  • Rook: 41.44%

The position is labeled Mixed: at least one optimal move exists for each piece. The relatively balanced prediction is noteworthy, but does not establish that the network has recognized both categories as optimal.

2.4. Interpretation

The three positions illustrate different outputs of the same classifier. Their diagnostic value lies in comparison with the optimal move categories derived from the DTM table. In particular, a Softmax output near 50/50 is not evidence, by itself, that both choices are valid.

3. Implementation and Evaluation Pitfalls

3.1. Feature encoding

The initial implementation contained a feature-encoding error: the feature intended to represent the black king’s position was populated from the black rook’s position instead. In KRK, Black has no rook.

After correcting the encoding and retraining, the predictions became substantially more consistent with the expected decisions. This underlines the importance of checking the input representation before changing network depth, optimization settings, or other hyperparameters. An implementation error in the feature pipeline can make a viable learning task appear unsuccessful.

3.2. An unsuitable evaluation reference

An early diagnostic compared the network’s output with a hypothetical distribution in which rook moves were assumed to be twice as likely as king moves:

\[P(King) = 1/3, \qquad P(Rook) = 2/3.\]

The distance to this reference distribution was required to be below 0.1. This was an arbitrary criterion, not a measure of move optimality. Even if those proportions matched the aggregate frequencies of a dataset, they would not determine which piece should move in a particular position.

A task-aligned evaluation should instead compare predictions with optimal-move categories computed from the DTM table, using a separate test set. Metrics such as classification accuracy, confusion matrices, and cross-entropy can then be interpreted in relation to the actual learning objective.

4. From Exclusive Classification to Multi-Label Classification

The current binary classifier produces a Softmax distribution:

\[p_K + p_R = 1.\]

This is natural when exactly one category is correct. KRK positions, however, may admit optimal moves with both the king and the rook. For these positions, an exclusive target loses relevant information.

A more faithful formulation asks two separate questions:

  • Does at least one optimal king move exist?

  • Does at least one optimal rook move exist?

Optimal move categories King target Rook target

King only

1

0

Rook only

0

1

Mixed

1

1

A model with two independent Sigmoid outputs could estimate these two labels without imposing a sum-to-one constraint. Training could use binary cross-entropy for each output:

\[\mathcal{L}=-\sum_{i\in\{K,R\}}\left[y_i\log(p_i)+(1-y_i)\log(1-p_i)\right].\]

For a Mixed position, the target is (1, 1), so both predicted scores can be high. These scores would represent the model’s estimates that at least one optimal move exists for each piece; they would not represent the proportion of optimal moves among all legal moves of that piece.

This change does not prove that the multi-label model will perform better. It makes the target representation more closely aligned with the structure of the problem and provides a testable hypothesis.

5. Next Steps

The precomputed DTM table makes it possible to derive move-category labels systematically. For each legal White move, optimality can be assessed against the DTM recurrence, including Black’s best reply. The resulting labels distinguish King only, Rook only, and Mixed positions.

The next experiments will compare the existing Softmax classifier with a multi-label Sigmoid model on the same training and test partitions. Evaluation should report performance by category and by DTM range, and explicitly account for positions with more than one optimal move.

A later extension would predict individual legal moves rather than only the piece to move. For now, the objective is narrower: establish how reliably a compact model can recognize optimal move categories, and understand the effect of the target representation on that task.

6. Conclusion

This initial experiment demonstrates that a compact neural network can produce strongly differentiated predictions on selected KRK positions with modest training time and model size. It does not yet establish generalization accuracy.

Two methodological lessons emerged: verify feature encoding before interpreting failed training runs, and evaluate against chess-derived ground truth rather than an assumed probability distribution. The existence of Mixed positions also motivates a move from exclusive binary classification to a multi-label formulation, which will be the focus of the next experiment.