Intelligent battle learning sample automatic generation method and device
Through the automatic generation method of intelligent battle learning samples, self-playing chess and cross-entropy loss functions are used to optimize the neural network, which solves the problem of difficulty in quickly generating high-quality learning samples in the existing technology, and achieves efficient learning sample generation and AI player training. .
Patent Information
- Application Number
- CN202410726325.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-09-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technology is difficult to quickly generate high-quality learning samples, especially in chess games with high complexity of chess rules, resulting in limited training effects for artificial intelligence players, high hardware environment costs, and the inability of algorithms such as Monte Carlo simulation to Quickly generate large amounts of learning samples.
Using the method of automatic generation of intelligent battle learning samples, by setting both sides to use the same neural network model, they play chess in a self-playing manner, record the steps and weight information of the chess playing, and use the cross-entropy loss function to optimize the neural network, so that both sides can learn from each other and reduce the cost of analysis. Time and space complexity.
It effectively reduces the time and space complexity of learning sample generation, improves computing power and memory usage efficiency, and generates high-quality learning samples, which is suitable for training excellent AI players.
Smart Images

Figure CN118674045A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method and device for automatically generating intelligent combat learning samples. Background Art
[0002] Computer chess games have always attracted extensive attention from researchers in the field of artificial intelligence. Training AI players to defeat human players is the direction everyone pursues. In-depth research on methods for training AI players will help researchers to have a deeper understanding of related issues in machine intelligence. It is worth noting that it is completely reasonable to use deep neural networks as a carrier of knowledge. Under the premise that it is impossible to enumerate all chess game states, a large number of data sets can be obtained by using self-play chess game learning sample generators to provide strong support for training AI players. It is achievable to eventually obtain better AI players by learning how to play chess games.
[0003] Classic representatives of research on computer chess games include Chinook, Deep Blue, and AlphaZero. The Chinook program, based on the prior knowledge of multiple human experts, analyzes every possible chess game as much as possible, and learns and judges the best moves involving about 500 trillion combinations; Deep Blue's design highlights are mainly in hardware design, combining α-β pruning and MCTS algorithm, and using specially customized registers to greatly improve the speed of searching the chessboard situation; AlphaZero proposed the design concept of self-playing, which can master a variety of chess games from scratch only through self-playing learning, by using the Monte Carlo search algorithm for self-playing, and using the data set generated by self-playing to continuously train the neural network, without any human guidance except the rules of playing chess in the whole process.
[0004] It should be noted that the current research on intelligent chess games focuses on the outcome of the game between AI players and human players, but rarely focuses on the generation and quality of learning samples, which makes it difficult to generate a large number of high-quality learning samples within a certain period of time. Especially for chess games with complex chess rules, the hardware environment required for learning samples is expensive and difficult to obtain, and it is difficult to pay enough attention to algorithms such as Monte Carlo simulation, which are already quite mature. Although the corresponding results can be obtained within a limited period of time, it is still impossible to quickly generate a large number of learning samples, which will affect the training of AI players' chess playing level to some extent.
[0005] At present, the common learning sample generation methods are mainly divided into three categories:
[0006] (1) Based on the existing chess games and expert knowledge base, learning samples are generated by manual intervention. The advantage of this generation method is that the chess games are known and the learning objectives are very clear, but the acquisition cost is extremely high and the coverage of learning samples cannot be guaranteed.
[0007] (2) Learning samples are obtained based on the genetic variation evolution method of multi-player games. There is no human intervention in the whole process, and learning optimization needs to be carried out after the game is completely finished. This method is the survival of the fittest, and the best players are selected from the group, but it needs to be supported by effective organizational methods to ensure the participation of the group. Any external factors may affect the training results.
[0008] (3) The learning samples are obtained by self-playing games and Monte Carlo simulation. There is no human intervention in the whole process. Playing chess and training AI players are carried out simultaneously. The cost is low and easy to implement in the whole learning process. The coverage rate of chess games is high and each chess game can be completely saved. However, the intelligence comes from itself, and the training effect of AI players will be limited by themselves. Summary of the invention
[0009] In order to reduce the time and space complexity of the learning sample generation method, the present invention provides a method and device for automatically generating intelligent combat learning samples.
[0010] In one aspect, the present invention provides a method for automatically generating intelligent combat learning samples, comprising:
[0011] Step 1: Set the two players to use the same neural network model;
[0012] Step 2: Perform the first optimization on both sides to obtain the initial weight information; the first optimization process specifically includes: 1 In each game, both sides first randomly initialize their weights as the initial weights and then play chess against each other. The chess steps, weight information of both sides and win / loss results in each game are recorded as learning samples and stored in the first learning sample set. When the set number of self-playing games N is completed, 1 After that, both sides select their own winning m from the first learning sample set 1 The chess piece randomly selects one from the chess games, and uses the weight information corresponding to the selected chess game as its own initial weight information;
[0013] Step 3: Perform subsequent optimization iterations on both parties until the set number of iterations N is reached; wherein each optimization process specifically includes: 2In each game, both sides use the final weight information after the last optimization as the initial weight to play chess against each other again, and record the chess playing steps, weight information of both sides and winning and losing results in each game as learning samples and store them in the second learning sample set; when the set number of self-playing chess games N is completed 2 Then, all the winners of both parties are selected from the second learning sample set. 2 The learning samples of the two sub-groups are stored in the third learning sample set; the third learning sample set is used to enable the two parties to learn from each other, and the final weight information of the two parties after this optimization is obtained; wherein, m 2 <m 1 .
[0014] Furthermore, the method further comprises:
[0015] Step 4: When the set number of iterations N is reached, the weight information of the last optimization is used as the optimal weight. If the winning rate of the party with the optimal weight against the other party with the randomly initialized weight reaches the set threshold, the game ends. Otherwise, the N value is reset to 2 and returns to step 3.
[0016] Furthermore, the process of playing chess by itself includes:
[0017] Step A1: Determine whether the current chess game state has been decided;
[0018] If the winner is not decided and the player is the one who is going to make the next move, then all the possible moves are listed and used as the input values of the neural network to calculate the score of each move. The move with the largest score is selected as the next move state of the player. The current state of the game is saved as a new root node.
[0019] If the winner is not decided and the opponent is the current player, then all the moves that the opponent can choose are listed, and all the moves are used as input values of the opponent's neural network in turn to calculate the score of each move, and the move with the smallest score is selected as the opponent's next move state; and the chess game state at this time is saved as a new root node;
[0020] Step A2: Repeat step A1 until the winner is determined.
[0021] Furthermore, the third learning sample set is used to enable both parties to learn from each other, and the final weight information of both parties after this optimization is obtained, which specifically includes:
[0022] Assume that in the third learning sample set, the team wins m 2 The number of learning samples is M, and the M learning samples are divided into m small training sets;
[0023] For each small training set, the chess steps of each learning sample are obtained in turn. Starting from the first step of the chess game, the chess game state faced by the opponent in this step is used as the input value of the opponent's neural network to calculate the original score. Then, the chess game state and weight information of the next step of the player are used as the input value of the opponent's neural network to calculate the target score. This process is repeated to complete the learning of all chess game states, and the opponent's neural network is optimized in combination with the Adam optimization algorithm.
[0024] After all the small training sets are learned, the weight information finally optimized by the other party is used as the final weight information after this optimization;
[0025] According to the above optimization process of the other party's neural network, optimize your own neural network to obtain your final weight information after this optimization.
[0026] Furthermore, in the process of using the third learning sample set to enable the two parties to learn from each other, the loss is calculated based on the original score and the target score using a cross entropy loss function.
[0027] Furthermore, the neural network model adopts a seven-layer fully connected neural network.
[0028] In another aspect, the present invention provides a device for automatically generating intelligent battle learning samples, comprising:
[0029] The two players build an optimization module to set the two players to use the same neural network model;
[0030] The first optimization module is used to perform the first optimization on both sides to obtain initial weight information; the first optimization process specifically includes: 1 In each game, both sides first randomly initialize their weights as the initial weights and then play chess against each other. The chess steps, weight information of both sides and win / loss results in each game are recorded as learning samples and stored in the first learning sample set. When the set number of self-playing games N is completed, 1 After that, both sides select their own winning m from the first learning sample set 1 The chess piece randomly selects one from the chess games, and uses the weight information corresponding to the selected chess game as its own initial weight information;
[0031] The second optimization module is used to perform subsequent optimization iterations on both parties until a set number of iterations is reached; wherein each optimization process specifically includes: after a set number of self-playing games N 2 In each game, both sides use the final weight information after the last optimization as the initial weight to play chess against each other again, and record the chess playing steps, weight information of both sides and winning and losing results in each game as learning samples and store them in the second learning sample set; when the set number of self-playing chess games N is completed2 Then, all the winners of both parties are selected from the second learning sample set. 2 The learning samples of the two sub-groups are stored in the third learning sample set; the third learning sample set is used to enable the two parties to learn from each other, and the final weight information of the two parties after this optimization is obtained; wherein, m 2 <m 1 .
[0032] Further, including:
[0033] The test module is used to use the weight information of the last optimization completed as the optimal weight after reaching the set number of iterations, and to determine whether the winning rate of the party with the optimal weight playing against the other party with the randomly initialized weight reaches the set threshold.
[0034] Beneficial effects of the present invention:
[0035] In the process of collecting learning samples, the two players play against each other and collect learning samples at the same time. The next move is determined only by scoring the chessboard, which greatly reduces the analysis time and space complexity, and the requirements for computing power and memory usage. At the same time, by letting the black and white sides learn from each other and iteratively optimize the chess strength of each player, the weight information of the finally optimized white player (that is, the player on our side) is saved and regarded as a relatively excellent AI player. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 The initial board for checkers;
[0037] Figure 2 One of the flow charts of the method for automatically generating intelligent battle learning samples provided by an embodiment of the present invention;
[0038] Figure 3 A second flow chart of the method for automatically generating intelligent battle learning samples provided by an embodiment of the present invention;
[0039] Figure 4 A schematic diagram of a branch of a checkers game tree provided by an embodiment of the present invention;
[0040] Figure 5 A schematic diagram of a self-playing chess process provided by an embodiment of the present invention;
[0041] Figure 6 A schematic diagram of the black square neural network optimization process provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] The present invention takes checkers as an example to illustrate the automatic generation method of learning samples. Before introducing the method of the present invention, the rules of checkers are briefly introduced.
[0044] Checkers is a board game with relatively complex rules. Figure 1 This is the initial state of the chessboard. There are black and white squares on the chessboard (chess pieces can only be placed on white squares). The two players each hold 12 chess pieces occupying the upper and lower sides of the chessboard.
[0045] The present invention stipulates that the white chess piece is the first mover, and the two sides take turns to play chess. During the process of playing chess, the ordinary chess pieces of the moving side can only play chess in a diagonal manner towards the blank space in the direction of the opponent. When reaching the opponent's bottom line, the chess piece can become a king chess piece, and the chess piece after becoming the king can capture chess pieces in four diagonal directions. Until all the chess pieces of any side are eaten, the side without chess pieces is determined to be the loser; when both sides are unable to move, the side with more remaining chess pieces is determined to be the winner according to the number of remaining chess pieces of the black and white sides at the end of the game, and if the number of remaining chess pieces is the same, it is determined that the two sides are tied.
[0046] In the present invention, the learning sample generation method and device refers to using a self-playing chess method to let the black and white sides play chess, saving the chess steps, weight information of both sides and the winning and losing results of each game as learning samples, and obtaining an excellent AI player by continuously optimizing the deep neural network.
[0047] Example 1
[0048] like Figure 2 As shown, an embodiment of the present invention provides a method for automatically generating intelligent combat learning samples, comprising the following steps:
[0049] S101: setting the two players to use the same neural network model;
[0050] Specifically, in this embodiment, both neural network models use a seven-layer fully connected neural network, where the input layer (indicating the state of the chessboard) has 64 nodes, each hidden layer has 30 nodes, and the output layer (indicating the score of the chess game) has only one node.
[0051] S102: Perform the first optimization on both parties to obtain initial weight information; the first optimization process specifically includes: 1 In each game, both sides first randomly initialize their weights as the initial weights and then play chess against each other. The chess steps, weight information of both sides and win / loss results in each game are recorded as learning samples and stored in the first learning sample set. When the set number of self-playing games N is completed, 1 After that, both sides select their own winning m from the first learning sample set 1 The chess piece randomly selects one from the chess games, and uses the weight information corresponding to the selected chess game as its own initial weight information;
[0052] Specifically, during the first optimization, since neither the black nor the white side has a trained neural network, the weights must be randomly initialized (the initialization value range is [-1,1]) before each game.
[0053] In addition, the checkers board interface is concise and clear at a glance. All square states can be stored in a two-dimensional array to represent the board information, that is, an 8×8 two-dimensional array is defined, where the array elements are composed of {-5, -1, 0, 1, 5}, black square positions and no chess pieces are represented by 0, and the positive and negative signs are used to distinguish between black and white. Black is a negative number (-5 represents black king chess, -1 represents ordinary black chess), and white is a positive number (5 represents white king chess, 1 represents ordinary white chess). In this embodiment, N 1 =1000, m 1 =6.
[0054] S103: Perform subsequent optimization iterations on both parties until a set number of iterations N is reached; wherein each optimization process specifically includes: 2 In each game, both sides use the final weight information after the last optimization as the initial weight to play chess against each other again, and record the chess playing steps, weight information of both sides and winning and losing results in each game as learning samples and store them in the second learning sample set; when the set number of self-playing chess games N is completed 2 Then, all the winners of both parties are selected from the second learning sample set. 2 The learning samples of the child are stored in the third learning sample set; the third learning sample set is used to make the two parties learn from each other, and the final weight information of the two parties after this optimization is obtained; in this embodiment, N 2 =5000, m 2 =3.
[0055] Specifically, during the entire learning sample generation process, the number of optimization iterations N is set to 100,000 times (experimental results show that even if the Adam optimization algorithm is used to adjust the neural network weight information, more optimization times will result in overfitting).
[0056] In addition, the third learning sample set is used to make the two parties learn from each other, and the final weight information of the two parties after this optimization is obtained, including: first, let the other party (set as black) according to all the wins of the own party (set as white) 2 The learning samples of the child are trained to obtain the final weight information of the opponent's optimization; then let the player select the best weight according to all the winning numbers of the opponent. 2 The learning samples of the child are used for training to obtain the final weight information after this optimization.
[0057] Example 2
[0058] Based on the above embodiments, Figure 3 As shown, in order to ensure that the performance of the final AI player meets the given requirements, the method for generating intelligent battle learning samples provided by the embodiment of the present invention also includes the following steps:
[0059] S104: When the set number of iterations N is reached, the weight information of the last optimization is used as the optimal weight. If the winning rate of the party with the optimal weight against the other party with the randomly initialized weight reaches the set threshold, the process ends. Otherwise, the N value is reset to 2 and returns to step S103.
[0060] Specifically, since the white side is used as the self-side in the embodiment of the present invention, the white side with the optimal weight is used to play against the black side with a random initial weight. It is assumed that a total of 2000 games are played, and the weight of the black side is randomly initialized in each game. After the end, the winning rate of the white side in 2000 games is counted. If it exceeds 75%, it is considered that the optimal weight of the white side obtained at this time meets the requirements, and the training is terminated. Otherwise, N=0 is initialized, and the iterative optimization is continued until the winning rate reaches 75%.
[0061] Example 3
[0062] On the basis of the above-mentioned embodiments, in the embodiment of the present invention, a game tree is used as a recording medium for chess move information, that is, a huge game tree is generated during the chess game process to record chess move information.
[0063] Furthermore, the self-playing chess in the embodiment of the present invention needs to be combined with the Minimax algorithm to determine the way of moving the pieces only by scoring the chess surface.
[0064] The Minimax algorithm, also known as the minimax algorithm, is an algorithm that finds the minimum value in the maximum probability of failure. That is, one party must find the option that maximizes its own advantage among the available options, and the other party chooses the method that minimizes the opponent's advantage. The Minimax algorithm assumes that the opponent has perfect decision-making ability, so the essence of the algorithm is that we should choose the best of the worst cases that the opponent can achieve. In other words, under the opponent's perfect decision, the loss to us is minimized. In short, we have to choose the best in the worst case.
[0065] Since the entire checkers game tree is too large and it is impossible to enumerate all the game states in a short period of time, only a small section of the branches is selected as an example to explain the Minimax algorithm. Suppose it is our turn (white) to play chess now. We need to select one from all the selectable games as the next game state. The basis for selection is to find the one with the largest game score among all the selectable games. The game score is to use each selectable game state as the neural network input value, and calculate several scores through the current white neural network. Similarly, if the opponent (black) is playing chess now, the opponent needs to select a game with the smallest score from all the current selectable games as the next game state. According to the above description, draw the chess process of a certain branch of checkers, such as Figure 4 As shown. Among them, Figure 4 A square node indicates that our side (white side) is playing chess, while a triangular node indicates that the opponent side (black side) is playing chess. The node when it is our turn to play chess is called a MAX node, and the node when it is the opponent's turn to play chess is called a MIN node.
[0066] Based on the above, if Figure 5 As shown, the self-playing chess process in the embodiment of the present invention specifically includes the following steps:
[0067] Obtain the weight information of both parties so that both parties can play chess according to the weight information and the current chess game status;
[0068] Determine whether the current chess game information has been decided. If not, determine whether the player to play the current chess game is the white player. If so, list all the available moves for the white player and save all the available chess game information as input values for the white neural network in turn. Calculate and save the score of each chess game state. Combined with the maximum and minimum algorithm, select the chess game with the largest score as the next chess game state for the white player. At the same time, treat the chess game as a new root node and save it, thereby completing the collection of chess game steps.
[0069] On the contrary, if the player to play the chess at the current step is the black player and the winner has not been decided yet, then all the chess game information that the black player can choose will be saved and used as the input values of the black player's neural network in turn. The chess game state with the smallest score will be selected as the black player's next chess move state, and the chess game will be regarded as the new root node and saved, thereby completing the collection of chess steps.
[0070] When the black side wins and loses, the final win and loss result is saved together with all the above chess steps into a file as a new round of learning samples. The above is a complete game of self-playing chess.
[0071] Example 4
[0072] On the basis of the above embodiments, in order to speed up the neural network training, in the process of using the third learning sample set to make both parties learn from each other, a small batch gradient descent algorithm combined with the Adam optimization algorithm is used to optimize the neural networks of both parties. This embodiment only takes the optimization of the black party neural network as an example to describe the optimization process in detail. Figure 6 As shown, the specific process is as follows:
[0073] Get the training set, that is, all the learning samples of the white side winning 3 pieces. Assume that there are M learning samples in total.
[0074] The obtained training set is split into m smaller training sets (hereinafter referred to as mini-batches), where Use m_count to represent a round in the process of mini-batch gradient descent algorithm. Initialize it to 0 and initialize V db 、V dw , S db , S dw The value of the parameter is 0; only when the value of m_count exceeds m, it is equivalent to a round of processing of the entire training set (no less than m times of gradient approximation) is completed. Figure 2 As long as the value of m_count is less than or equal to m, the following steps must be completed:
[0075] (1) Take the next white chess game state in the current mini-batch as the input value and calculate the target value (using y) through the neural network. ∧ express);
[0076] (2) The current black chess game state is used as the input value and the original value (represented by y) is calculated through the neural network;
[0077] (3) With the help of J(w,b)=-(ylogy ∧ +(1-y)log(1-y ∧))Calculation formula to calculate the value of loss function J;
[0078] (4) Determine whether the J value is less than 10 -6 If yes, go to step (10); if no, go to step (5);
[0079] (5) Calculate dw and db in the current mini-batch;
[0080] (6) Calculate the weighted average value of the momentum index V dw and V db , the calculation formula is V dw =β 1 V dw +(1-β 1 )dw、V db =β 1 V db +(1-β 1 )db, where β 1 The value of is 0.9;
[0081] (7) Update S in RMSprop dw and S db Parameter value, calculated as S dw =β 2 S dw +(1-β 2 )dw 2 , S db =β 2 S db +(1-β 2 )db 2 , where β 2 The value of is 0.999;
[0082] (8) Correct the deviation and calculate The value of the parameter is calculated as
[0083] (9) Using the calculation formula Update the values of parameters w and b and return to step (2);
[0084] (10) Determine whether there are any learning samples in the current mini-batch. If yes, proceed to step (11); otherwise, proceed to step (12);
[0085] (11) In the learning sample, obtain the chess game status of the black and white sides in the last two steps and return to step (1);
[0086] (12) After the value of m_count is increased by 1, it is then determined whether it exceeds the value of m. If it does not exceed, the process returns to step (1) and continues to execute all the above steps. If it exceeds, the process proceeds to step (13);
[0087] (13) Save the current black square weight information and obtain the optimized black square neural network.
[0088] Similarly, to optimize the white neural network, we only need to swap the black and white sides, and let the white side learn from all the samples of the black side winning 3 pieces in the same way to obtain the final optimized white neural network.
[0089] Example 5
[0090] Corresponding to the above method, an embodiment of the present invention further provides an automatic generation device for intelligent battle learning samples, including a chess-playing two-party construction optimization module, a first optimization module, a second optimization module and a test module;
[0091] The two players build an optimization module to set the two players to use the same neural network model; the first optimization module is used to perform the first optimization on both players to obtain initial weight information; the first optimization process specifically includes: 1 In each game, both sides first randomly initialize their weights as the initial weights and then play chess against each other. The chess steps, weight information of both sides and win / loss results in each game are recorded as learning samples and stored in the first learning sample set. When the set number of self-playing games N is completed, 1 After that, both sides select their own winning m from the first learning sample set 1 The second optimization module is used to perform subsequent optimization iterations on both sides until the set number of iterations is reached; wherein each optimization process specifically includes: after the set number of self-playing games N, 2 In each game, both sides use the final weight information after the last optimization as the initial weight to play chess against each other again, and record the chess playing steps, weight information of both sides and winning and losing results in each game as learning samples and store them in the second learning sample set; when the set number of self-playing chess games N is completed 2 Then, all the winners of both parties are selected from the second learning sample set. 2 The learning samples of the two sub-groups are stored in the third learning sample set; the third learning sample set is used to enable the two parties to learn from each other, and the final weight information of the two parties after this optimization is obtained; wherein, m 2 <m 1The test module is used to use the last optimized weight information as the optimal weight after reaching the set number of iterations, and to determine whether the winning rate of the party with the optimal weight against the other party with the randomly initialized weight reaches the set threshold.
[0092] It should be noted that the automatic generation device for intelligent combat learning samples provided in the embodiment of the present invention is for realizing the above method. Its specific functions can be referred to the above method embodiments, which will not be repeated here.
[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. Automatic generation method of intelligent combat learning samples, It is characterized in that include: Step 1: Set the two players to use the same neural network model; Step 2: Perform the first optimization on both parties to obtain the initial weight information; The first optimization process specifically includes: after playing the self-game for a set number of times N 1 In each game, both sides first randomly initialize their weights as the initial weights and then play chess against each other. The chess steps, weight information of both sides and win / loss results in each game are recorded as learning samples and stored in the first learning sample set. When the set number of self-playing games N is completed, 1 After that, both sides select their own winning m from the first learning sample set 1 The chess piece randomly selects one from the chess games, and uses the weight information corresponding to the selected chess game as its own initial weight information; Step 3: Perform subsequent optimization iterations on both parties until the set number of iterations N is reached; wherein each optimization process specifically includes: 2 In each game, both sides use the final weight information after the last optimization as the initial weight to play chess against each other again, and record the chess playing steps, weight information of both sides and winning and losing results in each game as learning samples and store them in the second learning sample set; when the set number of self-playing chess games N is completed 2 Then, all the winners of both parties are selected from the second learning sample set. 2 The learning samples of the two sub-groups are stored in the third learning sample set; the third learning sample set is used to enable the two parties to learn from each other, and the final weight information of the two parties after this optimization is obtained; wherein, m 2 <m 1 .
2. The method for automatically generating intelligent combat learning samples according to claim 1, It is characterized in that Also includes: Step 4: When the set number of iterations N is reached, the weight information of the last optimization is used as the optimal weight. If the winning rate of the party with the optimal weight against the other party with the randomly initialized weight reaches the set threshold, the game ends. Otherwise, the N value is reset to 2 and returns to step 3.
3. The method for automatically generating intelligent combat learning samples according to claim 1, It is characterized in that The process of playing chess by itself includes: Step A1: Determine whether the current chess game state has been decided; If the winner is not decided and the player is the one who is going to make the next move, then all the possible moves are listed and used as the input values of the neural network to calculate the score of each move. The move with the largest score is selected as the next move state of the player. The current state of the game is saved as a new root node. If the winner is not decided and the opponent is the current player, then all the moves that the opponent can choose are listed, and all the moves are used as input values of the opponent's neural network in turn to calculate the score of each move, and the move with the smallest score is selected as the opponent's next move state; and the chess game state at this time is saved as a new root node; Step A2: Repeat step A1 until the winner is determined.
4. The method for automatically generating intelligent combat learning samples according to claim 1, It is characterized in that The third learning sample set is used to enable the two parties to learn from each other, and the final weight information of the two parties after this optimization is obtained, which specifically includes: Assume that in the third learning sample set, the team wins m 2 The number of learning samples is M, and the M learning samples are divided into m small training sets; For each small training set, the chess steps of each learning sample are obtained in turn. Starting from the first step of the chess game, the chess game state faced by the opponent in this step is used as the input value of the opponent's neural network to calculate the original score. Then, the chess game state and weight information of the next step of the player are used as the input value of the opponent's neural network to calculate the target score. This process is repeated to complete the learning of all chess game states, and the opponent's neural network is optimized in combination with the Adam optimization algorithm. After all the small training sets are learned, the weight information finally optimized by the other party is used as the final weight information after this optimization; According to the above optimization process of the other party's neural network, optimize your own neural network to obtain your final weight information after this optimization.
5. The method for automatically generating intelligent combat learning samples according to claim 4, It is characterized in that In the process of using the third learning sample set to enable the two parties to learn from each other, the loss is calculated based on the original score and the target score using a cross entropy loss function.
6. The method for automatically generating intelligent combat learning samples according to any one of claims 1 to 5, It is characterized in that The neural network model adopts a seven-layer fully connected neural network.
7. Intelligent battle learning sample automatic generation device, It is characterized in that include: The two players build an optimization module to set the two players to use the same neural network model; The first optimization module is used to perform the first optimization on both parties to obtain initial weight information; The first optimization process specifically includes: after playing the self-game for a set number of times N 1 In each game, both sides first randomly initialize their weights as the initial weights and then play chess against each other. The chess steps, weight information of both sides and win / loss results in each game are recorded as learning samples and stored in the first learning sample set. When the set number of self-playing games N is completed, 1 After that, both sides select their own winning m from the first learning sample set 1 The chess piece randomly selects one from the chess games, and uses the weight information corresponding to the selected chess game as its own initial weight information; The second optimization module is used to perform subsequent optimization iterations on both parties until a set number of iterations is reached; wherein each optimization process specifically includes: after a set number of self-playing games N 2 In each game, both sides use the final weight information after the last optimization as the initial weight to play chess against each other again, and record the chess playing steps, weight information of both sides and winning and losing results in each game as learning samples and store them in the second learning sample set; when the set number of self-playing chess games N is completed 2 Then, all the winners of both parties are selected from the second learning sample set. 2 The learning samples of the two sub-groups are stored in the third learning sample set; the third learning sample set is used to enable the two parties to learn from each other, and the final weight information of the two parties after this optimization is obtained; wherein, m 2 <m 1 .
8. The device for automatically generating intelligent battle learning samples according to claim 7, It is characterized in that include: The test module is used to use the weight information of the last optimization completed as the optimal weight after reaching the set number of iterations, and to determine whether the winning rate of the party with the optimal weight playing against the other party with the randomly initialized weight reaches the set threshold.
