I removed the regular expressions from the Rust program, and it did seem to speed things up a little bit, but the unoptimized builds still took a few seconds to run. I couldn’t really think of any other optimizations that weren’t either a pain to implement or unlikely to work, so I ultimately decided just to run my script with the release build and wait. Thankfully, I seriously overestimated how long the benchmarking would take; it got through 1900-odd Hangman games in under 10 minutes. I wrote up a second quick script (not included in the repository) to test my old Hangman solver, but as this was in Python, calling code I wrote months ago, with only half-hearted attempts at optimization, that bit of benchmarking took hours to run. It really shouldn’t have, but at the time I decided I’d rather simply be patient than to actually figure out what was wrong. I had the results the next morning, so I put everything into some CSV files, whipped up a quick bit of Matplotlib code, and looked at how my new Rust program compared with my old Python program. To my satisfaction, the Rust program generally used less guesses overall than the Python program did. However, the programs were rather similar in the number of incorrect guesses they made, with the Python version beating the Rust one by a slim margin. This, arguably, is the more important metric for Hangman; there isn’t really a limit on how many guesses you make in Hangman, only how many wrong guesses you make. The results were nevertheless unsurprising. My Rust program, after all, attempts to optimize the information gained. The Python program attempts to play safely, though often at the cost of using more guesses overall. The Rust program is a little more willing to guess a rarer letter because it knows that absence of that letter still gives you information. This may be something we want to discourage. My plan is to open up a new branch in my repository and see if I can tweak the entropy calculations to make the algorithm a little more wary of incorrect guesses. I suppose that this would make the “entropy” more of a custom heuristic than true Shannon entropy, which reduces the program’s transparency, but I think the potential strategic gains are worth the tradeoff.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.