Engine PR 8.1: pawns — pushes, captures, attack mask, legality wiring #68
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
spec
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amaurycoudr/chess-project#68
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
#67
What to build
Make pawns a playable piece end-to-end through the public
GameAPI, for all positions where no pawn reaches the last rank. This is the base pawn tracer bullet: attack mask → pseudo-legal generation (non-capturing pushes + diagonal captures) →applyMoveen-passant-target lifecycle → legality wiring.Promotion (slice 8.2) and en passant capture (slice 8.3) are deliberately out of scope and additive. To avoid leaking illegal moves, this slice does not generate pawn moves onto the last rank — a last-rank pawn move with no
promotionfield is illegal, so omitting it (an absent legal move) is correct here; 8.2 adds it back as a promotion expansion.Implements step 8 (partial) of
docs/adr/0004-engine-slice-plan-and-king-first-piece-ordering.md.pawnAttacks(square, color)toattacks.ts— the (up to two) diagonal squares a pawn of the given color attacks. Color-dependent, unlikekingAttacks/knightAttacks. Models attacks only; non-capturing pushes are not attacks.pseudoLegalPawnMoves(position)tomovegen.ts— single push (square ahead empty), double push (from the starting rank, both intermediate and destination squares empty), and diagonal captures (pawnAttacksintersected with enemy pieces). Excludes any move landing on the last rank.applyMoveinrules.ts: on a double push set the next position'septo the skipped-over square; on every other move keepepcleared.isAttackedinrules.ts—pawnAttacks(target, byColor)intersected with the enemy pawn set.legalMovesaggregates king + knight + slider + pawn candidates, then runs the existing legality filter unchanged.rules-pawns.test.ts(pawn geometry, push blocking, double-push rules, captures, pinned-pawn legality, pawn-delivered mate,applyMoveep-target and halfmove-clock effects), following therules-knights.test.tsstyle.makePositionintest-fixtures.tsalready acceptswhitePawns/blackPawns/ep— no fixture change needed.Acceptance criteria
pawnAttacksreturns the correct diagonal targets for white (toward rank 8) and black (toward rank 1), truncated at the a/h filesGame.legalMoves()includes pawn single pushes when the square ahead is emptyGame.apply()of a double push setsepto the skipped-over square; every other move clearsepisAttackedreturns true when an enemy pawn attacks the square along its diagonal; a king cannot move onto a pawn-attacked squareGame.status()returnscheckmateon a pawn-delivered mate,ongoingwhenever a legal pawn move existspromotionfield;fromis the pawn's originrules-knights.test.tsstyle (behavioural assertions,algebraicTargets), written as vertical TDD slicespnpm lint,pnpm typecheck,pnpm test,pnpm buildall green from the repo rootImplemented by Sandcastle on branch
sandcastle/sequential-reviewer/1778948706723— awaiting review. Adds pawnAttacks, pseudoLegalPawnMoves, ep-target lifecycle in applyMove, and pawn clause in isAttacked.Promoted to branch
feat/engine-pr-8-1-pawns-pushes-captures-attack-mask-legality-wiring-68(PR #72), not yet merged to main. A dependent slice shouldgit fetch origin feat/engine-pr-8-1-pawns-pushes-captures-attack-mask-legality-wiring-68and branch off it.mentioned in issue #69
mentioned in issue #70
mentioned in commit
a6d484cae5