1 comment

[ 0.30 ms ] story [ 10.8 ms ] thread
During the quarantine, I've been sharpening my tactics and studying endgame theory, but lately I've been wanting to learn some openings. In particular, I wanted to get a little practice with some crazy openings that the streamers [1] I've been watching play before trying them out in actual games.

So I built this CLI tool. The intended use case is to 1) download the games of a chess player from a website like openingtree.com, 2) run the program on the fetched PGN file to generate an opening repertoire, and 3) import the output into a study tool like lichess or chessable.

This has been my first foray into Rust and I learnt a lot while coding. One thing that particularly gave me trouble was modeling the opening tree given how stringent Rust's requirements are when it comes to lifetimes & mutability. Fortunately I found out about arena allocation [2] in a blog post [3] by Niko Matsakis, a Rust core dev, and inspired by the approach he advocates I was able to implement it in a fairly straightforward way. Although pruning the opening tree results in a leak as a consequence of this impl, I don't think it causes any safety issues in this case.

[1]: Shout out to Eric Rosen, Jonathan Schrantz & the chessbrahs. [2]: https://en.wikipedia.org/wiki/Region-based_memory_management [3]: http://smallcultfollowing.com/babysteps/blog/2015/04/06/mode...