thou shalt not divide by zero
Steamhammer is mostly reliable, but does crash occasionally. When SSCAIT catches a crash, it saves a couple of low-level dump files that offer a hope of tracing the cause.
Today I got a game with a division by zero crash, which was infuriating. Division by zero must die! Zero tolerance of zero! I decided to eliminate all bad divisions by inspecting every division “/” and mod “%” in the code, though it was a little tricky when the comment delimiter is “//” and “%” is used in strings.
// don't even enter the same city as division by zero
I did it, and shored up a few weak spots. No direct division by zero should be possible in Steamhammer. I also added error checks in the hope of catching bad parameters before they are passed to BWAPI, which looks like the cause of other rare crashes that I have never been able to trace.
I tell the story as an example. If you want to write reliable software, you have to be thorough. I fix all reproducible crashes immediately, so that (so far) crashes on the server are unreproducible and difficult to solve, but I don’t let that stop me.
Comments
LetaBot on :
krasi0 on :
Steamhammer is now the official reference as a foundation to code C++ based bots in: http://sscaitournament.com/index.php?action=tutorialCpp
Please let me know if any amendments to the text in the link should be made. Also, it'd be good to have something like a an easy to find ticketing system / issues tracker / points of contact, etc. for questions and feedback related to Steamhammer.
Keep up the good work! :)