0

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?

Brian Towers
  • 92,895
  • 10
  • 227
  • 372
dDo
  • 69
  • 2

2 Answers2

1

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) {
    if(*)
     defended = true
  }
}
David
  • 16,212
  • 26
  • 61
0

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