Automatic Mine clearance-Preface

Source: Internet
Author: User

A few years ago, I used C # As a plug-in for the Clearance game under the XP system. At that time, I had limited capabilities,ProgramThe framework is not good enough, and the functions are not perfect. Now I use C ++ to write a Win32 automatic mineterminator, which is now compiled into a blog post.

It will be divided into the following explanations:

Automatic Mine clearance-game framework

Automatic Mine clearance-Determination Analysis

Automatic Mine clearance-mathematical Implementation of Probability Analysis

Automatic Mine clearance-Program Implementation of Probability Analysis

When it comes to automatic games, you can use a program to automatically play a game. This involves three parts: Getting game data, analyzing data, Getting useful data, and controlling the game.

In mineterminator, game data is obtained by analyzing the pixel information of the game window. Instead, sendmessage is used to send a key message to the game window. The difficulty is to analyze the game data: The following describes how to use the beauty of mathematics to successfully solve the problem.

First, we will analyze the situations that can exist in mine clearance and summarize four different models:

    • First and second Models

Analyze 2 in the upper-right corner, the unknown blocks A and B are equal to the number of mines around them, so we can determine that A and B are thunder. Next, analyze the 2 below, there are a total of three undisplayed blocks A, B, and C. Among them, A and B have determined that they are mines, that is, when the number of mines that have been judged around is equal to the number of mines, it can be determined that the remaining block is not a Ray, that is, the C block is not a ray.

One of these two models is to determine the thunder, and the other is to determine whether there is no thunder. This is a method that people on earth know about mine clearance. The following model may only be available to mine clearance experts or mathematical experts ~~

    • Third Model

Let me make a bold judgment first. Block C has no thunder !! Let me hear it over again ~

The following formula is available for two blocks that are displayed as 1:

A + B = 1 (1)

D + E = 1 (2)

It indicates that there is only one ray in A and B, and D and E have only one ray,

Based on the two displayed blocks, you can get:

A + B + C + D + E = 2 (3)

Indicates that there are only two mines in ABCDE.

According to (1) (3 ),

C + D + E = 1 (4)

According to (2) (4), c = 0, so Block C must be mine-free and can be opened with confidence.

This model can be said to be the most sophisticated and seemingly unidentifiable situation in mine clearance. Through such calculations, we can determine where the mine is or where the mine is not.

    • Fourth Model

The above three models all fall into the scope of deterministic judgment, and often encounter dead ends that cannot be determined during mine clearance. Then we need to use the mathematical tool-probability for optimal judgment.

It is easy to calculate the probability of thunder around 3: 3/8 (this is relatively simple ). Let's look at the figure below.

When two blocks with a distance of less than or equal to 2 are opened, the probability of thunder surrounding them is not so easy to judge (A, B, c. What is the probability of thunder. The last question in the beauty of programming is this question. Three years ago, I had been thinking about how to calculate this probability and how to implement it using a program. Now I finally want to understand it ~~~

Preface write this article first, and you will be looking forward to it later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.