complexity of mate problems

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

Uri Blass
Posts: 10893
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

complexity of mate problems

Post by Uri Blass »

I think we can define complexity of chess problem as the number of lines you need to calculate to prove the solution.

Let start with pesudo complexity of mate in 1 in a problem I composed.

[d]4R2B/3pn1n1/R7/4k3/R7/4n1nQ/7B/K3R3 w - - 0 1

Solutions is Qh5 mate but you need to see for 8 pseudo legal king moves and 6 pseudo legal knight moves why they are illegal so I can say the pseudo complexity is 29 because you need to calculate 29 possible positions to prove Qh5 is mate.

Now the question is what is the maximal pesudo complexity of mates in 1,mate in 2 and longer mate and if there is a tool to calculate it.

You can also decide that you consider only legal moves and not pseudo legal moves and in this case the complexity of mates in 1 is always 1 and the question is only about comlexity of longer mates.

Here is some example of mate in 4

https://www.chesstempo.com/chess-tactics/78057

What is the complexity(not pseudo complexity that I did not care to calculate)
Solution is 1.Rxg6+ and now
a)hxg6 2.Ne7+
aa)2...Kf8 3.Nxg6+
aaa)3...Kh8 4.Qh8#
aab)3...Ke8 4.Qe7#
ab)2...Kh7 3.Qxf7+
aba)3...Kh6 4.Qxg6#
abb)3...Kh8 4.Nxg6#
abc)3...Ng7 4.Qxg7#
b)1...fxg6 2.Ne7#
c)1...Kf8 2.Qh8#
d)1...Ng7 2.Qxg7#

Number of positions in the tree is 23.
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: complexity of mate problems

Post by Ferdy »

This is the mate in 4 posted.

[d]r2r2k1/5p1p/p3nQpP/1p2PN2/2p5/2P3R1/P2q1PP1/4R1K1 w - - 0 1

Calculation

Code: Select all

{'dm': 4}
r2r2k1/5p1p/p3nQpP/1p2PN2/2p5/2P3R1/P2q1PP1/4R1K1 w - - 0 1
Analyzing: r2r2k1/5p1p/p3nQpP/1p2PN2/2p5/2P3R1/P2q1PP1/4R1K1 w - - 0 1
Attacker's best move: g3g6 (Adds 1 to complexity)
  Defender must explore 4 legal move(s):
  - Defender tries: g8f8 (Adds 1 to complexity)
    Analyzing: r2r1k2/5p1p/p3nQRP/1p2PN2/2p5/2P5/P2q1PP1/4R1K1 w - - 1 2
    Attacker plays mating move: f6h8# (Complexity: 1)
  - Defender tries: e6g7 (Adds 1 to complexity)
    Analyzing: r2r2k1/5pnp/p4QRP/1p2PN2/2p5/2P5/P2q1PP1/4R1K1 w - - 1 2
    Attacker plays mating move: f6g7# (Complexity: 1)
  - Defender tries: h7g6 (Adds 1 to complexity)
    Analyzing: r2r2k1/5p2/p3nQpP/1p2PN2/2p5/2P5/P2q1PP1/4R1K1 w - - 0 2
    Attacker's best move: f5e7 (Adds 1 to complexity)
      Defender must explore 2 legal move(s):
      - Defender tries: g8f8 (Adds 1 to complexity)
        Analyzing: r2r1k2/4Np2/p3nQpP/1p2P3/2p5/2P5/P2q1PP1/4R1K1 w - - 2 3
        Attacker's best move: e7g6 (Adds 1 to complexity)
          Defender must explore 2 legal move(s):
          - Defender tries: f8g8 (Adds 1 to complexity)
            Analyzing: r2r2k1/5p2/p3nQNP/1p2P3/2p5/2P5/P2q1PP1/4R1K1 w - - 1 4
            Attacker plays mating move: f6h8# (Complexity: 1)
          - Defender tries: f8e8 (Adds 1 to complexity)
            Analyzing: r2rk3/5p2/p3nQNP/1p2P3/2p5/2P5/P2q1PP1/4R1K1 w - - 1 4
            Attacker plays mating move: f6e7# (Complexity: 1)
      - Defender tries: g8h7 (Adds 1 to complexity)
        Analyzing: r2r4/4Np1k/p3nQpP/1p2P3/2p5/2P5/P2q1PP1/4R1K1 w - - 2 3
        Attacker's best move: f6f7 (Adds 1 to complexity)
          Defender must explore 3 legal move(s):
          - Defender tries: h7h8 (Adds 1 to complexity)
            Analyzing: r2r3k/4NQ2/p3n1pP/1p2P3/2p5/2P5/P2q1PP1/4R1K1 w - - 1 4
            Attacker plays mating move: e7g6# (Complexity: 1)
          - Defender tries: h7h6 (Adds 1 to complexity)
            Analyzing: r2r4/4NQ2/p3n1pk/1p2P3/2p5/2P5/P2q1PP1/4R1K1 w - - 0 4
            Attacker plays mating move: f7g6# (Complexity: 1)
          - Defender tries: e6g7 (Adds 1 to complexity)
            Analyzing: r2r4/4NQnk/p5pP/1p2P3/2p5/2P5/P2q1PP1/4R1K1 w - - 1 4
            Attacker plays mating move: f7g7# (Complexity: 1)
  - Defender tries: f7g6 (Adds 1 to complexity)
    Analyzing: r2r2k1/7p/p3nQpP/1p2PN2/2p5/2P5/P2q1PP1/4R1K1 w - - 0 2
    Attacker plays mating move: f5e7# (Complexity: 1)
