5

A winning position is called critical, if all moves - except one - draw or lose (assuming the opponent plays perfectly). Similarly, a drawn chess position is called critical, if all moves - except one - lose.

Consider this critical endgame position as an example.

[FEN "8/8/1B6/6P1/1b6/8/2K4k/8 w - - 0 1"]

The only winning move is 1. Ba5!! while every other move draws.

Using endgame tables it is possible to determine if a given position is critical. However, I am interested in a database with all critical endgames. Does such database exist? If not, how could I create one myself?

3 Answers 3

2

Partly building on ferdy's answer (and the comments to it). In Python this can be done as follows:

  1. Using the python-chess module, iterate through the games in your database. Docs: https://python-chess.readthedocs.io/en/latest/pgn.html

    https://python-chess.readthedocs.io/en/latest/core.html#board

  2. Now you could use tablebases, but another option is to use Stockfish. Download the Stockfish engine, and then use the stockfish python module: https://pypi.org/project/stockfish/

    For each position in a game, get its FEN (using python-chess), and then set the stockfish module object's position to it (using the set_fen_position method). Finally, call get_top_moves(2) with the stockfish object.

Then, a position can be deemed critical if:

a) The top move is winning (e.g., >= +4 or <= -4, for White's and Black's perspectives).

b) The second top move is under an evaluation that's winning (e.g., <= +0.5 (White isn't winning) or >= -0.5 (Black isn't winning)).

OR

a) The top move is at least around equal (e.g., >= -0.5 (White is at least close to equal) or <= +0.5 (Black is at least close to equal)).

b) The second top move is losing (e.g., <= -4 (White is losing) or >= +4 (Black is losing)).

3

Here is a typical procedure to save critical positions.

  • For the given material configuration like kbpkb ... generate positions and save to FEN. To generate positions you can use python-chess library for example.
  • Analyze the FEN with ending tablebase and save it if critical.
6
  • There are many endgame positions for a given material configuration. I am interested in a systematic and efficient way to find all of them. Commented Apr 3, 2022 at 18:05
  • 2
    Python-chess can be systematic and efficient.
    – ferdy
    Commented Apr 4, 2022 at 6:16
  • Late to the party but python-chess.readthedocs.io/en/latest/pgn.html is the documentation for parsing pgns with python-chess. Commented Aug 31, 2022 at 1:34
  • That is more than that, for example if you check the board module it can do many things.
    – ferdy
    Commented Aug 31, 2022 at 2:56
  • Yup, a board can be created for the starting positoin in a given game: first_game = chess.pgn.read_game(pgn) board = first_game.board(). And then the board can be updated by iterating through first_game's .mainline_moves(), and sending each move as an argument in calls to the board's push member function. Docs go over this more clearly. Commented Aug 31, 2022 at 7:40
2

As posed, I think this is more of a “data structures and algorithms” question. I don’t think the chess content can be leveraged, except there are existing tables which can be mined.

In compositions, it’s not just a single critical position which is interesting - rather it’s a chain of critical positions where with “best play by Black”, there is at least one chain of mostly unique White moves that lead to a “clearly won/drawn” position.

If this line of thinking interests you, then there is definitely chess content, and there is also a clear retroanalytic approach to efficiently determine a sequence of critical positions.

In this case it may well be worth constructing your own tablebase to allow you to explore the possibilities, particularly the notions of “clearly won” and “best defensive play”.

Hope this helps: good luck!

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.