The Beginnings Of A User Interface

With the basic structure of the mineField in place, we can introduce some form of user interface to the system. It is typical that the user may interact with TKeden models in such an early stage of creation, and in fact, allows the user to gain more familiarisation with the concepts and scope of later additions, modifications and improvements to the model.
As we now have a mineField, and have lists containing values to be placed on the minefield, we simply need to define how a potential player might select a cell to try.
For this demonstration, we have decided to use a variable, named currentPos to denote the current position of a conceptual 'pointer' which represents our mineSweeping hero. Due to the way in which the model has been created using lists, we may cross reference each property of any particular cell using the same value. If, for example, currentPos was set to 7, then we can look at the 7th element of the status list to see whether that cell has already been uncovered or not. We can look at the 7th element of the mines list to see whether or not that particular space contains a mine, and may also examine the 7th element of the values list to see the value at that cell.
Therefore, our first step at introducing a player interface to TK-MineSweeper involves the creation of the variable, currentPos as follows :

  currentPos is 0;
Since we do not want a turn to already have been taken before the player even gets the chance to start the game, we set the value of currentPos to 0 to begin with. The user may select cells to 'try' by redefining the variable currentPos in the TKeden Input Window.
A typical player session with TK-MineSweeper in it's current state could be as follows :
  currentPos is 1;
  currentPos is 7;
  currentPos is 13;
Clearly, however, we have no idea of what is going on. We may query TKeden with writeln commands, such as :
This will give us values so we know whether we are on a mine, and what value the current cell is rated at. However, this is not suitable for a real game of mineSweeper, and so, we know that there is much that can be done to further embellish what already exists of the TK-MineSweeper script.
Whilst we have the basic interface, therefore, we need to know what is actually happenning in the game. We cannot play if we don't know that we just a) trod on a mine, b) don't know values at squares and c) cannot tell which squares have been uncovered, etc.
The next step in the creation of TK-MineSweeper will be to create some form of output to inform the user of the state of play at the current time. This is investigated in the next section.

Move to the seventh TK-MineSweeper page...

Updated Wednesday, January 6, 1999