Calculated Mate Complexity: 23
This mate in 3 has a high number.

[d]2rB4/1b1n1pp1/pn4Rp/1Q2NB2/2pK1k1r/3RN1pr/4P3/8 w - - 0 1

Code: Select all

{'dm': 3}
2rB4/1b1n1pp1/pn4Rp/1Q2NB2/2pK1k1r/3RN1pr/4P3/8 w - - 0 1
Analyzing: 2rB4/1b1n1pp1/pn4Rp/1Q2NB2/2pK1k1r/3RN1pr/4P3/8 w - - 0 1
Attacker's best move: f5h3 (Adds 1 to complexity)
  Defender must explore 33 legal move(s):
  - Defender tries: c8d8 (Adds 1 to complexity)
    Analyzing: 3r4/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 0 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 3r4/3n1pp1/pn4Rp/1Q2N3/2pK1k1r/3R2pB/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: c8b8 (Adds 1 to complexity)
    Analyzing: 1r1B4/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: d8h4 (Adds 1 to complexity)
      Defender must explore 32 legal move(s):
      - Defender tries: b8h8 (Adds 1 to complexity)
        Analyzing: 7r/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b8g8 (Adds 1 to complexity)
        Analyzing: 6r1/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b8f8 (Adds 1 to complexity)
        Analyzing: 5r2/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b8e8 (Adds 1 to complexity)
        Analyzing: 4r3/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b8d8 (Adds 1 to complexity)
        Analyzing: 3r4/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b8c8 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b8a8 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f8 (Adds 1 to complexity)
        Analyzing: 1r3n2/1b3pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f6 (Adds 1 to complexity)
        Analyzing: 1r6/1b3pp1/pn3nRp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7e5 (Adds 1 to complexity)
        Analyzing: 1r6/1b3pp1/pn4Rp/1Q2n3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: b5e5# (Complexity: 1)
      - Defender tries: d7c5 (Adds 1 to complexity)
        Analyzing: 1r6/1b3pp1/pn4Rp/1Qn1N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7c8 (Adds 1 to complexity)
        Analyzing: 1rb5/3n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7a8 (Adds 1 to complexity)
        Analyzing: br6/3n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7c6 (Adds 1 to complexity)
        Analyzing: 1r6/3n1pp1/pnb3Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7d5 (Adds 1 to complexity)
        Analyzing: 1r6/3n1pp1/pn4Rp/1Q1bN3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7e4 (Adds 1 to complexity)
        Analyzing: 1r6/3n1pp1/pn4Rp/1Q2N3/2pKbk1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7f3 (Adds 1 to complexity)
        Analyzing: 1r6/3n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RNbpB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 1r6/3n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P1b1/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7h1 (Adds 1 to complexity)
        Analyzing: 1r6/3n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/7b w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6c8 (Adds 1 to complexity)
        Analyzing: 1rn5/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6a8 (Adds 1 to complexity)
        Analyzing: nr6/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6d5 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/p5Rp/1Q1nN3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6a4 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: f7g6 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n2p1/pn4pp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5g6# (Complexity: 1)
      - Defender tries: a6b5 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/1n4Rp/1p2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: c4d3 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/pn4Rp/1Q2N3/3K1k1B/3pN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5d3# (Complexity: 1)
      - Defender tries: f7f6 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n2p1/pn3pRp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: h6h5 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/pn4R1/1Q2N2p/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g5# (Complexity: 1)
      - Defender tries: a6a5 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: c4c3 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/pn4Rp/1Q2N3/3K1k1B/2pRN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: g3g2 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN2B/4P1p1/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: f7f5 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g3# (Complexity: 1)
  - Defender tries: c8a8 (Adds 1 to complexity)
    Analyzing: r2B4/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: d8h4 (Adds 1 to complexity)
      Defender must explore 32 legal move(s):
      - Defender tries: a8h8 (Adds 1 to complexity)
      - Defender tries: a8g8 (Adds 1 to complexity)
      - Defender tries: a8f8 (Adds 1 to complexity)
      - Defender tries: a8e8 (Adds 1 to complexity)
      - Defender tries: a8d8 (Adds 1 to complexity)
      - Defender tries: a8c8 (Adds 1 to complexity)
      - Defender tries: a8b8 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: a8a7 (Adds 1 to complexity)
        Analyzing: 8/rb1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f8 (Adds 1 to complexity)
        Analyzing: r4n2/1b3pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7b8 (Adds 1 to complexity)
        Analyzing: rn6/1b3pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f6 (Adds 1 to complexity)
        Analyzing: r7/1b3pp1/pn3nRp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7e5 (Adds 1 to complexity)
        Analyzing: r7/1b3pp1/pn4Rp/1Q2n3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: b5e5# (Complexity: 1)
      - Defender tries: d7c5 (Adds 1 to complexity)
        Analyzing: r7/1b3pp1/pn4Rp/1Qn1N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7c8 (Adds 1 to complexity)
        Analyzing: r1b5/3n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7c6 (Adds 1 to complexity)
        Analyzing: r7/3n1pp1/pnb3Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7d5 (Adds 1 to complexity)
        Analyzing: r7/3n1pp1/pn4Rp/1Q1bN3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7e4 (Adds 1 to complexity)
        Analyzing: r7/3n1pp1/pn4Rp/1Q2N3/2pKbk1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7f3 (Adds 1 to complexity)
        Analyzing: r7/3n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RNbpB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: r7/3n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P1b1/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7h1 (Adds 1 to complexity)
        Analyzing: r7/3n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/7b w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6c8 (Adds 1 to complexity)
        Analyzing: r1n5/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6d5 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/p5Rp/1Q1nN3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6a4 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: f7g6 (Adds 1 to complexity)
        Analyzing: r7/1b1n2p1/pn4pp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5g6# (Complexity: 1)
      - Defender tries: a6b5 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/1n4Rp/1p2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: c4d3 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/pn4Rp/1Q2N3/3K1k1B/3pN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5d3# (Complexity: 1)
      - Defender tries: f7f6 (Adds 1 to complexity)
        Analyzing: r7/1b1n2p1/pn3pRp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: h6h5 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/pn4R1/1Q2N2p/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g5# (Complexity: 1)
      - Defender tries: a6a5 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: c4c3 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/pn4Rp/1Q2N3/3K1k1B/2pRN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: g3g2 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1B/3RN2B/4P1p1/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: f7f5 (Adds 1 to complexity)
        Analyzing: r7/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g3# (Complexity: 1)
  - Defender tries: c8c7 (Adds 1 to complexity)
    Analyzing: 3B4/1brn1pp1/pn4Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 3B4/2rn1pp1/pn4Rp/1Q2N3/2pK1k1r/3R2pB/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: c8c6 (Adds 1 to complexity)
    Analyzing: 3B4/1b1n1pp1/pnr3Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker plays mating move: e3g2# (Complexity: 1)
  - Defender tries: c8c5 (Adds 1 to complexity)
    Analyzing: 3B4/1b1n1pp1/pn4Rp/1Qr1N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 3B4/3n1pp1/pn4Rp/1Qr1N3/2pK1k1r/3R2pB/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: d7f8 (Adds 1 to complexity)
    Analyzing: 2rB1n2/1b3pp1/pn4Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 2rB1n2/5pp1/pn4Rp/1Q2N3/2pK1k1r/3R2pB/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: d7b8 (Adds 1 to complexity)
    Analyzing: 1nrB4/1b3pp1/pn4Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 1nrB4/5pp1/pn4Rp/1Q2N3/2pK1k1r/3R2pB/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: d7f6 (Adds 1 to complexity)
    Analyzing: 2rB4/1b3pp1/pn3nRp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 2rB4/5pp1/pn3nRp/1Q2N3/2pK1k1r/3R2pB/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: d7e5 (Adds 1 to complexity)
    Analyzing: 2rB4/1b3pp1/pn4Rp/1Q2n3/2pK1k1r/3RN1pB/4P3/8 w - - 0 2
    Attacker plays mating move: b5e5# (Complexity: 1)
  - Defender tries: d7c5 (Adds 1 to complexity)
    Analyzing: 2rB4/1b3pp1/pn4Rp/1Qn1N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 2rB4/5pp1/pn4Rp/1Qn1N3/2pK1k1r/3R2pB/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: b7a8 (Adds 1 to complexity)
    Analyzing: b1rB4/3n1pp1/pn4Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: a8g2 (Adds 1 to complexity)
        Analyzing: 2rB4/3n1pp1/pn4Rp/1Q2N3/2pK1k1r/3R2pB/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: b7c6 (Adds 1 to complexity)
    Analyzing: 2rB4/3n1pp1/pnb3Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: c6g2 (Adds 1 to complexity)
  - Defender tries: b7d5 (Adds 1 to complexity)
    Analyzing: 2rB4/3n1pp1/pn4Rp/1Q1bN3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: d5g2 (Adds 1 to complexity)
  - Defender tries: b7e4 (Adds 1 to complexity)
    Analyzing: 2rB4/3n1pp1/pn4Rp/1Q2N3/2pKbk1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: e4g2 (Adds 1 to complexity)
  - Defender tries: b7f3 (Adds 1 to complexity)
    Analyzing: 2rB4/3n1pp1/pn4Rp/1Q2N3/2pK1k1r/3RNbpB/4P3/8 w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: f3g2 (Adds 1 to complexity)
  - Defender tries: b7g2 (Adds 1 to complexity)
    Analyzing: 2rB4/3n1pp1/pn4Rp/1Q2N3/2pK1k1r/3RN1pB/4P1b1/8 w - - 1 2
    Attacker plays mating move: e3g2# (Complexity: 1)
  - Defender tries: b7h1 (Adds 1 to complexity)
    Analyzing: 2rB4/3n1pp1/pn4Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/7b w - - 1 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: h1g2 (Adds 1 to complexity)
  - Defender tries: b6a8 (Adds 1 to complexity)
    Analyzing: n1rB4/1b1n1pp1/p5Rp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: d8h4 (Adds 1 to complexity)
      Defender must explore 32 legal move(s):
      - Defender tries: c8h8 (Adds 1 to complexity)
        Analyzing: n6r/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8g8 (Adds 1 to complexity)
        Analyzing: n5r1/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8f8 (Adds 1 to complexity)
        Analyzing: n4r2/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8e8 (Adds 1 to complexity)
        Analyzing: n3r3/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8d8 (Adds 1 to complexity)
        Analyzing: n2r4/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8b8 (Adds 1 to complexity)
      - Defender tries: c8c7 (Adds 1 to complexity)
        Analyzing: n7/1brn1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c6 (Adds 1 to complexity)
        Analyzing: n7/1b1n1pp1/p1r3Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c5 (Adds 1 to complexity)
        Analyzing: n7/1b1n1pp1/p5Rp/1Qr1N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: a8c7 (Adds 1 to complexity)
        Analyzing: 2r5/1bnn1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: a8b6 (Adds 1 to complexity)
      - Defender tries: d7f8 (Adds 1 to complexity)
        Analyzing: n1r2n2/1b3pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7b8 (Adds 1 to complexity)
        Analyzing: nnr5/1b3pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f6 (Adds 1 to complexity)
        Analyzing: n1r5/1b3pp1/p4nRp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7b6 (Adds 1 to complexity)
        Analyzing: n1r5/1b3pp1/pn4Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7e5 (Adds 1 to complexity)
        Analyzing: n1r5/1b3pp1/p5Rp/1Q2n3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: b5e5# (Complexity: 1)
      - Defender tries: d7c5 (Adds 1 to complexity)
        Analyzing: n1r5/1b3pp1/p5Rp/1Qn1N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7c6 (Adds 1 to complexity)
        Analyzing: n1r5/3n1pp1/p1b3Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7d5 (Adds 1 to complexity)
        Analyzing: n1r5/3n1pp1/p5Rp/1Q1bN3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: e3d5# (Complexity: 1)
      - Defender tries: b7e4 (Adds 1 to complexity)
        Analyzing: n1r5/3n1pp1/p5Rp/1Q2N3/2pKbk1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7f3 (Adds 1 to complexity)
        Analyzing: n1r5/3n1pp1/p5Rp/1Q2N3/2pK1k1B/3RNbpB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: n1r5/3n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P1b1/8 w - - 1 3
        Attacker plays mating move: e3g2# (Complexity: 1)
      - Defender tries: b7h1 (Adds 1 to complexity)
        Analyzing: n1r5/3n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/4P3/7b w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: f7g6 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n2p1/p5pp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5g6# (Complexity: 1)
      - Defender tries: a6b5 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n1pp1/6Rp/1p2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: c4d3 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n1pp1/p5Rp/1Q2N3/3K1k1B/3pN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5d3# (Complexity: 1)
      - Defender tries: f7f6 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n2p1/p4pRp/1Q2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: h6h5 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n1pp1/p5R1/1Q2N2p/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g5# (Complexity: 1)
      - Defender tries: a6a5 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n1pp1/6Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: c4c3 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n1pp1/p5Rp/1Q2N3/3K1k1B/2pRN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: g3g2 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN2B/4P1p1/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: f7f5 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n2p1/p5Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g3# (Complexity: 1)
  - Defender tries: b6d5 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/p5Rp/1Q1nN3/2pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker plays mating move: e3g2# (Complexity: 1)
  - Defender tries: b6a4 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/p5Rp/1Q2N3/n1pK1k1r/3RN1pB/4P3/8 w - - 1 2
    Attacker's best move: d8h4 (Adds 1 to complexity)
      Defender must explore 36 legal move(s):
      - Defender tries: c8h8 (Adds 1 to complexity)
        Analyzing: 7r/1b1n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8g8 (Adds 1 to complexity)
        Analyzing: 6r1/1b1n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8f8 (Adds 1 to complexity)
        Analyzing: 5r2/1b1n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8e8 (Adds 1 to complexity)
        Analyzing: 4r3/1b1n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8d8 (Adds 1 to complexity)
        Analyzing: 3r4/1b1n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8b8 (Adds 1 to complexity)
      - Defender tries: c8a8 (Adds 1 to complexity)
      - Defender tries: c8c7 (Adds 1 to complexity)
        Analyzing: 8/1brn1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c6 (Adds 1 to complexity)
        Analyzing: 8/1b1n1pp1/p1r3Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c5 (Adds 1 to complexity)
        Analyzing: 8/1b1n1pp1/p5Rp/1Qr1N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f8 (Adds 1 to complexity)
        Analyzing: 2r2n2/1b3pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7b8 (Adds 1 to complexity)
        Analyzing: 1nr5/1b3pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f6 (Adds 1 to complexity)
        Analyzing: 2r5/1b3pp1/p4nRp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7b6 (Adds 1 to complexity)
        Analyzing: 2r5/1b3pp1/pn4Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7e5 (Adds 1 to complexity)
        Analyzing: 2r5/1b3pp1/p5Rp/1Q2n3/n1pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: b5e5# (Complexity: 1)
      - Defender tries: d7c5 (Adds 1 to complexity)
        Analyzing: 2r5/1b3pp1/p5Rp/1Qn1N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7a8 (Adds 1 to complexity)
        Analyzing: b1r5/3n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7c6 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/p1b3Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7d5 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/p5Rp/1Q1bN3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: e3d5# (Complexity: 1)
      - Defender tries: b7e4 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/p5Rp/1Q2N3/n1pKbk1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7f3 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RNbpB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P1b1/8 w - - 1 3
        Attacker plays mating move: e3g2# (Complexity: 1)
      - Defender tries: b7h1 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN1pB/4P3/7b w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: a4b6 (Adds 1 to complexity)
      - Defender tries: a4c5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/p5Rp/1Qn1N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: a4c3 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/2nRN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: a4b2 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/p5Rp/1Q2N3/2pK1k1B/3RN1pB/1n2P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: f7g6 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/p5pp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5g6# (Complexity: 1)
      - Defender tries: a6b5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/6Rp/1p2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: c4d3 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/p5Rp/1Q2N3/n2K1k1B/3pN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5d3# (Complexity: 1)
      - Defender tries: f7f6 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/p4pRp/1Q2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: h6h5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/p5R1/1Q2N2p/n1pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g5# (Complexity: 1)
      - Defender tries: a6a5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/6Rp/pQ2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: c4c3 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/p5Rp/1Q2N3/n2K1k1B/2pRN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: g3g2 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/p5Rp/1Q2N3/n1pK1k1B/3RN2B/4P1p1/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: f7f5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/p5Rp/1Q2Np2/n1pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g3# (Complexity: 1)
  - Defender tries: h4h5 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/pn4Rp/1Q2N2r/2pK1k2/3RN1pB/4P3/8 w - - 1 2
    Attacker plays mating move: g6g4# (Complexity: 1)
  - Defender tries: h4g4 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/pn4Rp/1Q2N3/2pK1kr1/3RN1pB/4P3/8 w - - 1 2
    Attacker plays mating move: g6g4# (Complexity: 1)
  - Defender tries: h4h3 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/pn4Rp/1Q2N3/2pK1k2/3RN1pr/4P3/8 w - - 0 2
    Attacker plays mating move: g6g4# (Complexity: 1)
  - Defender tries: f7g6 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n2p1/pn4pp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 0 2
    Attacker plays mating move: e5g6# (Complexity: 1)
  - Defender tries: a6b5 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/1n4Rp/1p2N3/2pK1k1r/3RN1pB/4P3/8 w - - 0 2
    Attacker's best move: e3d5 (Adds 1 to complexity)
      Defender must explore 2 legal move(s):
      - Defender tries: b7d5 (Adds 1 to complexity)
        Analyzing: 2rB4/3n1pp1/1n4Rp/1p1bN3/2pK1k1r/3R2pB/4P3/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
      - Defender tries: b6d5 (Adds 1 to complexity)
        Analyzing: 2rB4/1b1n1pp1/6Rp/1p1nN3/2pK1k1r/3R2pB/4P3/8 w - - 0 3
        Attacker plays mating move: d3f3# (Complexity: 1)
  - Defender tries: c4d3 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/pn4Rp/1Q2N3/3K1k1r/3pN1pB/4P3/8 w - - 0 2
    Attacker plays mating move: e5d3# (Complexity: 1)
  - Defender tries: f7f6 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n2p1/pn3pRp/1Q2N3/2pK1k1r/3RN1pB/4P3/8 w - - 0 2
    Attacker's best move: e3d5 (Adds 1 to complexity)
      Defender must explore 2 legal move(s):
      - Defender tries: b7d5 (Adds 1 to complexity)
        Analyzing: 2rB4/3n2p1/pn3pRp/1Q1bN3/2pK1k1r/3R2pB/4P3/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
      - Defender tries: b6d5 (Adds 1 to complexity)
        Analyzing: 2rB4/1b1n2p1/p4pRp/1Q1nN3/2pK1k1r/3R2pB/4P3/8 w - - 0 3
        Attacker plays mating move: d3f3# (Complexity: 1)
  - Defender tries: h6h5 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/pn4R1/1Q2N2p/2pK1k1r/3RN1pB/4P3/8 w - - 0 2
    Attacker plays mating move: d8g5# (Complexity: 1)
  - Defender tries: a6a5 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1r/3RN1pB/4P3/8 w - - 0 2
    Attacker's best move: d8h4 (Adds 1 to complexity)
      Defender must explore 34 legal move(s):
      - Defender tries: c8h8 (Adds 1 to complexity)
        Analyzing: 7r/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8g8 (Adds 1 to complexity)
        Analyzing: 6r1/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8f8 (Adds 1 to complexity)
        Analyzing: 5r2/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8e8 (Adds 1 to complexity)
        Analyzing: 4r3/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8d8 (Adds 1 to complexity)
        Analyzing: 3r4/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8b8 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8a8 (Adds 1 to complexity)
        Analyzing: r7/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c7 (Adds 1 to complexity)
        Analyzing: 8/1brn1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c6 (Adds 1 to complexity)
        Analyzing: 8/1b1n1pp1/1nr3Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c5 (Adds 1 to complexity)
        Analyzing: 8/1b1n1pp1/1n4Rp/pQr1N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f8 (Adds 1 to complexity)
        Analyzing: 2r2n2/1b3pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7b8 (Adds 1 to complexity)
        Analyzing: 1nr5/1b3pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f6 (Adds 1 to complexity)
        Analyzing: 2r5/1b3pp1/1n3nRp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7e5 (Adds 1 to complexity)
        Analyzing: 2r5/1b3pp1/1n4Rp/pQ2n3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: b5e5# (Complexity: 1)
      - Defender tries: d7c5 (Adds 1 to complexity)
        Analyzing: 2r5/1b3pp1/1n4Rp/pQn1N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7a8 (Adds 1 to complexity)
        Analyzing: b1r5/3n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7c6 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/1nb3Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7a6 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/bn4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7d5 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/1n4Rp/pQ1bN3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7e4 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/1n4Rp/pQ2N3/2pKbk1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b7f3 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RNbpB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P1b1/8 w - - 1 3
        Attacker plays mating move: e3g2# (Complexity: 1)
      - Defender tries: b7h1 (Adds 1 to complexity)
        Analyzing: 2r5/3n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/7b w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b6a8 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n1pp1/6Rp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b6d5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/6Rp/pQ1nN3/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: b6a4 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/6Rp/pQ2N3/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: f7g6 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/1n4pp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5g6# (Complexity: 1)
      - Defender tries: c4d3 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/1n4Rp/pQ2N3/3K1k1B/3pN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5d3# (Complexity: 1)
      - Defender tries: f7f6 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/1n3pRp/pQ2N3/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: h6h5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/1n4R1/pQ2N2p/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g5# (Complexity: 1)
      - Defender tries: a5a4 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/1n4Rp/1Q2N3/p1pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: c4c3 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/1n4Rp/pQ2N3/3K1k1B/2pRN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: g3g2 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n1pp1/1n4Rp/pQ2N3/2pK1k1B/3RN2B/4P1p1/8 w - - 0 3
        Attacker plays mating move: g6g4# (Complexity: 1)
      - Defender tries: f7f5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/1n4Rp/pQ2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g3# (Complexity: 1)
  - Defender tries: c4c3 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/pn4Rp/1Q2N3/3K1k1r/2pRN1pB/4P3/8 w - - 0 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 2rB4/3n1pp1/pn4Rp/1Q2N3/3K1k1r/2pR2pB/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: g3g2 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n1pp1/pn4Rp/1Q2N3/2pK1k1r/3RN2B/4P1p1/8 w - - 0 2
    Attacker's best move: e3g2 (Adds 1 to complexity)
      Defender must explore 1 legal move(s):
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 2rB4/3n1pp1/pn4Rp/1Q2N3/2pK1k1r/3R3B/4P1b1/8 w - - 0 3
        Attacker plays mating move: e2e3# (Complexity: 1)
  - Defender tries: f7f5 (Adds 1 to complexity)
    Analyzing: 2rB4/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1r/3RN1pB/4P3/8 w - - 0 2
    Attacker's best move: d8h4 (Adds 1 to complexity)
      Defender must explore 31 legal move(s):
      - Defender tries: c8h8 (Adds 1 to complexity)
        Analyzing: 7r/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8g8 (Adds 1 to complexity)
        Analyzing: 6r1/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8f8 (Adds 1 to complexity)
        Analyzing: 5r2/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8e8 (Adds 1 to complexity)
        Analyzing: 4r3/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8d8 (Adds 1 to complexity)
        Analyzing: 3r4/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8b8 (Adds 1 to complexity)
        Analyzing: 1r6/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8a8 (Adds 1 to complexity)
        Analyzing: r7/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c7 (Adds 1 to complexity)
        Analyzing: 8/1brn2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c6 (Adds 1 to complexity)
        Analyzing: 8/1b1n2p1/pnr3Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c8c5 (Adds 1 to complexity)
        Analyzing: 8/1b1n2p1/pn4Rp/1Qr1Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f8 (Adds 1 to complexity)
        Analyzing: 2r2n2/1b4p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7b8 (Adds 1 to complexity)
        Analyzing: 1nr5/1b4p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7f6 (Adds 1 to complexity)
        Analyzing: 2r5/1b4p1/pn3nRp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: d7e5 (Adds 1 to complexity)
        Analyzing: 2r5/1b4p1/pn4Rp/1Q2np2/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: b5e5# (Complexity: 1)
      - Defender tries: d7c5 (Adds 1 to complexity)
        Analyzing: 2r5/1b4p1/pn4Rp/1Qn1Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7a8 (Adds 1 to complexity)
        Analyzing: b1r5/3n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7c6 (Adds 1 to complexity)
        Analyzing: 2r5/3n2p1/pnb3Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7d5 (Adds 1 to complexity)
        Analyzing: 2r5/3n2p1/pn4Rp/1Q1bNp2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7e4 (Adds 1 to complexity)
        Analyzing: 2r5/3n2p1/pn4Rp/1Q2Np2/2pKbk1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7f3 (Adds 1 to complexity)
        Analyzing: 2r5/3n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RNbpB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b7g2 (Adds 1 to complexity)
        Analyzing: 2r5/3n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P1b1/8 w - - 1 3
        Attacker plays mating move: e3g2# (Complexity: 1)
      - Defender tries: b7h1 (Adds 1 to complexity)
        Analyzing: 2r5/3n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/7b w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6a8 (Adds 1 to complexity)
        Analyzing: n1r5/1b1n2p1/p5Rp/1Q2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6d5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/p5Rp/1Q1nNp2/2pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: b6a4 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/p5Rp/1Q2Np2/n1pK1k1B/3RN1pB/4P3/8 w - - 1 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: a6b5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/1n4Rp/1p2Np2/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: c4d3 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/pn4Rp/1Q2Np2/3K1k1B/3pN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: e5d3# (Complexity: 1)
      - Defender tries: h6h5 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/pn4R1/1Q2Np1p/2pK1k1B/3RN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g5# (Complexity: 1)
      - Defender tries: a6a5 (Adds 1 to complexity)
      - Defender tries: c4c3 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/pn4Rp/1Q2Np2/3K1k1B/2pRN1pB/4P3/8 w - - 0 3
        Attacker plays mating move: h4g3# (Complexity: 1)
      - Defender tries: g3g2 (Adds 1 to complexity)
        Analyzing: 2r5/1b1n2p1/pn4Rp/1Q2Np2/2pK1k1B/3RN2B/4P1p1/8 w - - 0 3
        Attacker plays mating move: h4g3# (Complexity: 1)
