I created a Minesweeper program a few months ago using a matrix. In order for mines to be placed randomly, I used randInt( commands for the x and y locations and made it so it can't select the same square twice. To input the numbers, the program runs through every single square and finds the number of mines (represented as 9's in my program) around that square and stores that number into the matrix. The problem: the calculations take forever (about a minute for a 10x20 game, and 45 seconds for a 8x16). The problem is that I used If…Then conditions to work around the boundaries. The program subtracts and adds to the x and y components to "look" at the squares around it, but at a boundary, a DOMAIN:ERR arises, and I figures If…Then commands would fix it. But it goes through so many that the amount of time taken is too long. Is there a way around this? I tried extending the boundaries of the matrix on all sides leaving the outside null, but the variables mix up with the constants and the larger matrix takes more memory.
My second question: is there a way for the program to spread out the zero squares like the computer version does? The best mine does is open every square around a zero except on the edges.
This is all in TI-Basic. No Assembly.