Chalculator
- 6 Devlogs
- 4 Total hours
This is another Java game where players see numbers, operators, and the answer and have to guess the original equation.
This is another Java game where players see numbers, operators, and the answer and have to guess the original equation.
Today I finished working on implementing a difficulty system. It took a long time because I had to change standard arrays into ArrayLists and there were numerous IndexOutOfBounds issues. But while checking for errors I also caught an unrelated missing return statement that just so happened to never be reached while I was playtesting, so that’s nice. I am now planning to ship it soon!
Today I spent most of the time fixing errors. It’s now ready to be played and I will ship it shortly.
I have to admit, this game is very challenging. I plan to introduce a difficulty setting, in a later version.
Today I started debugging the programme. The compilation errors were very easy to solve, especially with the densely-populated progress messages. It was eventually realised that this was an error due to wrong variables taking the place. However, I noticed a critical logic error when the code compiled, giving out incomprehensible answers. I suspected that this was a problem in calculating the answer because all the invalid answers were correctly flagged. I eventually noticed that this was because I didn’t reset the numbers whenever the operator was keyed in…
But even then I still have no idea why it’s producing nonsense. For some reason it thinks 568*9+2 = 9.0, even though I’m very sure my implementation is already correct. I feel like giving up because I can’t debug since AI is also spitting out nonsense right now.
Today I finished coding the answerVerify method. While coding the method, though, I thought of rounding the answer so the answer doesn’t fill the entire line and allow the user’s equation’s answer to be off by a small amount. What I didn’t notice before was that that meant my answers variable should be a double, not an int. I had to go and change a lot of parts where an int was used rather than a double, and that took a good amount of time. Now, I am able to run the code, but I’d need to fix these OutOfBoundsErrors (I’m not frustrated because I didn’t expect it, but I can’t identify where it is)… that will take time. I will use the “loading message” method I described before to locate the error, since these error messages are impossible to interpret (at least for me) unless you use AI. (image caption: OK, the error is between 2% and 3%)
Today, I finished the questionGenerator() method, and now I am on my way to make the answerVerify() method which checks if the answer the user entered is valid and correct. But even right now, this game is starting to have a lot of lines (it’s one of the most I wrote for a single project), and personally I find it hard to keep track of what it does. I feel that that would become a genuine struggle when I test the game in the future. There would be simply too many lines to correctly pinpoint the problem. It is night time right now, so I will find the error tomorrow. I plan to have loading messages printed to the console for every step to see where the code is experiencing a problem (e.g. “values generated!”, “equation assembled!”, etc.). This means the code compiled correctly up to the last loading message and that’s where the error might be.
I completed the game introduction that loads when the user first loads the game, so they will know how to play it. The questionGenerator method is quite a challenge because I’d need to ensure there are the correct number of values. One too few, there might be an awkward plus on the end. One too many, it looks like a 1259 when it is supposed to be 12 and 59 (or even 1 and 259, for that matter). I had to pay special attention to ensure there are no off-by-one errors. In the future, I would need to work on a method that evaluates whether the user entered a valid formula. I feel that would be hard because converting Strings to operations will be difficult, but I’m thinking of a solution that scans each character of the answer and conduct operations accordingly.