fsmosca / chess-artist

A python script that can annotate chess games in pgn file with static evaluation or search score of an engine, can annotate an epd file with acd, acs, bm, and ce opcodes, can test engine with epd test suite and can generate chess puzzles.
GNU General Public License v3.0
69 stars 18 forks source link

Detect moves that sacrifice material. #27

Closed fsmosca closed 4 years ago

fsmosca commented 7 years ago

Material is not regained in the next 3 moves or more, but the position is still good.

fsmosca commented 7 years ago

If the side to move of the current position sacrifices a piece, Example:

  1. A non-capture move to a square where it can be attacked by lower piece value say Rb7 and black would reply Nxb7
  2. A queen captures a pawn or knight or bishop and then that queen is captured by opponent's pawn, knight, bishop or rook.

If such situation is seen by examining the main line of the game under analysis, search this position with time extension and capture the pv of the engine. Walk the pv line say up to 6 or more plies, and check the material balance at the end of the pv walk, if the material is in favor of the opponent but the search score of the engine is equal or in favor of the player that sacrifices material, then this can be considered as one player sacrifices material and a comment can be added to the move like, White sacrifices material !! or With compensation of the sacrificed material.

Another method to detect the side to move has sacrificed material is by examining the move history of the game forward. Say 12. Rb7 Nxb7 {If black is now ahead in material and search score showed in favor to white or slightly in favor to white} 13 aaa bbb 14 aaa1 bbb1 15 aaa2 bbb2 16. aaa3 with black to play and black is still ahead in material at move 16, it is possible that the move 12. Rb7 is a sacrifice.