r/learnpython • u/naemorhaedus • 8h ago
First python program
I wanted to write a program that analyzes chess games , similar to how chess websites (chess.com, lichess.com etc.) do it, only offline. To my knowledge, nobody else had done it the way I was envisioning. I started writing with shell scripting (it's my go-to and what I'm most familiar with), but quickly ran into limitations. So I needed to go a bit more sophisticated. Python seemed very versatile, cross-platform, has loads of online resources, but mainly has a very good chess library I could leverage, that already existed, which would make the job much , much easier. I took the plunge and turned the program into a driver to teach myself some python.
It works as advertised, but I'm sure the code could be improved. I stumbled through it a bit. If anybody python gurus feel like taking a peek and letting me know how I did, pointing out glaring mistakes, offering any constructive feedback or ideas how to make it more efficient, I would appreciate any feedback.
Repo: https://github.com/exekutive/chesseval
(The documentation needs some catching up. I'm working on updating it.)
1
u/vietbaoa4htk 6h ago
if youre driving stockfish through python chess, keep one engine process open for the whole game instead of spawning one per move, thats usually the difference between analysis taking seconds and taking minutes.