DemineExercizer

This program is a clone of Minesweeper; the following image shows its board. There is a main menu, two digital counters, a button with a smiling face on it and two boards with many colored tiles. Clicking the button is possible to clear the current configuration (upper image) while the second image remains unchanged (if the 'New cfg' option is checked then also a new random configuration is created in the bottom image).

There are some bombs (the exact number of which is shown by the digital counter on the left) placed on the board: the game is to found them all and flag them. To do so there is the help of the tiles that don't hide a bomb: they reveal the number of bombs around them. Safe tiles must be clicked to gather more information about the current configuration. The rules are exactly the same as the rules of Minesweeper so why a new clone ? Well there are some differences, can You spot the most obvious ? As You can see from the image above the entire configuration is revealed by the second image at the bottom of the game's window, but there is an option to hide it completely from the user view. But where has gone the spirit of the original game if every bomb can be spotted in the image below ? This feature reveals clearly that the main purpose of this program is not to enjoy an human user (it can do this too if the right options are checked, but this is a different history ...) but to exercize another program, Demine in this case. The two programs can talk via a code interface (WM_COPYDATA). With this program is possible to create a configuration (randomly or by hand), to save it, to modify it and to play it again and again. This ability is particularly useful to debug Demine: for example if while playing a configuration Demine makes a mistake and some bomb explodes (or it cannot guess an obvious configuration) is possible to capture the configuration, modify Demine and try it again with the same configuration to verify if the behaviour of the program has been really improved.

Let's now take a look at the program's menus to learn some details of the program.

File menu

This menu allows to quit the program (with the Exit item), to save the current configuration to a file (with the Save item) or to load a configuration from a file (with the Load item).

A configuration has two parts: the most important part is the positions of the bombs (corresponding to the lower image), then there is the current configuration (corresponding to the upper image). Both parts are needed to take a snapshot of the game in a particular moment; the upper configuration reveals the current situation (but it is static as a Demine configuration or a bitmap of the board), while the lower configuration allows the advancing/evolving of the game (it can be considered the dynamic part of a DemineExercizer configuration). The configuration is saved in a .bum file and it is the sum of a header and two Demine configurations (corresponding to the contents of .min files). The configurations are swapped with respect to their position on the window: first we have the bomb positions and then the current situation. A sample configuration follows in the green table below.

 

DemineExercizer configuration (.bum file)

DemineExercizer_G1@nn1Luc1@n1(2006)
Demineur_G1@nn1Luc1@n1(2003)
Width= 30
Height= 16
Bombs= 99
.*..**.*.*.*.........*...**.*.
..*..*......*..*...**.......**
.......**.....***..*..*....*.*
.......*.*..*............*....
..*............*..*.......*...
...*......*.....***......*....
...............*...........*..
............**..........*.....
.*.......*..*.....*...**......
*...........*.......**........
*........*.........****..*.*..
..**...**.........*.*.**..**..
....*.............*.*..*......
....*........*........*......*
*..**.............*....*..**..
...*.*...*.*..*..*.......***.*
Demineur_G1@nn1Luc1@n1(2003)
Width= 30
Height= 16
Bombs= 99
==============================
==============================
===========================F==
===========================221
===========================1..
===========================21.
========================222F1.
========================F1111.
========================21....
========================21211.
========================2F4F2.
===========================F2.
===========================221
==============================
==============================
==============================

The Load menu allows to load DemineExercizer configurations or Demine configurations/boards.

While the DemineExercizer configuration is complete in the sense that it reveals both a current situation and the possibility to evolve it, the Demine configuration is a snapshot of a moment; it is used to build the bombs configuration i.e. it MUST show the position of all the bombs of the original configuration (no matter if bombs are revealed by flags, bombs tiles or exploded tiles). So a Demine configuration can be used as a base, a starting point to build a complete DemineExercizer configuration.

Edit menu

The Tools menu allows to undo the last action (or to redo it again); it also allows to copy the current configuration (the cfg shown by the upper image) to the clipboard.

Tools menu

