TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: A chess repertoire builder written in Rust

4 pointsby zcesurover 4 years ago

1 comment

zcesurover 4 years ago
During the quarantine, I&#x27;ve been sharpening my tactics and studying endgame theory, but lately I&#x27;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&#x27;ve been watching play before trying them out in actual games.<p>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.<p>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&#x27;s requirements are when it comes to lifetimes &amp; 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&#x27;t think it causes any safety issues in this case.<p>[1]: Shout out to Eric Rosen, Jonathan Schrantz &amp; the chessbrahs. [2]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Region-based_memory_management" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Region-based_memory_management</a> [3]: <a href="http:&#x2F;&#x2F;smallcultfollowing.com&#x2F;babysteps&#x2F;blog&#x2F;2015&#x2F;04&#x2F;06&#x2F;modeling-graphs-in-rust-using-vector-indices&#x2F;" rel="nofollow">http:&#x2F;&#x2F;smallcultfollowing.com&#x2F;babysteps&#x2F;blog&#x2F;2015&#x2F;04&#x2F;06&#x2F;mode...</a>