I am looking for a script/code/CQL that searches for undefended pieces in a given position. I know that is possible to do it in the python chess library, but that is too complicated for me.

Is there any easy way?

2 Answers 2


Shouldn't something like the folowing be good enough? (* stands for however you check that potentialDefendingPiececan move to piece's square)

for (piece in WhitePieces) {
  defended = false;
  for (potentialDefendingPiece in WhitePieces) {
     defended = true

You can use "Chess Query Language" for coding this, as it will be quicker to work with and easier to understand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.