With the Tools menu is possible to redraw the current board or to activate a window that let You create a new configuration by hand.

The following image shows a snapshot of the window: the current lower real config is copied to the new form leaving only bombs; it is possible to drag & drop bombs around on the image to customize the configuration as required. Also a wheel mouse can be used to 'rotate' rows and columns. The wheel can be used to rotate columns up & down and, if CTRL is pressed the row under the mouse pointer can be rotated to the Left (rotating up the wheel) and to the Right (rotating down the wheel).

A click with the right mouse button and the following popup menu appears and let You accept the created configuration or reject it and return to the main window of the program. It is also possible to create a new random configuration. The accepted configuration replaces the real configuration in the main bottom window and the current upper configuration is cleared to reflect such an important change.

Options menu

The options menu allows the customization of the behaviour of the program (different behaviours range from a close clone to Minesweeper to a perfect partner/exercizer for Demine passing from a configuration creator as we saw with the 'Create configuration' menu). The color of the digital digits can be chosen from a variety of colors, board appearance can be customized (old Minesweeper, current Minesweeper, W2K flowers or XP flowers appearance), the exact bombs' position can be hidden or revealed, sounds can be used and clicks from user or via the code interface can be allowed or forbidden and so on.

In particular the Draw As option let You choose the boards appearance i.e. which set of tiles is used to draw the boards (as with Demine).

One difference with Demine is that DeminExercizer uses only multicolor bitmaps as the following menu snapshot shows.

The LED color option let You choose the digital digits' color among the following colors:

The View bombs menu let You decide if the lower board is visible or not; hiding it makes DeminExercizer a clone of Minesweeper.

If the Sound option is checked as in the menu snapshot above, it's possible to select the sounds used to communicate failure or success. The available sounds are those of Minesweeper, the sounds of the different flower Italian version or a voice saying something as 'very good' for success and 'Oh-Oh' for failure. If sound is enabled a 'tick' is generated for every click that modifies the board and when the program is closed a 'Goodbye' message is issued.

As already said checking the New cfg option forces DeminExercizer to create a new random configuration every time the face at the top of the window is pressed.

It's also possible to enable/disable user clicks and/or clicks generated via WM_COPYDATA messages with the Accept clicks from option.

Help menu

The Help menu contains only the About menu items whose purpose should be clear.

 

It is also possible to drag & drop a '.bum' file from Explorer to the program GUI to load it.

WM_COPYDATA program interface

It is possible to drive the program via a code interface i.e. using the WM_COPYDATA Windows message. The following table lists the constants and a structure used by the code interface.

enum DemineProtocol {
  PROTOCOL_CAPTURE,
  PROTOCOL_CLICK,
  PROTOCOL_FOCUS,
  PROTOCOL_END_BURST,

};

enum MouseClickProtocol {
  LEFT_CLICK,
  RIGHT_CLICK,
};

class MouseClickPosition {
private:
  MouseClickProtocol m_type;
  int m_x;
  int m_y;
};

Demine sends a PROTOCOL_CAPTURE message with no data and DemineExercizer replies with the same message containing the current upper configuration as a string. The representation used is that of .min files.

 

When Demine has to communicate suggestions to DemineExercizer it sends a PROTOCOL_FOCUS

Messages accepted
PROTOCOL_CAPTURE No data
PROTOCOL_ FOCUS No data
PROTOCOL_CLICK

MouseClickPosition

PROTOCOL_END_BURST No data
message to DemineExercizer (to let it generate a single 'tick' if sound is enabled) and then each suggestion is sent with the PROTOCOL_CLICK message. It contains the position where the click must be issued and which mouse button has to be used; the PROTOCOL_END_BURST message ends the current round of suggestions.

 

Message replied
PROTOCOL_CAPTURE A Demine configuration i.e. the content of a .min file.

That's all: enjoy it !

The program has been developed with C++ Builder 2006 Pro with service pack 1 on Windows XP with service pack 2 using Boost version 1.33.1 (www.boost.org) thanks to the bcbboost project under SourceForge.

 

Gianni Luciani