Quick show-and-tell because it’s the first time I’ve used Zig for the purpose of going fast, and I’m excited about how my first pass of optimising went!
I’ve been working on a minesweeper solver in Zig recently: minesolver/zig at main · LewisGaul/minesolver · GitHub
This is something I’ve worked on at various points in the past in both Python and C, and I had intended to rewrite in Rust a couple of years ago but got bogged down in the complexity of the language. This has always been a project I’ve had in mind since I started learning Zig a bit under a year ago.
I started off with a ‘just-get-it-working’ implementation, which was performing comparably to the Python implementation (which uses numpy). I just put in a couple of hours to remove some unnecessary allocations and suddenly the Zig code is going fast! Still plenty of room to optimise, but narrowing down 12,000 possible mine combinations to 60 in 1/30th of a second (in debug mode) is feeling pretty good to me so far!
This project has now reached a point where I’m excited to integrate it into my advanced minesweeper GUI (written in Python) and get it back to looking something like this (screenshot from old implementation):
I’ll update on progress when there are interesting updates - I think this could become a nice visual/pointy-clicky demonstration of Zig where performance matters, in an application that isn’t solely targeted at other developers/computer geeks!