Answers.Body: <p>Shouldn't something like the folowing be good enough? (* stands for however you check that <code>potentialDefendingPiece</code>can move to <code>piece</code>'s square)</p>
  <pre><code>for (piece in WhitePieces) {
    defended = false;
    for (potentialDefendingPiece in WhitePieces) {
      if(*)
       defended = true
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-13T06:19:10.643Z
Answers.LastActivityDate: 2020-08-13T06:19:10.643Z
Answers.UserDisplayName: David
Body: <p>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.</p>
  
  <p>Is there any easy way?</p>
  
Tags: <programming><cql>
Title: Script for finding undefended pieces
ThreadText: # Script for finding undefended pieces
  
  (Asked by: username_0 on 2020-06-06)
  
  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?
  
  **Tags:** programming, cql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-08-13. Score: 1
  
  Shouldn't something like the folowing be good enough? (\* stands for however you check that `potentialDefendingPiece`can move to `piece`'s square)
  
  ```
  for (piece in WhitePieces) {
    defended = false;
    for (potentialDefendingPiece in WhitePieces) {
      if(*)
       defended = true
    }
  }
  
  ```
  
  
  ---
  
  