Hi Rich,
Great to have a Minesweeper game on the VIC !
Now, I converted it to a WimBasic version. That makes it no longer dependant on the memory configuration. I brought it back to 36 lines, 1682 bytes. Also, I brought down runtime memory consumption. It can now play in a stock VIC-20 with WimBasic, easily. Even with a 9*10 grid.
More importantly, I brought the elapse time of the 'thinking'-part back by more than 60% (9x10 grid with 1 mine takes less than 18 seconds in the WimBasic version versus over 50 seconds in the original version).
For amusement during waiting, I animated the analysis so you can follow what's happening. And, check for a win is now faster.
I took the liberty of including the WimBasic version in
https://home.kpn.nl/oost4231/wb_samples.zip
In the WimBasic version I make use of only one matrix array. Each element corresponds to a cell in the grid and can have one of five states, where
bit 0 indicates "mine", bit 1 indicates "flag", bit 2 indicates "uncovered". With bit 2 set, bits 1 and 0 have no meaning anymore.
The number of adjacent mines to a cell is only on display and not in the matrix array.
The cell-state information could also be put into the "shadow-color" memory because it needs no more than 3 bits per cell. But programming around that is a bit of a hassle.
A string is used to hold the workload for the 'thinking' part. Each coordinate is held there through CHR$() and retrieved through ASC(),so the maximum string length needed is 180 characters. For a grid larger than 127 cells you could fold X and Y together, but only as long as the number of cells in the grid is less than 256.
Benefits of using WimBasic for this game are the powerful commands and functions:
- ERASE
- WHILE/WEND/QUIT
- IF/THEN/ELSE
- ODD(), XOR(), MAX(), MIN()
- COKE
- SuperNumbers
and more.
Regards,
Wim.