20200612 minesweeper clone
.
Today's effort is a minesweeper clone, written in Java. This uses tty magic to
clear the screen, so probably won't work on Windows.
https://github.com/cratuki/console_minesweeper_java
I feel satisfaction at having gone from nothing to a working github project
within a day.
The model for enumerating squares is rough-and-ready. Each possible square
state is represented by a byte value.
In retrospect, it would have been tighter to use bitmasking. Consider if each
square would be represented by a byte of this structure,
Low five bits: Number of neighbouring squares containing bombs (less
than or equal to 8)
High three bits: is_bomb | is_marked | is_revealed
The code required to work that structure would be tighter than today's effort.
It has been four years since I attempted anything in Java, and far longer
since I build anything that worked. Result.