The thought of Chess Man-machine program

Source: Internet
Author: User

Computer and player chess, go, Gobang, Dou Landlord, Three Kingdoms kill and so on, we call it human-machine game. The following is an example of chess, talking about the basic idea of human-machine game procedure.

This kind of chess procedure mainly involves 3 aspects, namely the walk method generation, the valuation algorithm and the search technology.

<ignore_js_op>


The way to go is to walk through all the feasible methods of the current situation.

<ignore_js_op>


The procedure above describes the method of red stroke. As long as the walk of each of the pieces of the method, through the addmove added to the list, walk the table formed.

<ignore_js_op>

<ignore_js_op>

<ignore_js_op>


Understand that after the introduction of the method, it is necessary to introduce the valuation algorithm, in short, to evaluate a situation good or bad algorithm. Here are three methods of evaluation, one is to calculate the value of the pieces, the other is to calculate the flexibility of the pieces (the pieces are not blocked), the third is to calculate the relationship between the pieces (there is no threat to the other pieces), the combination of these methods, you can obtain a better valuation results.

<ignore_js_op>

<ignore_js_op>

<ignore_js_op>

<ignore_js_op>

<ignore_js_op>

<ignore_js_op>


With a walk-through generation and valuation, you can produce a game tree, and then you'll learn how to find the best way to go.

<ignore_js_op>

<ignore_js_op>


You can use the following figure to explain the minimax algorithm, which is a two-tier game tree, and C1 's valuation is 8,C2 's valuation is 10. If the program is popular, now in the B1 situation, turn black play chess, the worst case is black to go to C1 situation, because this time the situation on the red side of the lowest valuation. So B1 's valuation is the C1,C2,C3 minimum, which is 8,b2 and B3, and the estimates are 5 and 10, respectively. If now in situation a, turn red side go, that nature to take one step to oneself most advantageous, so chose B3.

<ignore_js_op>

<ignore_js_op>


As shown, when the program is calculated to C4, the C4 is 7, because B2 takes the lowest value of the node below, so B2 <= 7, and B1 = 8, so in a situation to b1,b2,b3 situation selection, it is impossible to choose B2. At this time C5 and C6 can not calculate, direct discard, a bit like the leaves of a tree, called pruning, which is a search algorithm optimization.

<ignore_js_op>


Finished, understand this idea, you will also understand the Gobang, go, Dou landlords, Three Kingdoms kill and so on human machine game program thinking.

<ignore_js_op>

The thought of Chess Man-machine program

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.