TI-Basic Calculator Programming: Minesweeper and More
Hello There. I’m back home for corona and found some fun programs on my calculator I wrote in high school. First up: calculator minesweeper.
This version of minesweeper can’t quite compete with what you’re used to, but it has some handy functionality that gets you thinking about Minesweeper at a lower level. You’ll also get to see what TI-Basic looks like!
- Saving games
- Clearing adjacent mines when revealing a zero
- Starting the game on a zero
- Keeping track of time
When starting up the program, you will have the option to play on a new board, to replay the last board, or to load a saved game. The program stores previous games in calculator matrix variables which work nicely for grid structured games like this one.
Get a glimpse of TI-Basic code
The replay last board option was mainly intended to make the long board generation times bearable. These calculators are not especially fast; it takes about 30 seconds. When loading a new game, you can see the controls. Arrows to move, 8 to toggle the flag, and enter to reveal.
Code for calculating Percent Loaded
Once finished loading the board, you start the game with your cursor over a randomly selected 0. I partially implemented the functionality that clears the surrounding when revealing a zero, however it doesn’t fully capture the zero lake as implementing such functionality would make the program run even slower than it already does.
Code for recursively revealing zero lake
You can mark potential mine locations with a “P” flag. If you reveal a mine, all the mines are revealed before wiping the screen away. When the game ends, you are presented with your outcome, the time you played for, and the number of mines. I’m pretty sure it took me longer to code this than I spent playing it.
Code for revealing mines and clearing screen
Looking back, I’m surprised I was able to persevere through writing out the program. No vim bindings, no indentation, and the screen holds just 9 lines of code! Upon opening the code back up it took me a while to reorient myself (there were zero comments at the time) as the syntax is just a small step above assembly. I think most of the time I spent putting this together was during math class.
The fun doesn’t end there. I remember some of my favorite programs to play around with were “Prank” programs which run their mission in “stealth” mode without the user noticing. One such program appears to parse arithmetic operations normally, but occasionally adjusts the output of an arithmetic expression by minor amounts, potentially leading someone to think their calculator is broken.
If you are very fast you can code and run this program on a friends calculator while they aren’t paying attention. :)
Simple guessing game for a number between 1 and 10000 with a first place leader board. This is the first time I became familiar with binary search.
Seems to correspond to some math equation, but I haven’t been able to figure out which one. Let me know if you figure it out!
Before Minesweeper I put together a Flappy Bird “clone”, but unfortunately it doesn’t seem to have stood the test of time. I vaguely recall wincing as someone reset the RAM of my calculator along with all the code.
You can find the code for the above and more on GitHub if you’d like to give it a whirl on your very own ti device / emulator. Thanks for tuning in!