Files
cc65-Chess/doc
Stefan WesselsandClaude Opus 5 4512ab9529 Document the engine that was replaced
The failure is more instructive than the fix, and the original is not bad
code - which is what makes it worth reading.  Two structural decisions made
it weak, both of them traps that are well known inside computer chess and
close to invisible from outside it:

  The attack database became the legality oracle.  It is the right structure
  for the attacker/defender display it was built for, and reusing it to
  answer "is my king attacked" is the natural next thought - but it meant
  testing one move for legality cost a full 64-square regeneration, and
  legality is the innermost loop of the whole program.

  The evaluation scored move desirability rather than position value.  Each
  scoring function is individually sensible; the quantity is not a property
  of the position, so it cannot be negated for the opponent, so accumulating
  it across plies does not describe anything.  This is the one that mattered
  most: the database made it slow, but this made depth not help.

Also covers what followed from those two - mate detection as special-case
machinery mutating a shared structure, promotion decided during make rather
than encoded in the move - and a positional-initialiser hazard in
gPieceValues where the comments run in a different order from the enum, so
the king and queen values landed swapped.

Leads with what the original got right, because it is the reason the rework
could port the movement rules rather than rederive them: the generator was
perft-exact to depth 5 on two reference positions, with one divergence, and
that divergence was a design choice rather than a bug.

Every excerpt and figure checked against the source at v1-original-engine.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 12:58:55 -07:00
..
2026-08-07 12:36:36 -07:00
2026-08-07 12:48:35 -07:00
2026-08-07 12:36:36 -07:00