identifying opening

Sort:
pandaTT

what's the most efficient way to identify an opening from a PGN without reinventing the wheel? is there an existing python implementation/API?

ImperfectAge

Yes.  If you have a polyglot book file.  See the 'rm_bookmoves.py' here

https://www.chess.com/blog/e4_guy/chess-analysis-on-linux-command-line-addicts-heaven

Also see the excellent Python chess API https://python-chess.readthedocs.io/en/v1.6.1/polyglot.html

 

 

ImperfectAge

What are you working on?

stephen_33

I've never needed those and I'm fairly certain the answer is no but I think you may be able to derive a game's opening from the PGN data? For example:-

https://api.chess.com/pub/player/pandatt/games

from the first game in the listing:-

{"url":"https://www.chess.com/game/daily/340325471","move_by":1625989553,"pgn":"[Event \"54th Chess.com Thematic Tournament - Morra Gambit (1400-1599) - Round 1\"]\n[Site \"Chess.com\"]\n[Date \"2021.06.15\"]\n[Round \"1\"]\n[White \"viperfang4\"]\n[Black \"pandaTT\"]\n[Result \"*\"]\n[SetUp \"1\"]\n[FEN \"rnbqkbnr/pp1ppppp/8/8/3pP3/8/PPP2PPP/RNBQKBNR w KQkq - 0 3\"]\n[Tournament \"https://www.chess.com/tournament/54th-chess-com-thematic-tournament-morra-gambit-1400-1599\"]\n[CurrentPosition \"r2qkb1r/1b3ppp/2np1n2/1B2p1B1/4P3/2N5/PPP2PPP/R2QK2R w KQkq - 1 11\"]\n[Timezone \"UTC\"]\n[ECO \"A04\"]\n[ECOUrl \"https://www.chess.com/openings/Reti-Opening-Black-Mustang-Defense\"] ....


Is that of any use to you?

pandaTT

thanks everyone for the above. super helpful! re: the ECO code in the PGN clearly that's best if available happy.png  but I don't think it's mandatory for a well formed PGN. @ImperfectAge nothing concrete yet but will definitely update here if I get anything interesting.