rpdelaney-archive / python-chess-annotator

Reads chess games in PGN format and adds annotations using an engine
GNU General Public License v3.0
62 stars 29 forks source link

Division by zero if ply_count = 0 #30

Open NajdorfB opened 5 years ago

NajdorfB commented 5 years ago

I experienced the case that ply_count can be zero, resulting in two separate division by zero errors. My quick fix was just to ensure that division by zero is not possible (see 9a311a05300f1454e15169745105faa1537e71ab )

Other solutions might be better or preferred.

rpdelaney commented 5 years ago

Thank you. I handled a similar problem like this: 6caa559ec168e47c86ee433eebef3e6586153039

I tend to find that clearer since it's more obviously there for error state handling. What do you think?

NajdorfB commented 5 years ago

Thank you. I handled a similar problem like this: 6caa559

I tend to find that clearer since it's more obviously there for error state handling. What do you think?

Yeah, it seems like a nice solution, definitive clearer.

rpdelaney commented 5 years ago

Cool. I will get around to it. Feel free to send a PR in the mean time.

By the way, did you observe this with zero-length PGN games or was it with 'normal' games?

NajdorfB commented 5 years ago

I think it happened with zero-length PGN games, but I'm not sure.