{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture25

# lecture25 - CS 70 Discrete Mathematics for CS Spring 2005...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 70 Discrete Mathematics for CS Spring 2005 Clancy/Wagner Notes 25 Minesweeper Our final application of probability is to Minesweeper. We begin by discussing how to play the game optimally; this is probably infeasible, but a good approximation is to probe the safest squares. This motivates the computation of the probability that each square contains a mine, which is a nice application of what we have learned about both logic and probability. Optimal play in Minesweeper We have seen many cases in Minesweeper where a purely logical analysis is insufficient, because there are situations in which no move is guaranteed safe. Therefore, no Minesweeper program can win 100% of the time. We have measured performance by the proportion of wins as a function of the initial density of mines. Can we find the algorithm that plays better than all others, i.e., has a higher probability of winning? The first step in the argument is to move from algorithms , of which there are infinitely many, to strategies , of which there are only finitely many. Basically, a strategy says what to do at every point in the game. Notice that a strategy is specific to a particular number of mines M and total number of squares N (as well as the shape of the board): Definition 25.1 (Strategy) : A strategy for a Minesweeper game is a tree; each node is labelled with a square to be probed and each branch is labelled with the number of mines discovered to be adjacent to that node. Every node has 9 children with branches labelled 0 , . . ., 8; no node label repeats the label of an ancestor; and the tree is complete with N- M levels. Figure 1 shows an example. Even for fixed N and M , there are a lot of possible strategies: N- M- 1 ∏ i = ( N- i ) 9 i (For N = 6, M = 3, this is 68507889249886074290797726533575766546371837952000000000.) Still, the number is finite. It is easy to see that every (terminating) algorithm for Minesweeper (given fixed N , M , and 1 2 3 4 5 6 7 8 (1,1) (1,2) (2,2) (3,3) (3,3) (3,3) (10,1) (10,1) (10,1) (10,1) Figure 1: First two levels of a Minesweeper strategy. CS 70, Spring 2005, Notes 25 1 board shape) corresponds to exactly one strategy. Furthermore, with every strategy there is an associated probability of winning. Indeed, it is possible to calculate this exactly, but it is probably easier to measure it using repeated trials. Definition 25.2 (Optimality) : A strategy for Minesweeper is optimal if its probability of winning is at OPTIMAL least as high as that of all other strategies. Clearly, there is an optimal strategy for any given N , M , and board shape. Moreover, we can construct an optimal method of play in general (for arbitrary N , M , and board shape): enumerate every strategy for that configuration and play the optimal one. The performance profile of this algorithm will dominate that of any other algorithm....
View Full Document

{[ snackBarMessage ]}

### Page1 / 7

lecture25 - CS 70 Discrete Mathematics for CS Spring 2005...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online