You are browsing as a guest. Sign up (or log in) to start making projects!

3h 15m 8s logged

As I was working on my benchmarking script, I found that the program is currently much too slow to play up to 2000 full games of Hangman in a reasonable amount of time, even when compiled with full optimizations. Perhaps compiling regex with the regex crate can get expensive, or perhaps there is some suboptimal use of memory within my code I overlooked. The word list is just under 200,000 words long, and while processing that much data doesn’t take all that long, minor inefficiencies are probably magnified a good bit. I may try swapping out the regular expressions for a custom, domain-specific pattern matching algorithm; however, the performance I’ve observed does seem to depend heavily on the calculations that occur after pruning. The program, after all, does get faster when the state is more restrictive. hangstop "?????????" takes about 3.5 seconds with the unoptimized build, since there are tens of thousands of nine-letter words in the dictionary; hangstop "???ee????" -i "nl" takes less than half the time (albeit still far more time than I would prefer). One particular challenge that comes with optimization is the fact that there is little benefit to precomputing anything. The program, as I have said in previous devlogs, is stateless, and it only makes one guess at a time, so it doesn’t spend any more time using data that it does generating it. Besides ditching regex, I may also experiment with lazy evaluation, or find something else to micro-optimize. :)

0
5

Comments 0

No comments yet. Be the first!