Need ideas on recognize 'tactics' from game database.

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Re: Need ideas on recognize 'tactics' from game database.

Post by Kempelen »

Thinking on how to get a good PV, it comes to me an idea. The PV could be as long as the material balance is the same as the start position......
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/
matthewlai
Posts: 793
Joined: Sun Aug 03, 2014 4:48 am
Location: London, UK

Re: Need ideas on recognize 'tactics' from game database.

Post by matthewlai »

Ajedrecista wrote:Hello Matthew:
matthewlai wrote:Most of them are pretty shallow change-of-minds, but there are quite a few at above 1 million nodes, too.
Thanks for your time. I also see jumps when |evals| are very high, over 3 pawns and more. A good idea could be filter these results with an arbitrary minimum acn and a maximum of min.(|c0|,|ce|) unless there is a change of sign from c0 to ce or you get something like c0 = -900 and ce = -5.

Regards from Spain.

Ajedrecista.
Yeah that is true.

I tried to not filter as much as possible, while generating, because generating these positions is very time consuming.

So I decided to generate too many rather than too few, and possibly filter them afterwards, since that's easy.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 4:48 am

Re: Need ideas on recognize 'tactics' from game database.

Post by kbhearn »

You might want to add a condition to filter out the positions where the jump in score does not correspond to a change in game evaluation (won/drawn/lost). crudely requiring either the before or the after to be say below 200cp absolute value would get rid of a lot of these which merely correspond to the snowball effect once you have an advantage (if you're already up a rook there's often ability to go up more on the board, but that doesn't really make for a good tactic problem when there's many ways to win and sometimes a justifiable human approach is even to give up some of that material to reduce to a simpler, slower, but still winning ending)
matthewlai
Posts: 793
Joined: Sun Aug 03, 2014 4:48 am
Location: London, UK

Re: Need ideas on recognize 'tactics' from game database.

Post by matthewlai »

kbhearn wrote:You might want to add a condition to filter out the positions where the jump in score does not correspond to a change in game evaluation (won/drawn/lost). crudely requiring either the before or the after to be say below 200cp absolute value would get rid of a lot of these which merely correspond to the snowball effect once you have an advantage (if you're already up a rook there's often ability to go up more on the board, but that doesn't really make for a good tactic problem when there's many ways to win and sometimes a justifiable human approach is even to give up some of that material to reduce to a simpler, slower, but still winning ending)
That is true.

It depends on what these positions are used for. Those positions are probably not very useful for human training, but they should still be useful for computer training, where it's an advantage to see those changes earlier, too.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Need ideas on recognize 'tactics' from game database.

Post by Henk »

Just make a copy of your engine that resigns early. Play some games and print the final position. These final positions may contain a combination that made your engine resign.
PK
Posts: 913
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Need ideas on recognize 'tactics' from game database.

Post by PK »

that's not gonna work that way, but there's a potential to squeeze something out of that idea, by recording resignations with material advantage .
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Need ideas on recognize 'tactics' from game database.

Post by Ferdy »

Kempelen wrote:Hello,

I am thinking on making my own 'tactics position generator' tool. Let say, based on a big PGN file, extract 'tactics' puzzles from it. They should be not only king attacks (as usual), but quite moves, pawn advances, sacrifices, captures, endgames, etc... I would use my own engine routines to make it.
I want it only for my enjoy (programming it) and for use those possition from my own training.

I ask for ideas on how to recognize those positions.... they should be obviously not easy mistakes....

Thanks for the help
One way to collect these tatctical positions is by using multi pv.
What I did is save those positions where bestscore >= 500 and bestcore2 <= 0. The bestscore2 is score from multipv 2. The idea is this is the position with only 1 best move and that this best move is winning. The margin 500 can be adjusted depending on what type of positions you want to save. For mate positions you can increase the 500 to say a value equivalent to mate in 2 or so. But note that margin 500 will also cover those mate in x positions already because of bestscore >= 500. By manipulating the bestscore2 you will be able to create alternative solutions.

Here are sample positions saved from the python script. I use the pgn from 2014 world blitz championship, using sf5 at movetime 100 ms per position using multipv 2, with the following conditions.

Code: Select all

if ((bs1 >= 30000 and bs2 <= 1000) or (bs1 >= 500 and bs2 <= 0))
Once position is found in a game, I continue to find position in the next game. This is pretty fast considering that I am using multipv 2 on 0.2 sec, I am not sure if longer time will produce better looking positions, but the first 10 positions saved by script are not bad I think, especially for beginners, but there are positions there that are challenging too. The 4th (mate threats) and 9th (sort of deflection, promotion and checks) positions are good.

Positions converted to pgn with soluton as bestmove from engine.
[pgn]
[Event "movetime 100 bs1 32756 bs2 72"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "1R6/2k5/4K3/8/8/4B3/2r5/8 w - - 0 1"]

1. Bf4+ *

[Event "movetime 100 bs1 528 bs2 0"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "5rk1/2P2pp1/1R1Qp3/p5p1/3Pq3/6P1/5PKP/8 w - - 0 1"]

1. Kf1 *

[Event "movetime 100 bs1 32763 bs2 94"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "1k3b2/1p3pp1/pBrr4/4R1P1/2p2P2/1P5B/P2p1P1P/2R3K1 w - - 0 1"]

1. Re8+ *

[Event "movetime 100 bs1 32760 bs2 408"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "8/6pk/1Q2p2p/3pq3/4p3/4P1PP/3R1P1K/2r5 b - - 0 1"]

1... Qa1 *

[Event "movetime 100 bs1 672 bs2 -328"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "5rk1/1Q2p2p/3p1ppP/3P4/2n1PP2/6R1/4q1PK/8 w - - 0 1"]

1. Qxe7 *

[Event "movetime 100 bs1 32760 bs2 319"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "3R4/r3rBk1/4Pp1p/2pK1Pp1/2Pb2P1/8/P6R/8 w - - 0 1"]

1. Rg8+ *

[Event "movetime 100 bs1 684 bs2 0"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "5n1k/4q2p/p1P2p2/1pK2P2/1P1Q1P2/8/P6P/8 w - - 0 1"]

1. Kb6 *

[Event "movetime 100 bs1 935 bs2 -11"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "8/1pk4p/p7/P1KP4/6p1/6P1/7P/8 w - - 0 1"]

1. d6+ *

[Event "movetime 100 bs1 1358 bs2 -51"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "r4k2/1p3rpB/2p5/p1np2qN/P7/2P1Q2P/1P4p1/R3R1K1 b - - 0 1"]

1... Rf1+ *

[Event "movetime 100 bs1 32763 bs2 -31"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "3rbk2/Q1R2pp1/7p/3Bq3/pp5P/6P1/P4PK1/8 w - - 0 1"]

1. Rxf7+ *
[/pgn]
Classifying these positions to tactical motiff is a challenge. Since you are using your engine, with access to internal functions, you can evaluate positions if there exist tactical motiffs like pins, skewers, deflections, and others. I have not tried, but if I have to do it, just evaluate the first 3 or 5 plies of the engine output. Look for checking moves in those sequence, or discovered checks, or a passed pawn push to 7th rank, or opp pieces pinned, with that info you will be able to classify tactics.
A good tactical themes are here.
http://chesstempo.com/tactical-motifs.html