August 4, 2015 Log No. 311

Top of the Minesweeper Loserboards

I am uniquely gifted at finding mines on a blank board. I swear that it’s at the point of a statistical anomaly: there’s a > 10/81 chance that my first choice is a bomb. When we first started coding the project today, I kinda forgot why I never really played Minesweeper, but yeah, I remembered real fast.

But it was a fun game to code at least! Actually things fell into place much quicker than I thought, once we had decided what properties the Tile class would handle, vs the Board, vs the Game. Maybe somewhat “controversially”, we decided to not store position info in the Tile objects and just have the Board handle all that, with Tile class methods to generate neighbors, but our reasoning for that was the same as why the valid_moves method in Knight’s Travail was a class method: shouldn’t Tile.neighbors work regardless if a Tile instance has been created? Maybe I just want to know what neighboring tiles a Tile at position (5, 5) would have. I don’t need to make a Tile at 5, 5 to find out, I just need to pass in that position and the board info to get it. At least, that’s how we figured it. Nothing against implementing it as an instance method, of course, and it would be easy enough to do.

It was pretty nice how Board.reveal(position) lent itself naturally to recursively revealing tiles until it hit a boundary of bomb-bordering tiles. And we even got YAML to work on our game, to allow us to save and load board states. So it’s a full-featured game! First time pushing to Github as well. The code’s all at github.


Leave a Reply

Your email address will not be published. Required fields are marked *

*