test positions when all the moves losing except a winning move

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

Moderator: Ras

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

Re: test positions when all the moves losing except a winning move

Post by Uri Blass »

Dann Corbit wrote: Mon Jan 20, 2025 6:03 pm For this position [d]2N5/p4P2/p4RqP/P2krb2/5RNK/2PPB1P1/3P1pP1/4nQ2 b - - I have this pv:
Nf3+ gxf3 Qh5+ Kxh5 Bg6+ Kxg6 Rg5+ Kh7 Rg7+ Kh8 Rh7+ Kg8 Rh8+ Kg7 Rh7+ Kf8 Rh8+ Ke7 Re8+ Kd7 Rd8+ Kc7 Rd7+ Kb8 Rb7+ Ka8 Rb8+ Kxa7 Rb7+ Kxa6 Ra7+ Kb5 Rxa5+ Kb4 Rb5+ Ka3 Rb3+ Ka2 Rb2+ Ka1 Ra2+ Kb1 Rb2+ Kc1 Rb1+ Kc2 Rb2+ Kd1 Rb1+ Ke2 Re1+ Kxf2 Re2+ Kg1 Rg2+
with a score of 32676, but maybe there was a bug, because I only have one mate solution, and usually I have a lot of them (I try different engines on mate problems to see how well they fare at solving).
I will re-examine this one later.
Right now, the electric company is watching me and I am supposed to curtail my electricity usage between 8AM and 10AM.
I am one of the biggest electricity using households in Federal Way, and I get constant requests to know if I want training to reduce my electric power usage.
Good thing I am not running my industrial servers right now. Several of them have 4 power supplies in the server with over 1000 watts per power supply. I imagine my electric meter would be emitting smoke, and whining in agony as it furiously spins.
chest can see easily that there is only one mate solution.
Dann Corbit
Posts: 12721
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: test positions when all the moves losing except a winning move

Post by Dann Corbit »

The sign in my database is inverted.
I got this solution:
2N5/p4P2/p4RqP/P2krb2/5RNK/2PPB1P1/3P1pP1/4nQ2 b - - acd 162/93; acs 962; acn 21661898k; ce -32675; bm Nf3+; pv Nf3+ gxf3 Qh5+ Kxh5 Bg6+ Kxg6 Rg5+ Kh7 Rg7+ Kh8 Rh7+ Kg8 Rh8+ Kg7 Rh7+ Kf8 Rh8+ Ke7 Re8+ Kd7 Rd8+ Kc7 Rd7+ Kb8 Rb7+ Ka8 Rb8+ Kxa7 Rb7+ Kxa6 Ra7+ Kb5 Rxa5+ Kb4 Rb5+ Ka3 Rb3+ Ka2 Rb2+ Ka1 Ra2+ Kb1 Rb2+ Kc1 Rb1+ Kc2 Rb2+ Kd1 Rb1+ Ke2 Re1+ Kxf2 Re2+ Kg1 Rg2+ Kh1 Rg1+ Kh2 Rh1+ Kg2 Rg1+ Kh3 Rxg3+ Kh4 Rh3+ Kg5 Rh5+ Kg6 Rg5+ Kh7 Rg7+ Kh8 Rh7+ Kg8 Rh8+ Kg7 Rh7+ Kg6 Rg7+ Kh5 Rg5+ Kh4 Rh5+ Kg3 Rh3+ Kf2 Rxf3+ Ke2 Rxe3+ Nxe3+ Kc5 R4f5+;
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Dann Corbit
Posts: 12721
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: test positions when all the moves losing except a winning move

Post by Dann Corbit »

Updated archive, now with 111 problems.
1 wrong solution removed.
The rest had alternative moves become non-losing moves upon deeper analysis.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
chesskobra
Posts: 326
Joined: Thu Jul 21, 2022 12:30 am
Full name: Chesskobra

Re: test positions when all the moves losing except a winning move

Post by chesskobra »

