Version 2 (modified by jtv, 14 years ago) (diff)



This project is brand-new, so don't expect to find much here just yet.

"libmines" is yet another implementation of the infamous Minesweeper game--but as a library this time.

I'm sure you know the Minesweeper game: you start out with a rectangle of water, divided into squares. Each of the squares may or may not contain a mine; you find out by clicking on it. If it held a mine, you die. If it didn't, it shows the total number of mines present in the eight surrounding squares. This hopefully gives you enough information to figure out that some neighbouring square is also "safe," and so on. Sometimes the game helps you a bit by revealing the squares that are absolutely obvious automatically.


Believe it or not, there were still reasons to write a new Minesweeper. Some of these were:

  • Clean separation of user interface and game logic. This project is currently all about the game logic. Others write better user interfaces than I can!
  • Different rules. Viewing the game logic separately from presentation allows for variations on the game. For instance, most Minesweeper games won't ever reveal mines--all you can do is set little flags to remind you where you deduce the mines must be. That's different here, if your user interface will support it. Also, the library can reveal the safe squares around the minefield right away to help get you started. Most other versions of the game let you gamble and die a few times before you get a decent start!
  • Intelligence. "Normal" Minesweeper games will help you a bit if you hit a square with no nearby mines: they will automatically reveal the neighbouring squares, and if any of those is also near 0 mines, that square's neighbours are also revealed and so on. This still leaves a lot of squares that are "obviously safe" to me, but need to be clicked anyway. This is where I usually make most of my mistakes. Instead, this library has multiple levels of intelligence.
  • Keep the brain working. With smarter "auto-completion" of the game, the player is left with the interesting problems--the little puzzles that make the game fun. Now you can tackle much larger minefields at higher difficulty levels, without wasting time on the easy parts.