Definition Of The Play Area

The MineField

Before we have anything on which to work, we must have an actual mineField upon which to place out characteristics, definitions and values. Using Empirical Modelling as our means, a good approach here could be to keep it simple, and define the 'mineField' itself as a list of cells representing some X x Y board.
As we are creating quite a small initial model of the mineSweeper model, a suitable approach for such a game is a 4 x 4 playing area. Clearly, 3 x 3 is too small, and 5 x 5 and above start to increase the size of the modelling task beyond what is required to create a model that can cater for any sized board.
So, we may visualise a 4 x 4 mineField as being represented by a 16-element list in TKeden. In this fashion, when X=1 and Y=1, the cell number is mineField[1]. Similarly, where X=3 and Y=2, we refer to mineField[((Y-1) x 4) + X], or minefield[7].
Begin a TKeden session, then type or copy & paste the following definition into the TKeden Input Window and select Accept :

        mineField is [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14
          , p15, p16];
Whilst no discernable output appears, we may interrogate TKeden using the ? operator typed into the TKeden Input Window thus :
        ? mineField
This query provides output on the xterm window used to start up TKeden concerning the variable, mineField.

MineField Characteristics

With the mineField defined, it is useful to define a few characteristics which may be required after further additions are included to TK-MineSweeper. We can define the dimensions of the board, and the number of cells, easily, using a number of variables.
We may define the number of cells the board possesses as being the number of elements in the list, mineField. This can be achieved simply by using the TKeden operator, # as follows :

        nCells is mineField#;
Here, the # operator returns the number of elements of the list, mineField, and stores it as nCells.
In terms of the actual dimension of the board, as desired to be perceived by the users, we may define two variables, xDim & yDim which respectively define the X & Y dimensions of the board. This is achieved simply thus :
        xDim is 4;
        yDim is 4;
We may check the correctness of our current definitions by using writeln() statements from the TKeden Input Window as follows :
        writeln("xDim=", xDim, " yDim=", yDim, " nCells=, "nCells");
In the current specification, xDim and yDim should both be 4, and nCells should be 16.
With the very basic board itself, and it's characteristics interms of appearence and shape set out, we may delve into more complex issues. The next page in this demonstration of TK-MineSweeper looks at developing the characteristics of our mineField to cohere more readily to the mineField in MineSweeper games we have played before.

Move to the third TK-MineSweeper page...

Updated Wednesday, January 6, 1999