Calculated Mate Complexity: 499
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: complexity of mate problems

Post by Ferdy »

Here is the python code, it is generated with the assistance of Gemini 2.5 Pro.

Code: Select all

import sys

import chess
import chess.engine


STOCKFISH_PATH = "sf17.exe"
TEST_POS = [
    "r2r2k1/5p1p/p3nQpP/1p2PN2/2p5/2P3R1/P2q1PP1/4R1K1 w - - dm 4",  # c=23
    "1N3B2/5p2/2R2p2/1p1kpp2/1P2rp2/2P1pB2/2P1P1K1/8 w - - dm 3",
    "2k5/2N5/1PKP4/2P5/8/8/8/8 w - - dm 3",
    "2q5/4B2p/7n/4p1pk/P2n1b2/R3P2P/2r3P1/1Q3R1K b - - dm 3",
    "2rB4/1b1n1pp1/pn4Rp/1Q2NB2/2pK1k1r/3RN1pr/4P3/8 w - - dm 3",
    "8/4p3/7R/n7/rp6/kp5Q/8/1K6 w - - dm 3",
    "7r/8/8/8/8/6p1/6PP/5kBK b - - dm 2",
    "1k6/8/1K6/8/8/3Q4/8/8 w - - dm 1",
]


def calculate_mate_complexity_with_engine(fen, max_depth=1000, engine_time_limit=3.0, verbose=False):
    board = chess.Board(fen)
    if board.is_checkmate():
        if verbose: print("Position is already checkmate.")
        return 0

    memo = {}
    engine = None
    try:
        engine = chess.engine.SimpleEngine.popen_uci(STOCKFISH_PATH)

        def find_mate_path_engine(current_board, depth, indent=""):
            board_fen = current_board.fen()
            if (board_fen, depth) in memo:
                return memo[(board_fen, depth)]

            if depth == 0:
                return False, 0
            
            # If the current position is checkmate, the path ends.
            # The move that led here was the final one.
            if current_board.is_checkmate():
                return True, 0

            # --- Attacker's turn (using engine) ---
            if verbose: print(f"{indent}Analyzing: {current_board.fen()}")
            analysis_result = engine.analyse(current_board, chess.engine.Limit(time=engine_time_limit))
            
            score = analysis_result.get("score")
            if not score or not score.is_mate():
                if verbose: print(f"{indent}Engine finds no forced mate from this position.")
                return False, 0
            
            # If the engine sees a mate in 1, the complexity from this point is 1 move.
            pov_score = score.pov(current_board.turn)
            if pov_score.mate() == 1:
                best_move = analysis_result['pv'][0]
                if verbose: print(f"{indent}Attacker plays mating move: {best_move.uci()}# (Complexity: 1)")
                memo[(board_fen, depth)] = (True, 1)
                return True, 1

            if 'pv' not in analysis_result or not analysis_result['pv']:
                return False, 0
            
            best_move = analysis_result['pv'][0]
            if verbose: print(f"{indent}Attacker's best move: {best_move.uci()} (Adds 1 to complexity)")
            
            temp_board = current_board.copy()
            temp_board.push(best_move)

            # --- Defender's turn ---
            is_mate_forced = True
            total_defender_path_complexity = 0
            
            if temp_board.is_stalemate():
                is_mate_forced = False
            elif not temp_board.legal_moves:
                is_mate_forced = temp_board.is_checkmate()
            else:
                if verbose: print(f"{indent}  Defender must explore {len(list(temp_board.legal_moves))} legal move(s):")
                for defender_move in temp_board.legal_moves:
                    if verbose: print(f"{indent}  - Defender tries: {defender_move.uci()} (Adds 1 to complexity)")
                    defender_board = temp_board.copy()
                    defender_board.push(defender_move)
                    
                    mate_possible, sub_complexity = find_mate_path_engine(defender_board, depth - 1, indent + "    ")
                    
                    if not mate_possible:
                        is_mate_forced = False
                        break
                    
                    # The complexity for this branch is the defender's move (1) + all subsequent moves.
                    total_defender_path_complexity += (1 + sub_complexity)
            
            if is_mate_forced:
                # The total complexity is the attacker's move (1) + the sum of all defender branches.
                result = (True, 1 + total_defender_path_complexity)
            else:
                result = (False, 0)
            
            memo[(board_fen, depth)] = result
            return result

        is_mate, complexity = find_mate_path_engine(board, max_depth)
        
        if is_mate:
            return complexity
        else:
            print(f"Engine did not find a forced mate within a depth of {max_depth}.", file=sys.stderr)
            return -1

    except (FileNotFoundError, chess.engine.EngineError) as e:
        print(f"Error initializing or using the chess engine: {e}", file=sys.stderr)
        print("Please ensure STOCKFISH_PATH is correct and the engine is functional.", file=sys.stderr)
        return -1
    finally:
        if engine:
            engine.quit()


if __name__ == '__main__':
    for i, epd in enumerate(TEST_POS):
        print(f'Mate pos {i+1}')
        board = chess.Board()
        op_codes = board.set_epd(epd)
        print(op_codes)
        fen = board.fen()
        print(fen)
        complexity = calculate_mate_complexity_with_engine(fen, engine_time_limit=10.0, verbose=True)
        print(f"Calculated Mate Complexity: {complexity}\n")