The key to any type of chess game is to determine whether the current Board has a correct score. The more accurate the score, the higher the computer's AI. This is also true for wuziqi games, but before scoring, we should first scan Fill in the gstyle array (2, 15, 15, 8, 2) for each blank board in eight directions. When the first subscript is 1, it indicates black, 2 indicates white chess, second and third The subscript represents (x, y), and the fourth subscript represents eight directions. When the last subscript is 1, it represents the number of pawns. If it is 2, it represents the number of spaces, for example:Gstyle (1st, 1) = 3 indicates that the number of black chess pieces adjacent to the coordinate () in the direction is 3 Gstyle (1st, 2) = 4 indicates the number of spaces closest to the coordinate () in the direction is 4 When defining the direction, you should also pay attention to some tips, indicating that the number of two opposite directions should be 4 different, which is defined in the program as follows: Const dir_up = 1 Const dir_upright = 2 Const dir_right = 3 Const dir_rightdown = 4 Const dir_down = 5 Const dir_downleft = 6 Const dir_left = 7 Const dir_leftup = 8 In this way, we can add four in the first four directions to get the value in the other direction. If you still don't quite understand it, see the following figure: --------- --------- --- Oo ---- -Ox * XX --- --------- --------- The * point in the figure is marked as (4, 4), (the position of the * is blank), then: Gstyle (, 1) = 1 The number of white games at the top of the adjacent vertex () is 1. Gstyle (, 2) = 2 the number of spaces closest to the top of the vertex () is 2 Gstyle (, 1) = 2 the number of black games on the right adjacent to () is 2. Gstyle (, 2) = 1 the number of spaces closest to the right of the right side of the vertex () is 3 ... Once all the chess values of the blank points are filled out, we can easily obtain the value of the point (4, 4) in the horizontal direction of the black game, from a punch 1 (I call the bounded chess game a punch) and active 2 (Unbounded Called active. The value of the point (4, 4) in the vertical direction of the game is a living 1, while the point in the/direction is also a living 1. Therefore, as long as we calculate the value of this point for the black game and the white game Then, we will take the sum of the two values of the empty points on the board as the playing point. However, what values should we take for various chess models? We can first make the following assumptions: FN indicates the active Chess Model of the First n pawns. For example, F4. FN 'indicates the playing style of the First n pawns. For example, f4' indicates the playing style of the First n pawns. Ln indicates the active Chess Model of the N pawns of the postmaster. For example, L3 indicates the active three of the postmaster. Ln 'indicates the playing style of N pawns in the backend, for example: L3' indicates playing three . . . Based on the chess analysis in a row, the following relationship is obtained: L1 '<= F1' <L2 '<= f2' <= L1 <F1 <L2 <F2 <L3' <= F3 '<L4' <F4 '= F4 This relationship includes the relationship between attack and defense (of course, this relationship is determined by me and you can define these relationships by yourself ). Further refine these relationships, as shown in the following code: There are three active players in the four directions of the Game point, which is not comparable to a single dash, so we can get another relationship of 4 * F3 <L4 '. Similarly, we can also obtain other relationships, such as: 4 * F2 <L3, 4 * L3 <F3 ..., these relationships may be different because of your method and my method. In this way, the computer AI is different. Finally, we set the value of L1 with the minimum score to 1. The score of the following chess models is represented by the C language: F [2] [5] = {16000, 30,750,160 }}; L [2] [5] = {3750, 30,150,400,}, {, 0 }}; The F array indicates the first hand. When the first subscript is 0, it indicates the impulse. The second subscript indicates the number of chess pieces. Then, the F2 'corresponds to f [0] [2] l array to indicate the second hand, when the first subscript is 0, it indicates the charge type, and the second The subscripts indicate the number of pawns. Then L2 corresponds to f [1] [2] OK. After the score relationship of the chess model is determined, we add the chess values in the four directions of each vertex (including the points of the first hand and the second hand ). Value), finally select a maximum value, and take this point as the point of the computer to go down on OK :). After that: 1. The maximum value may be more than one vertex, but only the first largest vertex can be selected in my program. Of course, you can use a random number to determine the maximum value. You can select the maximum value for further analysis. 2. In this algorithm, I only considered the points of pawns, but I did not consider other points. 3. You can go further. Use this algorithm to predict the next few moves, and then select the best predicted step. In this way, the computer AI will be higher. 4. This algorithm does not take into account the banned players of black games (double 3, double 4, and more than five players ). Because I usually do not have these five games. Banned. |