vitogit / pgn-tactics-generator

Generate chess puzzles / tactics from a pgn file
MIT License
114 stars 28 forks source link

Fix resolving --strict value #27

Open karol-brejna-i opened 3 years ago

karol-brejna-i commented 3 years ago

Fixes #21

Please, note the following lines: https://github.com/vitogit/pgn-tactics-generator/compare/master...karol-brejna-i:fix-strict?expand=1#diff-e31f1011e582ea3d502823f13a4a64fdef87e41ed47178a0a6e497df1402a27cR139-R140

There were cases where the number of analyzed legals was 2. In that case

self.analysed_legals[move_number].evaluation.cp

failed with IndexError

I proposed an addition condition (as above), but don't really know the intent of that piece of code.

vitogit commented 3 years ago

@karol-brejna-i I introduced that argument in this commit https://github.com/vitogit/pgn-tactics-generator/commit/0279b9d748eab490a5d14672e50859ac59186c30 but to be honest I don't remember why. I will vote to remove the Strict argument not sure if is that useful

GoldenChrysus commented 2 years ago

The change in position_list.py causes an out of range exception as len(self.analysed_legals) >= move_number does not mean that self.analysed_legals contains move_number. (e.g. if self.analysed_legals has a length of 1 and move_number is 1, that does not mean self.analysed_legals contains index 1; it only contains 0).