HI version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
100% Positive
Analyzed from 291 words in the discussion.
Trending Topics
#bishop#black#queen#check#dark#squared#solutions#place#attack#pieces

Discussion (7 Comments)Read Original on HackerNews
Python script: https://gist.github.com/dllu/698d5f71b2b9735c5c462ddf4a2f6fc...
Here's how it works:
0. precompute the attack patterns of each possible queen/bishop location as a bitmask, stored as an integer
1. generate candidate solutions, allowing attack rays to pass through other pieces, by brute forcing the positions of the 5 pieces and taking the bitwise OR of their attacks
2. out of the candidate solutions, check which ones are actually valid taking into account occlusion. Actually, you only need to check if the queen's horizontal attack is blocked by the bishop, as queens cannot block each other (the blocking queen herself has the same attacks so they effectively pass through each other).
That last word should be "check". not "checkmate". A king next to an unprotected queen will be in check but not checkmate as it can capture the queen.
Should maybe update the instructions to clarify that the dark-squared bishop is not constrained to dark squares.