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?.

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.

  • 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.
    – Scounged
    May 23, 2020 at 22:07
  • 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.
    – eguneys
    May 23, 2020 at 23:28
  • 1
    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: softwareengineering.stackexchange.com/q/160740/344999
    – Manik
    May 24, 2020 at 7:49

1 Answer 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?

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.