Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chess] Reduce _is_attacked call #1260

Merged
merged 10 commits into from
Oct 23, 2024
Merged

[Chess] Reduce _is_attacked call #1260

merged 10 commits into from
Oct 23, 2024

Conversation

sotetsuk
Copy link
Owner

@sotetsuk sotetsuk commented Oct 23, 2024

As is_attacked call is bottleneck, this PR intends to reduce it.

In normal play, the number of legal action is < 200. See these extreme examples without black pieces:

9 Queens 8 Queens
# legal actions 206 196
board image image

These examples are found by black box optimization. There might be larger example but I believe 200 is quite enough.

@sotetsuk
Copy link
Owner Author

image

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.95%. Comparing base (744cb2b) to head (67bd5d0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1260   +/-   ##
=======================================
  Coverage   79.95%   79.95%           
=======================================
  Files          61       61           
  Lines        5756     5758    +2     
=======================================
+ Hits         4602     4604    +2     
  Misses       1154     1154           

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

@sotetsuk
Copy link
Owner Author

image image

@sotetsuk
Copy link
Owner Author

image

@sotetsuk sotetsuk changed the title [Chess] reduce _is_attacked call [Chess] Reduce _is_attacked call Oct 23, 2024
@sotetsuk sotetsuk merged commit 5ae5f01 into main Oct 23, 2024
2 checks passed
@sotetsuk sotetsuk deleted the sotetsuk/reduce-checked branch October 23, 2024 11:21
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.

1 participant