Chinese chess software production Thoughts

Source: Internet
Author: User

When I was a child, I learned to play chess with my grandfather in year 45. When I was in high school, I could go to my grandfather. I felt very proud. I said my grandfather was old and had a bad brain... Just like the software I wrote now, it took me a month to write it. Now I am not a competitor at all. I often follow it with me, you can all know what to do next and feel that you have a great advantage, but no matter how hard you work, you cannot turn the advantage into a victory! My last attack at was broken down, and I lost the whole game! I am definitely a newbie in machine games, but I am not very amateur at the chess level. As a result, I lost my work. Program I was wondering if the top players of all mankind would be able to make software that challenges the invincible nature of all mankind? Terrible. All Smart behaviors of people are game actions! Let's talk about the experience of machine competitions. If you are interested, you can discuss it together. Source code But it's hard to explain it to you. It's not too difficult, but too messy. Haha! A complete program should include: the representation of the situation. Because of the huge amount of computing, a one-dimensional array is required. If two-dimensional data is used, the computing time is almost square times! The expression of the pawnpiece indicates that the integer type is used for speed. It took me about ten days to speed up the computation. This is a headache! There is also a two-dimensional array used to associate the positions of the red and black chess pieces in a situation. This will save a lot of time in the process of generation, which is not used in my program. Currently, my program only finds the sixth layer, that is, the depth. For Layer 7, it takes more than 40 seconds to perform an operation. This is intolerable! Then, you can generate the number of sub-accounts by means of the following steps: first, find a sub-account and generate all the sub-accounts that comply with the rules based on the sub-account type. Then there is the search engine, which is a historical-inspired Alpha Beta Search Han number. The basic idea is to try all the items that can go, and then let the other party go all the way, in this way, we will push back from the bottom layer, and then select the most favorable steps for the program, when the other party leaves, the other party will definitely choose the most unfavorable route for the program. In this way, it will find the best route for sending and then let the program go through this route. For example: for example, when the program starts, the program uses a red child, and there are forty-five sending methods, one of which is taken from the program, and the other is allowed to go all the way. On average, there are also more than 40 types, in this way, when the program takes a step, the opponent may take a 40-plus 40 chances. This is the so-called depth of 2. The depth of 3 means that when the opponent takes a step, let the program take a step, in this way, the greater the depth of the three, there will be 40 multiplied by 40 to 40 or equal to 64000 possibilities. For the fourth, there will be 2560000 possibilities. The exponential growth is terrible, and no one except God can catch up with it, that's why we talk about efficiency everywhere when doing this kind of program! Back to the original example, The last step is to let the program select the best situation from these 2560000 possibilities. How should we choose? How to let the program know which situation is good for itself? This is the meaning of situation evaluation. A good evaluation meaning can avoid a large number of fearless searches, thus saving time. Let's look back at how Alpha Beta accelerates the search. We know that the soldiers crossing the river are more expensive than the soldiers crossing the river. When the first soldiers are more expensive than the edge soldiers, the soldiers in the center of the 9th palace are even more expensive than a horse, in this way, each piece will have an absolute position-related value, called the sub-force value. My program directly copies the sub-force value table of open-source image-eye software, of course, there are still many factors that determine the quality of a situation. I didn't do research. I handed this task over to the search engine. Let's go back and talk about searching, if the search depth is 8, how many possibilities are there? 6553600000000! It takes a long time for such an astronomical number to evaluate the computer quality quickly. If we can evaluate the quality of 0.5 million cases in one second, it will take about 207813 years to evaluate these situations, at that time, you became a fossil! What should I do? Pruning! Many of these situations do not need to be evaluated for good or bad. For example, if the other party is a general, we do not need to consider how to proceed with irrelevant pawns, you don't have to worry about all the outgoing mails that are extended by those irrelevant ones, because if you choose them, the other party will eat your hair and you will get down! That is to say, we can only know how bad it is to go. There is no need to know how bad it is! This is Alpha Beta pruning, and we don't have to consider situations that are already bad enough. But there is a problem. If we have considered all the situations before we start pruning, it will be meaningless! Because we have spent a lot of time thinking about all the situations, but if we can cut out a lot of unnecessary situations and save a lot of time if we can just search for them! This means that the sorting of the situations to be searched is the key. How can we sort them? Sort by what? Historical inspiration! Some of the better ones are often better (bad for the opponent), and we will search for them as early as possible for pruning, if a person is found multiple times and thinks it is a good method, he will be searched first. This is the so-called historical inspiration! In general, there are so many things, but this is not enough. There are still a lot of details. This is just a framework. For example, when the generals are there, you will think a few more steps to see if they will die, that is, the depth should be added on the basis of the original, that is, the extension of the general, and the extension of the sub-system, that is, the extension of the sub-system, and the detection of duplicates, many of them appear in the query environment. We don't have to consider them all, and we need to implement time control through iteration! I took the test and thought it was almost a tutorial! If you are interested in this aspect, add my qq377693703 to study together.

 

 

Software: http://files.cnblogs.com/lipf/%E4%B8%AD%E5%9B%BD%E8%B1%A1%E6%A3%8B.zip

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.