user26890: 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?

user8201: 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!

user30545: 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.


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

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

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

26890: <p>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.</p>
<p>Consider this critical endgame position as an example.</p>
<pre><code>[FEN &quot;8/8/1B6/6P1/1b6/8/2K4k/8 w - - 0 1&quot;]
</code></pre>
<p>The only winning move is 1. Ba5!! while every other move draws.</p>
<p>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?</p>
 8201: <p>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.</p>
<p>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.</p>
<p>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.</p>
<p>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”.</p>
<p>Hope this helps: good luck!</p>
 30545: <p>Here is a typical procedure to save critical positions.</p>
<ul>
<li>For the given material configuration like kbpkb ... generate positions and save to FEN. To generate positions you can use python-chess library for example.</li>
<li>Analyze the FEN with ending tablebase and save it if critical.</li>
</ul>
 12873: <p>Partly building on ferdy's answer (and the comments to it). In Python this can be done as follows:</p>
<ol>
<li><p>Using the <code>python-chess</code> module, iterate through the games in your database. Docs:
<a href="https://python-chess.readthedocs.io/en/latest/pgn.html" rel="nofollow noreferrer">https://python-chess.readthedocs.io/en/latest/pgn.html</a></p>
<p><a href="https://python-chess.readthedocs.io/en/latest/core.html#board" rel="nofollow noreferrer">https://python-chess.readthedocs.io/en/latest/core.html#board</a></p>
</li>
<li><p>Now you could use tablebases, but another option is to use Stockfish. Download the Stockfish engine, and then use the <code>stockfish</code> python module:
<a href="https://pypi.org/project/stockfish/" rel="nofollow noreferrer">https://pypi.org/project/stockfish/</a></p>
<p>For each position in a game, get its FEN (using <code>python-chess</code>), and then set the <code>stockfish</code> module object's position to it (using the <code>set_fen_position</code> method). Finally, call <code>get_top_moves(2)</code> with the <code>stockfish</code> object.</p>
</li>
</ol>
<p>Then, a position can be deemed critical if:</p>
<p>a) The top move is winning (e.g., &gt;= +4 or &lt;= -4, for White's and Black's perspectives).</p>
<p>b) The second top move is under an evaluation that's winning (e.g., &lt;= +0.5 (White isn't winning) or &gt;= -0.5 (Black isn't winning)).</p>
<p>OR</p>
<p>a) The top move is at least around equal (e.g., &gt;= -0.5 (White is at least close to equal) or &lt;= +0.5 (Black is at least close to equal)).</p>
<p>b) The second top move is losing (e.g., &lt;= -4 (White is losing) or &gt;= +4 (Black is losing)).</p>
