Skip to content

feat: add Board.AttacksFrom - #126

Open
CosmicVeil wants to merge 1 commit into
CorentinGS:mainfrom
CosmicVeil:feat/attacks-from
Open

feat: add Board.AttacksFrom#126
CosmicVeil wants to merge 1 commit into
CorentinGS:mainfrom
CosmicVeil:feat/attacks-from

Conversation

@CosmicVeil

Copy link
Copy Markdown

Summary

Adds Board.AttacksFrom(Square) []Square to expose squares attacked by a
piece independently of legal-move restrictions.

Closes #70.

Behavior

  • Includes friendly occupied squares as defended squares
  • Sliding attacks include the first blocker and stop beyond it
  • Pawn attacks include diagonals regardless of occupancy
  • Ignores pins, check, and side to move
  • Empty or invalid source squares return an empty result

Testing

  • Added tests for every piece type
  • Added pawn edge-file tests
  • Added friendly-blocker and sliding-blocker tests
  • Added pinned-piece tests
  • Added benchmark coverage

Verification

  • go test ./...
  • go test -race ./...
  • go test -bench=AttacksFrom -benchmem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Piece sight outside legal moves?

1 participant