Skip to content

feat: add Board.AttacksFrom - #126

Merged
CorentinGS merged 1 commit into
CorentinGS:mainfrom
CosmicVeil:feat/attacks-from
Aug 17, 2026
Merged

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

Conversation

@CosmicVeil

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.50000% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.44%. Comparing base (2b08106) to head (899a883).

Files with missing lines Patch % Lines
attacks.go 72.50% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #126      +/-   ##
==========================================
- Coverage   80.51%   80.44%   -0.08%     
==========================================
  Files          27       28       +1     
  Lines        4424     4464      +40     
==========================================
+ Hits         3562     3591      +29     
- Misses        726      737      +11     
  Partials      136      136              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CorentinGS
CorentinGS merged commit 15c979b into CorentinGS:main Aug 17, 2026
6 of 8 checks passed
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?

2 participants