100 Days of Code Day 49
Another secret requirement in the exercise Grains. I am supposed to throw an ArgumentOutOfRange if the value passed in is not between 1 and 64. Maybe put that in the problem description. I shouldn’t stumble across it in the tests because you want to feel clever that I didn’t implement an unspoken requirement or didn’t mind-read to use the exact exception you expect. Anyway it is the chessboard problem. If you start with one grain of rice on square one of a chess board and double the amount for each successive square you will quickly bankrupt a kingdom. Then the King will go from wanting to reward you for helping him to wanting to exterminate you for trying to trick him. 9,223,372,036,854,775,808 grains is how many tons of wheat? Couldn’t find an exact answer but it sounds like about 21 trillion bushels of wheat.
For the 2048 game I added sound. Since the sound is annoying I added a mute/unmute function by pressing the letter ‘M’. I also added a new game function by clicking the letter ‘N’ on a You Win/Game over state. I don’t like that these things are hidden. However, I think I need to take a break on it and come back to finish it up later. I would like to do a windows and web version. Turn the you win/lose into a dialog box looking thing with a ‘new game’ button. Also, I should only have the mouse move leave trails on game win/over. I should also work on the tile drawing a bit, maybe add colors. Yes I am going to leave the animation as-is, and no I didn’t see any seg faults today but I didn’t find the source yet either. The audio is courtesy of https://sfxr.me/.
