Saturday, December 13, 2008

CREATING SPREADSHEET MINEFIELD GAMES

PART ONE

Real minefields are terrible things. Soldiers bury bombs in the ground. Real people, often long after the battles are over, step on the mines. Many are killed or are horribly injured. Mine disposal experts are needed to find and remove mines from the fields.

Can you represent this situation in a spreadsheet?

This will require you to take an Information Technology point of view of minefields. You will need to consider, for example, how information is inputted, stored, processed and outputted, then make a working “model”, bit by bit.
The player’s focus is on the area where his or her “steps” are inputted.
To keep things simple, let’s make this area a 5x5 array of cells and represent the steps as “1’s” placed in cells.







Prior to the start of the game, however, the game master has placed the mines in the field.
Their locations can also be represented as “1’s” placed in another 5x5 grid.













When the positions of steps and mines coincide there will be a terrible interaction.
This can be shown on another 5x5 grid filled with formulae that give a result if there are “1’s” in similar positions in the both of the first two areas.

Spreadsheets allow us to check for special situations with an IF function. If we were using Microsoft Excel, for example, we might place this formula in cell N2

=IF(B2+H2=2,9,” ”)

[If the sum is 2, the cell shows a “9”, if not, the double quotation marks make the cell appear empty.]

We can then use AutoFill to place similar formulae in the rest of this area.

The “9”, in this case, represents an explosion, but not very dramatically. So we can add another IF function formula under the first area to make this event more explicit, for instance:


=IF(Sum(N2:R6)>0, “YOU JUST STEPPED ON A MINE!", “SO FAR, SO GOOD”)

Once you have checked that this is all working the way you expect it to, you can work on how to make bigger minefield areas and how to hide the second and third areas from the players’ sight.

PART TWO

To help them locate and remove mines from minefields, mine disposal experts use mine detectors. These detectors collect harmless but useful information from the areas near mines. We can build on our basic game to represent this.

Let us first provide another 5x5 grid that collects and processes some mathematical information from all parts of the “minefield”.

Each cell in this new grid could contain a formula calculating the sum of the “1’s” in a 3x3 area immediately around each cell in the “minefield”.

In this case, we might place a formula like this in cell H10:

=SUM(G1:I3)

Again, AutoFill can be used to place similar formulae in the rest of this area.


When we walk through a minefield with a mine detector, it only reveals information about the area immediately near us.

Suppose we create another 5x5 area to show this.

Again, another IF function formula will do the trick. For example, in cell B10 , we could place the formula
=IF(B2=1,H10," ")

Then we could use AutoFill to place similar formulas in the rest of this area.
PART THREE

The next step might be to provide a way players can “dispose” of mines.
One way of doing this could be to give them the option of placing another number besides “1” in cells where they guess a “mine” is located.
You could then use IF function formulae to give them feedback about whether their guess was correct.

I will leave that task up to you.

Is there anyone out there ready to take up this challenge?

Tuesday, December 09, 2008

MAKE YOUR OWN SUDOKU





Quite a few people use their spreadsheets to help them solve Sudoku puzzles. Can you use yours to create a new Sudoku puzzle?



First of all, you need to know what you are creating.





(a) Each row lists each of the numbers from 1 to 9 once only

(b) Each column lists each of the numbers from 1 to 9 once only.

(c) The grid contains 9 smaller squares listing the numbers 1 to 9 once.

A fourth rule needs to be stated if you are going to create a "good" puzzle: (d) Apart from rules (a), (b) and (c) above, the numbers should look as if they were randomly distributed.


Simply putting the numbers 1 to 9 in a 9x9 grid to fit these rules may look easy when you start. It gets much harder the further you go. So we have to find a way to work smarter not harder.


Strategy 1. Start with a ready-made puzzle and change the numbers.

Suppose we

1. Made all the 9's into 1's, and added 1 to each of all the other numbers?, OR

2. Made all the 9's into 2's , all the 8's into 1's and added 2 to each of the other numbers? OR

3. Set up a more random pattern of changes, e.g 1=4, 2=7, 3=1, 4=9, 5=3, 6=8, 7=5, 8=2, 9=6?

Spreadsheets can be set up to do these tasks automatically. Hints: Methods 1 and 2 involve nested IF formulae. Method 3 can be done using HLOOKUP or VLOOKUP functions.



Strategy 2. Move whole rows and whole columns in a ready-made Sudoku puzzle.

1. Exchange the positions of the whole first column and the whole second column (TRY IT!)

2. Exchange the positions of the whole last row and the whole third last row.

3. Make the whole first three columns the middle three columns

4. Try moving whole columns or whole rows more randomly.

Any moves like these will not break rule (a) or rule (b) but doing more random moves soon breaks rule (c)



Strategy 3.

1. Create a simple non-random puzzle that obeys rules (a) and (b)




2. Swap around whole rows and whole columns until
(i) Rule (c) is obeyed. and
(ii)Rule (d) (Random appearance) is obeyed.

NOTE FOR TEACHERS AND PARENTS

Obviously the last strategy is the simplest, particularly if you know how to select and move rectangular arrays of numbers in your spreadsheet.


HAVE FUN!