Not exactly what Uri Blass asked, but approximate. I looked at the NICE program recently posted by Rebel, and started with the epd files that come with it (more than 78000 positions). Each line has 4 evals by Stockfish 17. I filtered for lines that contains evals =10 =0 =0 =0, which, if I understand correctly, says one move is 10 and all other moves bad. (I did this with a python script generated by ChatGPT (of course). The first file mea-sf17-1.epd of 10k positions gives 1546 such positions. Now remains to be seen how good the positions are (whether difficult/easy for engines/humans). But unlikely to be difficult for engines since the original scores were probably obtained at 1s/move.

Here is the script by ChatGPT. I ran it with python 3.11 on linux. You could change the parameters to filter by other parameters. The script given by ChatGPT just worked on first try.

Code: Select all

import re

# Open the file in read mode
with open("file.txt", "r") as file:
    lines = file.readlines()

# Define the regex pattern to match the sequence "=10 ... =0 ... =0 ... =0"
pattern = r"=10.*?=0.*?=0.*?=0"

# Filter lines that match the pattern
filtered_lines = [line for line in lines if re.search(pattern, line)]

# Save or display the filtered lines
with open("filtered_lines.txt", "w") as output_file:
    output_file.writelines(filtered_lines)

print(f"Filtered lines saved to 'filtered_lines.txt'.")

# Explanation:

#     Regex Pattern:
#         =10.*?=0.*?=0.*?=0:
#             =10: Matches =10.
#             .*?: Matches any characters (non-greedy), including spaces and text, until the next pattern.
#             =0: Matches =0 repeatedly as required.

#     Process:
#         The script reads each line and applies the regex to check if the sequence matches.
#         All matching lines are saved to filtered_lines.txt.

#     Replace "your_file.txt" with the name of your input file.

# If you need further adjustments or want help running this, feel free to ask!

User avatar
Ajedrecista
Posts: 2058
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Test positions when all the moves are losing except a winning move.

Post by Ajedrecista »

Hello:

I bring a position that is easy for engines. Its merit is that comes from a feasible, playable game without major blunders, but with some inaccuracies and fireworks... human chess after all. It comes from the Bellón Gambit of the English Opening:

[pgn][Event ""]
[Site ""]
[White ""]
[Black ""]
[PlyCount "54"]
[Result "*"]

1.c4 e5 2.Nc3 Nf6 3.Nf3 e4 4. Ng5 b5 5.cxb5 d5 6.e3 a6 7.bxa6 Bd6 8.d3 h6 9.Nh3 exd3 10.Bxd3 Bxh3 11.a7 Bxg2 12.axb8=Q Rxb8 13.Rg1 Bh3 14.Rxg7 Bxh2 15.Qf3 Be6 16.Bf5 Qe7 17.Bxe6 Qxe6 18.b3 Ne4 19.Bb2 Ng5 20.Rxg5 hxg5 21.Nxd5 Rh6 22.Nf6+ Ke7 23.Ng4 Rh4 24.Nxh2 Rxh2 25.Rc1 Kf8 26.Rxc7 Rd8 27.Qc6 Qg4 *[/pgn]

[d]3r1k2/2R2p2/2Q5/6p1/6q1/1P2P3/PB3P1r/4K3 w - - 3 28

28.- Rxf7+ is the only drawing move. Then, 28.- ..., Kxf7 is the only drawing move while 28.- ..., Kg8?? loses immediately to 29.- Qg6#. Getting back into the drawish line, 29.- Qf6+ is the only drawing move again, with the same result as before: 29.- ..., Ke8 saves the day while 29.- ..., Kg8?? crumbles to 30.- Qg7#. Getting back into the drawish line, there is an only drawish move again, 30.- Qe5+, with different variations from there.

The root position is a kind of seesaw, with winning and losing variations if one is not careful. It is not probably the kind of position that meets the request of the OP of the thread, but funny enough IMHO to be posted, adding that it can be reached reasonably from the starting position.

Regards from Spain.

Ajedrecista.
User avatar
Ajedrecista
Posts: 2058
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Test positions when all the moves are losing except a winning move.

Post by Ajedrecista »

Hello:

I just remembered that I composed such a position not long ago. Here it is:

WDL contempt of Lc0 is inversely proportional to (drawelo)^2.
Ajedrecista wrote: Fri Apr 05, 2024 10:21 pm[...]

An even funnier position is this one: beware with which queen you capture... win or lose!

[d]3Q2qk/8/4qq1K/7P/7Q/8/8/8 w - - 0 1

a) White wins (perfect play):
Qhxf6+, Qxf6+; Qxf6+, Qg7+; Qxg7#

b) Black wins (white blunders):
Qdxf6+??, Qg7#

c) White wins (back-to-back blunders):
Qdxf6+??, Qxf6+??; Qxf6+, Qg7+; Qxg7#

[...]
Regards from Spain.

Ajedrecista.