Examples of Mixed Strategy Games
Fall 2006, David Matuszek

In order to test methods, you have to supply problems for which you know the correct answers.

For example, since int largest(int[]) is supposed to return the largest value in an array, it's easy to test with JUnit tests such as:

    public void testLargest1() {
        msg = "Testing with small positive values";
        int[] array1 = {2, 4, 6};
        int[] array2 = {5, 3, 1};
        assertEquals(msg, 6, s.largest(array1));
        assertEquals(msg, 5, s.largest(array2));
    }

To test your Mixed Strategy program, you need some games for which you know the correct answers. Unless you are a game theorist, I need to supply them. So here are a few:

4
-3
-5
12
Best strategy for Max: [0.708, 0.291]
Best strategy for Min: [0.624, 0.375]
2
5
5
2
Best strategy for Max: [0.5, 0.5]
Best strategy for Min: [0.5, 0.5]
-2
3
3
-4
Best strategy for Max: [0.583, 0.417]
Best strategy for Min: [0.583, 0.417]
2
4
6
0
Best strategy for Max: [0.75, 0.25]
Best strategy for Min: [0.5, 0.5]
10
20
35
5
Best strategy for Max: [0.75, 0.25]
Best strategy for Min: [0.375, 0.625]
2
7
6
9
5
1
4
3
8
Best strategy for Max: [0.333, 0.333, 0.332]
Best strategy for Min: [0.333, 0.333, 0.333]
-9
12
-6
7
14
5
10
-8
3
6
17
-10
This array has a saddle point at row 1, column 2
1
2
3
3
2
1

Best strategy for Max: [0.5, 0.5]
Best strategy for Min: [0.5, 0.0, 0.5]

1
3
2
2
3
1
Best strategy for Max: [0.5, 0.0, 0.5]
Best strategy for Min: [0.5, 0.5]
-5
0
5
0
10
-10
2
-2
0
Best strategy for Max: [0.25, 0.125, 0.625]
Best strategy for Min: [0.333, 0.333, 0.333]
-2
-1
0
0
1
2
1
2
-3
-3
2
1
-1
2
0
0
-2
-1
0
3
2
2
1
-2

Best strategy for Max: [0.221, 0.333, 0.0, 0.444]
Best strategy for Min: [0.389, 0.0, 0.277, 0.0, 0.0, 0.333]

This is not a good array to use for JUnit testing, because columns 2 and 3 are identical. You don't care which column the program chooses, so you shouldn't test which one it chooses.

On the other hand, you could make a useful test out of this game by eliminating one of those columns.