wiki:WikiStart

libmines

"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.

Why?

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, so why not let them?
  • Variation on the rules. Separation makes it easy to experiment with 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 allow it. Also, the library can reveal the safe squares around the edge of 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. The mines library lets you select higher or lower levels of intelligence.
  • Keep your 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. It's okay to be addicted to puzzle games, as long as they keep exercising your mind. A regular Minesweeper game turns into drudgery after a while.
  • Large-scale games. Without the mindless clicking, there's no real reason why we can't play on huge playing fields with lots of mines. Games can be saved and restored, so take your time!

Getting the Source

There are many, many ways of getting access to the source code repository:

  1. The option bar on this site has a Browse Source option, which gives you full historical information.
  2. The same repository can be accessed (though not modified) anonymously by directing a  Subversion client at svn://pqxx.org/mines/.
  3. Releases will be made available through  http and  ftp.

Try it Online!

You can now play a game online. Try different variations on this URL to start games with various parameters:  http://pqxx.org/mines-online?rows=20&cols=20&mines=100&intl=2

The possible parameters are:

Parameter Meaning
rows Height of playing field
cols Width of playing field
mines Number of mines in playing field (values around rows*cols/4 or rows*cols/3 work nicely)
intl Intelligence level of "autocompletion"

You can set these parameters by pointing your browser at the URL above to start a game, but first replacing the values corresponding to these parameters in the URL. For testing, I sometimes play a  harder game with experimental features enabled.

Author

This program was written by Jeroen Vermeulen, then at Software Industry Promotion Agency ( SIPA). Contact me as "jtv" at xs4all.nl (preferably in English).