lichess-org / lila-openingexplorer

Opening explorer for lichess.org that can handle all the variants and trillions of unique positions
http://lichess.org/analysis#explorer
GNU Affero General Public License v3.0
135 stars 34 forks source link

Check if position corresponds to a known opening even if play param is empty #168

Closed iamhectorotero closed 2 years ago

iamhectorotero commented 2 years ago

As indicated in https://github.com/lichess-org/lila/issues/11025, when working FromPosition the Opening Explorer doesn't show the opening name even if the position specified is a known one.

The problem happens because the response the frontend gets from the internal endpoint (https://explorer.lichess.ovh/masters) doesn't contain the opening itself, even though according to the API docs it should if the FEN matches a known opening.

I have traced the issue to here and seen that if the endpoint receives an empty play parameter, it won't try to match the position to an opening and just return None. Therefore, I've added this couple of lines to try to match the position to an opening if the play parameter is empty.

niklasf commented 2 years ago

Oh, nice find. I didn't expect that bug to go this deep.

benediktwerner commented 2 years ago

It probably should do this even when play isn't empty, no? So that it finds the correct opening when the FEN is still a known opening but all the moves afterwards not.

iamhectorotero commented 2 years ago

That's actually a good point, @benediktwerner. What do you think @niklasf?

I created a new PR (https://github.com/lichess-org/lila-openingexplorer/pull/169) in case you want to merge it