Sunday, January 23, 2011

A Mine in Many Languages

One of my favorite games is the Windows classic Minesweeper. It is a simple yet addictive game that really engages your mind, and it is an excellent introduction to game programming. A lot of budding programmers are most interested in game programming because it gives you instant gratification, the visible results and interactivity that is missing from a large number of introductory programming assignments. Minesweeper may not have the flashy graphics or multiplayer capabilities of a hit game, but it is that simplicity that makes it an excellent starting program.

With any program, no matter the language or the scale, the first thing that you want to do is determine what exactly you will need. For minesweeper the list is fairly straightforward:

  1. Area to display the grid.
  2. Ability to click on squares in the grid.
  3. Ability to distinguish between unclicked square, square with a mine, square with a number, and square that has been flagged.
  4. On square click, the ability to determine if the square is a mine and if not the ability to count neighboring squares.
  5. Ability to detect when game is finished, either by clicking on a mine or by clicking on all non-mine squares.
  6. (Optional) Timer or move counter
  7. (Optional) Ability to change options; grid size, number of mines, etc.

Your answer to these questions may change depending on the language you choose to write the program in, and the personal desires of the client. It is important to note that creating any list such as this is not meant to be too detailed or all inclusive. Some programmers prefer to just jump right in, others prefer to have absolutely everything planned and outlined in advance.

I will be referring back to this post regularly, with the goal of having a working version of minesweeper in every language that I learn.

1 comment: