ArticleIt is divided into three parts: 1. The beauty of programming. 2. I wrote an enhanced version of mine clearance with a download link, but there was a bug. 3. restructured the Mine Clearance and addition, with game and SourceProgram. I. Beauty of Programming This is an article I wrote on Renren's Internet a few years ago. I got a very interesting book, the beauty of programming, from my brother. One of the questions about mine clearance is not answered. The original question is as follows:
Problem 1: When 40 mines are not found in this game, the probability of mines in blocks A, B, and C is P (A), P (B ), what is P (c) each ??
Question 2: This game situation has a total of 16*16 = 256 squares, P (A), P (B), P (c) is there a relationship between the size and the total number of mines in the current situation? For example, how does the total number of mines change from 10 to 240? How does the three curves of P (A), P (B), and p (c) change? Will they meet each other?
At first glance, it seems strange that the probability is related to the total number of mines? In his blog, Ren Xiaoyu gave an answer at http://snarc.ia.ac.cn/ren/html/y2010/390.html. However, his derivation process provides a general solution at one time, which is difficult for ordinary people to do so. Therefore, we should first consider it from special circumstances.
In Figure 1 and figure 2, is the probability of P (a) equal? In other words, is the probability of P (a) related to the total number of mines in the bureau? Set the total number of thunder N, the size of the Board is m (here M = 25), the total number of possible layout in the figure is C (M-9, N-1) * C (8, 1, among them, the total number of the layout of a ray is C (M-9, N-1) * C.
So P (A) = (M-9, N-1) * C (1, 1)/[C (M-9, N-1) * C (8, 1)] = 1/8, that is, P () the probability is irrelevant to the total number of mines. Next step.
In Figure 3 and figure 4, is the probability of P (a) equal? In this case, the layout of thunder is divided into two situations. Here M = 30 First, there is a ray in the range of 3*4 in the middle. Second: There are two mines in the range of 3*4 in the middle. Scenario 1: The total number of all la S isC (M-12N-1) * C (4,1)The total number of mines in point A is 0. Scenario 2: The total number of all la S isC (M-12N-2) * C (3,1)*C (3,1)Type, where the total number of mines on point A isM-12,N-2 )*C (1,1)* C (3,1)Type. So P (A) =M-12,N-2 )*C (1,1)* C (3,1)/[C (M-12N-2) * C (3,1)*C (3,1)] From the above formula, we can see that P (a) has a relationship with total number N, which is a curve of P (A) and total number n.
Why is the probability of this time related to the total number of mines?The problem is that the number of mines in the 3*4 square in the middle is uncertain.. According to this idea, the problem is solved.
Ii. enhanced version of Mine Clearance
This program was developed by me when I was a beginner in C language Windows API programming last year. At that time, the instructor Yang lixiang's teaching video was downloaded from the Internet. He learned a lot while reading and writing mine clearance. I recommend that you want to learn C windows programming. Games: In the game, I made some improvements to the original windows mine clearance. Each box contains a maximum of two mines, which gives players a little freshness and fixes the bug of the original windows mine clearance timer. The game can be downloaded at the link in the first line of the Article. However, I am writing a lot of things about this program, and there are a lot of bugs. Then I want to debug it and find it difficult, it has never been taken care of, and is not provided hereSource code. Iii. Mine clearance ++ Debugging is better than refactoring. Mine clearance ++ is a game I recently wrote. It is much better than the previous version, and the gameplay is completely different from Windows mine clearance. The game is a bit like the reverse thinking process of mine clearance. The game description is as follows: 1. Click any square to change it to a mine. 2. Each letter represents a number. When this number is equal to the surrounding thunder number, the letter is displayed in color. 3. Random Distribution of all mines. a random number is displayed on the square of a mine. 4. Victory condition: the remaining number of mines = 0, and all letters are in color. You need to figure out the numbers represented by each letter and find all mines with the least number of steps. Although the sparrow is small, it is tricky to download the game and the source program in the first line of the article, compiled by vs2005. Games: