is there a program available that will take a position as input and output the features in that position such as: bad knight on H3, good bishop on g2, knight outpost on E5, passed pawn on c6, etc. It would be ideal if it took FEN string and operated from the command line?
-
1That would be interesting. Objective things like passed pawns, isolated pawns, etc would be easy to program and are for instance implemented in database programs like scid. However I would imagine that obtaining subjective features like "good bishop" automatically would be very very difficult (or prone to many false positives).– user1583209Mar 18, 2017 at 1:03
1 Answer
It's possible (statically) but you may need to do some works. Let's take a look at Stockfish.
In the terminal, start Stockfish and type eval
.
Stockfish knows about your passed pawns, king safety, good knights etc. Your job is to pull it out from the source code.
Let's study Stockfish's evaluation. The source file is at: https://github.com/official-stockfish/Stockfish/blob/master/src/evaluate.cpp
Let's try two examples: bad knight and passed pawn.
- Bad knight
The line:
pos.attacks_from<Pt>(s)
gives you the attack bitboard for your knight. The PST table for the knight is in psqt.cpp.
{ S(-144, -98), S(-96,-82), S(-80,-46), S(-73,-14) },
{ S( -83, -69), S(-43,-54), S(-21,-17), S(-10, 9) },
{ S( -71, -50), S(-22,-39), S( 0, -7), S( 9, 28) },
{ S( -25, -41), S( 18,-25), S( 43, 6), S( 47, 38) },
{ S( -26, -46), S( 16,-25), S( 38, 3), S( 50, 40) },
{ S( -11, -54), S( 37,-38), S( 56, -7), S( 65, 27) },
{ S( -62, -65), S(-17,-50), S( 5,-24), S( 14, 13) },
{ S(-194,-109), S(-66,-89), S(-42,-50), S(-29,-13) }
Do you see -29 for the h1 square?
- Passed pawn
The line:
ei.pe->passed_pawns(Us)
gives you passed pawn information for a colour.
-
Could you elaborate on the "bad knight" part, specifically what those tables mean? I don't know the details of Stockfish's evaluation, but would imagine that it uses rather crude/fast algorithms to estimate things like piece activity. Even if it gets the piece activity part wrong for one piece that's not a big issue as this is only one tiny part of the evaluation. However if you want to look at only one position, you'd have more time and could invent slower/more precise algorithms to evaluate features like good/bad knight!? Mar 20, 2017 at 2:30
-
@user1583209 chessprogramming.wikispaces.com/Piece-Square+tables for PST Mar 20, 2017 at 3:12
-
Not sure I understand what you mean by "statistically" (also you might need to edit your answer where it says "statically"). That is statistics over what data? Mar 20, 2017 at 8:58
-
-
How about positions, where a piece is currently not active, but will be so soon (unavoidably)? For example a rook which can go onto an open file. I understand that in a static stockfish evaluation this would not count as a good rook, while a human might consider it a good piece. Mar 20, 2017 at 9:25