Answers.Body: <p>Yes, you can of course create a chess engine that does that. What you're saying is just a tiny part of engine search tree. You will need to read about more chess programming to get yourself started. Please come back when you have a concrete question.</p>
  
  <p>Stockfish is free, why  not start from it?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-24T10:16:14.517Z
Answers.LastActivityDate: 2020-05-24T10:16:14.517Z
Answers.UserDisplayName: SmallChess
Body: <p>I want to make a program that can identify chess tactics in the position, while searching moves according to given heuristics. but I am not sure exactly how to go about this. 
  Related to this <a href="https://chess.stackexchange.com/questions/5056/is-there-a-chess-engine-that-does-not-use-brute-force-search">Is there a chess engine that does NOT use brute-force search?</a>.</p>
  
  <p>For example let's analyze this position:</p>
  
  <pre><code>[FEN "5rk1/p2Q1ppp/1q2pb2/2rp1b2/5B2/P1N1P3/1P3PPP/R4RK1 w - - 0 1"]
  </code></pre>
  
  <p>The best move is Na4 forking rook and queen. But Bd6 also forks two rooks but leads to a bad position.
  A train of thought could be like:</p>
  
  <pre><code>If Bd6 attacks two rooks, Rxc3 captures knight;
      If bxc3 captures rook, Rd8 skewers queen and bishop on d6,
          If Bc7 attacks the queen, Rxd7, Bxb6 axb6
      If Bxf8, Rc7 attacks the queen,
          If Qe8 defends bishop, Qc6 attacks Qe8,
              If Qb8 moves the queen, Rc8 attacks queen and bishop.
  </code></pre>
  
  <p>In this position single move Na4 has the tactical motive of double attack, which should be fairly easy to spot. But it will also spot Bd6 move as a double attack, but needs to be searched further to decide that it's not working, maybe we need to spot all the other moves as uninteresting and not include in the output or the search.</p>
  
  <p>A simple way to get started is to identify about pins, skewers, attacks, pressures, hanging pieces etc.
  Apart from that, I am not sure what the next step should be, I mean I don't even know what the input and output should be to this program.</p>
  
  <p>Is a single position enough to identify a tactical motif or a line needs to be given as input, in which case I need to come up with the best lines as
  well.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-23T22:07:45.477Z
Comments.Text: How are you planning to implement the recognition of various general tactical themes? Are you going to do some hard-coding or do you have another plan? In the case of you trying to hard-code, I'd suggest you rethink your project.
Comments.UserDisplayName: Scounged
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-23T23:28:56.747Z
Comments.Text: Mate patterns could be hard coded, or we can have general rules for trapping a piece, and the final goal would be to trap the king.
  A goal might be to defend every piece, so every piece might have a defense type like; move away, block, defend, attack, ignore, sacrifice, hung etc. which are all associated with a list of legal moves. So if a piece is attacked and has no defense like move away, block or defend, then it's a trapped
  piece.
Comments.UserDisplayName: eguneys
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-24T07:49:09.510Z
Comments.Text: Your question is too broad try to break it down into smaller problems and then ask something more specific. Anyway you might find an answer here: https://softwareengineering.stackexchange.com/q/160740/344999
Comments.UserDisplayName: Manik
Tags: <engines><tactics><chess-algorithms>
Title: How to make a chess engine that can identify tactics in the position?
ThreadText: # How to make a chess engine that can identify tactics in the position?
  
  (Asked by: username_0 on 2020-05-23)
  
  I want to make a program that can identify chess tactics in the position, while searching moves according to given heuristics. but I am not sure exactly how to go about this.
  Related to this [Is there a chess engine that does NOT use brute-force search?](https://chess.stackexchange.com/questions/5056/is-there-a-chess-engine-that-does-not-use-brute-force-search).
  
  For example let's analyze this position:
  
  ```
  [FEN "5rk1/p2Q1ppp/1q2pb2/2rp1b2/5B2/P1N1P3/1P3PPP/R4RK1 w - - 0 1"]
  
  ```
  
  The best move is Na4 forking rook and queen. But Bd6 also forks two rooks but leads to a bad position.
  A train of thought could be like:
  
  ```
  If Bd6 attacks two rooks, Rxc3 captures knight;
      If bxc3 captures rook, Rd8 skewers queen and bishop on d6,
          If Bc7 attacks the queen, Rxd7, Bxb6 axb6
      If Bxf8, Rc7 attacks the queen,
          If Qe8 defends bishop, Qc6 attacks Qe8,
              If Qb8 moves the queen, Rc8 attacks queen and bishop.
  
  ```
  
  In this position single move Na4 has the tactical motive of double attack, which should be fairly easy to spot. But it will also spot Bd6 move as a double attack, but needs to be searched further to decide that it's not working, maybe we need to spot all the other moves as uninteresting and not include in the output or the search.
  
  A simple way to get started is to identify about pins, skewers, attacks, pressures, hanging pieces etc.
  Apart from that, I am not sure what the next step should be, I mean I don't even know what the input and output should be to this program.
  
  Is a single position enough to identify a tactical motif or a line needs to be given as input, in which case I need to come up with the best lines as
  well.
  
  **Tags:** engines, tactics, chess-algorithms
  
  > **Comments:**
  > **username_1**: How are you planning to implement the recognition of various general tactical themes? Are you going to do some hard-coding or do you have another plan? In the case of you trying to hard-code, I'd suggest you rethink your project.  
  > **username_0**: Mate patterns could be hard coded, or we can have general rules for trapping a piece, and the final goal would be to trap the king. A goal might be to defend every piece, so every piece might have a defense type like; move away, block, defend, attack, ignore, sacrifice, hung etc. which are all associated with a list of legal moves. So if a piece is attacked and has no defense like move away, block or defend, then it's a trapped piece.  
  > **username_2**: Your question is too broad try to break it down into smaller problems and then ask something more specific. Anyway you might find an answer here: https://softwareengineering.stackexchange.com/q/160740/344999  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2020-05-24. Score: 1
  
  Yes, you can of course create a chess engine that does that. What you're saying is just a tiny part of engine search tree. You will need to read about more chess programming to get yourself started. Please come back when you have a concrete question.
  
  Stockfish is free, why not start from it?
  
  
  ---
  
  