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 :
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.
currentPos is 0;
Clearly, however, we have no idea of what is going on. We may query TKeden with writeln commands, such as :
currentPos is 1; currentPos is 7; currentPos is 13; . . .
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.