SebLague / Chess-Challenge

Create your own tiny chess bot!
https://www.youtube.com/watch?v=Ne40a5LkK6A
MIT License
1.78k stars 1.07k forks source link

SquareIsAttackedByOpponent is returning true, although the square isn't attacked #482

Open Gamaya0 opened 9 months ago

Gamaya0 commented 9 months ago

Here the SquareIsAttackedByOpponent returns true, although the sqaure isn't attacked. Am I doing something wrong here?

image

image

danegraphics commented 9 months ago

The function includes squares that any piece is defending/attacking, whether the square is occupied or not.

Essentially, the question you are asking the function is "If I put an opponent piece on this square, can the player take it?"

For d7, in this case, the answer is yes, in three different ways.