diff --git a/packages/server/src/bot/casual-brain.ts b/packages/server/src/bot/casual-brain.ts index adcdb85..8a4ffa2 100644 --- a/packages/server/src/bot/casual-brain.ts +++ b/packages/server/src/bot/casual-brain.ts @@ -82,7 +82,11 @@ export class CasualBrain implements Brain { if (!destPiece) score += 50; const piece = view.pieces[move.from]; - if (!piece) return score; // shouldn't happen, but safe. + // Reachable when scoring tests pass minimal fixture views. In real play + // the candidate's `from` is always one of our pieces (since candidates + // came from `legalCandidates` over our own squares), but the early + // return keeps unit tests from needing full board fixtures. + if (!piece) return score; const ownStartingRank = this.color === 'w' ? '1' : '8'; const ownPawnStartingRank = this.color === 'w' ? '2' : '7';