Game strategy generation method and device based on large language model and storage medium
Through the game strategy generation method based on the large language model, the problems of confusion in behavioral logic and inconsistent actions of game characters in SLG games are solved, and the consistency of game actions and game authenticity are improved.
Patent Information
- Application Number
- CN202411611447.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-04-11
AI Technical Summary
Due to the numerous states and actions of SLG games, there is huge room for decision-making, which leads to the confusion of the behavioral logic of the game characters, making it difficult to maintain the consistency of the game actions, affecting the authenticity of the game.
The game strategy generation method based on the large language model is adopted. By obtaining multiple state data of the game characters, the large language model is used to predict the probability of game actions, and the lightweight neural network model is trained through knowledge distillation to generate game action strategies.
While reducing the cost of game decision-making, maintain the consistency of game actions, avoid logical confusion in the action strategies of game characters, and improve the authenticity of the game.
Smart Images

Figure CN119792947A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, device, and storage medium for generating a game strategy based on a large language model. Background Art
[0002] SLGs (Simulation Life Games) are simulation games that occupy a significant position in the gaming market. In these games, players simulate their lives within the game, and multiple players can be online simultaneously. Due to the extremely long playtime of these games, active players rapidly decline in the later stages of the game, which can affect the experience of active players. Therefore, game developers often incorporate non-player controlled characters (NPCs) into the game to serve real players and enhance their gaming experience.
[0003] However, due to the numerous states and actions in SLG games, the decision space is huge, the behavioral logic of different game characters is confusing, and it is difficult to maintain the consistency of game actions, resulting in poor game authenticity. Summary of the Invention
[0004] The embodiments of the present application provide a method, device, and storage medium for generating a game strategy based on a large language model, which aims to maintain the consistency of the game actions of a game character, thereby improving the authenticity of the game.
[0005] In a first aspect, an embodiment of the present application provides a method for generating a game strategy based on a large language model, comprising:
[0006] Acquire a plurality of first state data of the game character, wherein the plurality of first state data include a plurality of game actions corresponding to different game resource data;
[0007] using the plurality of first state data as inputs of a preset large language model, and determining, by the large language model, first predicted probabilities of executing the plurality of game actions under different scenarios of the game resource data;
[0008] Using the first predicted probabilities corresponding to the plurality of game actions as soft labels, a lightweight neural network model is trained using knowledge distillation to obtain a trained target language model;
[0009] Acquiring second state data of the game character, and inputting the second state data into the target language model for analysis to obtain second predicted probabilities of executing a plurality of game actions;
[0010] A game action strategy is generated based on the second predicted probabilities of the plurality of game actions.
[0011] In a second aspect, an embodiment of the present application further provides a computer device, comprising a processor, a memory, a computer program stored on the memory and executable by the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, any one of the game strategy generation methods provided in the embodiments of the present application is implemented.
[0012] On the third aspect, an embodiment of the present application also provides a storage medium for computer-readable storage, characterized in that the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement any game strategy generation method provided in the embodiment of the present application.
[0013] The game strategy generation method based on a large language model provided in an embodiment of the present application involves a preset large language model and a lightweight neural network model. The soft label of the lightweight neural network model is obtained through the large language model, so that the lightweight neural network model can be trained using knowledge distillation to obtain a trained target language model. When making specific decisions on the game actions of a game character, the target language model can be used to analyze the state data of the game character to obtain a second predicted probability of executing multiple game actions, thereby generating a game action strategy based on the second predicted probabilities of the multiple game actions. This can reduce the cost of game decision-making while maintaining the consistency of the game actions, thereby avoiding logical confusion in the game character's action strategy, and thus can improve the authenticity of the game. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 A flowchart of a method for generating a game strategy based on a large language model provided in an embodiment of the present application;
[0015] Figure 2 A screenshot of the interface of a game city provided in an embodiment of the present application;
[0016] Figure 3 A screenshot of the external interface of a game city provided in an embodiment of the present application;
[0017] Figure 4 A schematic diagram of an application method of a large language model provided in an embodiment of the present application;
[0018] Figure 5 A schematic diagram of a lightweight neural network model provided in an embodiment of the present application;
[0019] Figure 6 for Figure 1 A schematic flow chart of a sub-step of the game strategy generation method in FIG.
[0020] Figure 7 for Figure 1 A schematic flow chart of a sub-step of the game strategy generation method in FIG.
[0021] Figure 8 A schematic block diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0023] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.
[0024] It should be understood that the terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0025] Embodiments of the present application provide a method, device, and storage medium for generating a game strategy based on a large language model. The method can be applied to a computer device, which may include a server or a terminal device. The server can be a single server or a server cluster consisting of multiple servers. The terminal device can be an electronic device such as a mobile phone, tablet computer, laptop computer, desktop computer, personal digital assistant, or wearable device.
[0026] The following describes some embodiments of the present application in detail with reference to the accompanying drawings. In the absence of conflict, the following embodiments and features therein may be combined with each other.
[0027] Please refer to Figure 1 , Figure 1 A flowchart of the steps of a method for generating a game strategy based on a large language model is provided in an embodiment of the present application.
[0028] like Figure 1 As shown, the game strategy generation method includes steps S101 to S105.
[0029] Step S101: Acquire multiple first status data of a game character.
[0030] The multiple first state data include multiple game actions corresponding to different game resource data. Game resource data refers to a collection of various resources, materials, and information in the game, including but not limited to character attributes, map information, level design, and game plot. Game resource data can also include materials or supplies such as food, water, wood, stone, gold, and diamonds. Game actions refer to the creation of realistic dynamic effects for characters or objects in the game during the game development process, making them more dynamic and realistic. Game actions involve multiple aspects such as character animation, object physics, and combat movements, and can enhance the overall gaming experience and viewing experience.
[0031] It should be noted that the multiple first state data may include a large number of diverse and legal game states within the game. The game may be a life simulation game (SLG), which can support multiple players online at the same time. It may also be other games or other types of games, such as adventure games, sports games, puzzle games, etc., which are not specifically limited in the embodiments of the present application. For example, SLG games have a long play time and a single action lasts for a long time. For example, upgrading a single building may take up to several months from the time the upgrade command is initiated to the time the final building level status changes (simulating the construction time of a real building).
[0032] In one embodiment, a game may have multiple game actions. Different game actions require different game resource data to be consumed, and different game actions also require different condition data to be satisfied. Both the game resource data and the condition data may be empty. It is understood that different game actions may vary in different games, and game actions in different games may be configured based on actual circumstances.
[0033] Exemplarily, the game actions include at least one of the following: building upgrade action, character upgrade action, equipment upgrade action, skill upgrade action, normal attack action, skill attack action, defensive attack action, resource purchase action, resource consumption action, resource collection action, resource trading action, item pickup action, character movement action, and troop movement action.
[0034] For example, the game action is upgrading a building. The game resource data required for upgrading a building includes materials such as food, water, wood, and stone. The conditional data for upgrading a building is the level of the game character or the level of the building. Different levels can upgrade different buildings or building types. For example, the first state data includes 20 units of food, 15 units of water, and 10 units of wood for upgrading a Level 15 City Lord's Hall.
[0035] In one embodiment, the plurality of game actions include a first game action and a second game action. The game resource data required to consume by the first game action overlaps with the other game actions, while the game resource data required to consume by the second game action do not overlap with the other game actions. For example, SLG games have a large number of action spaces, with one game having over 200 available game actions. Furthermore, different game actions require different or similar resources, and the duration of the game actions also varies.
[0036] For example, the game actions include a building diamond acceleration action and a diamond store purchase action. The building diamond acceleration action requires diamonds, and the diamond store purchase action also requires diamonds. There is a conflict of diamond resources between these two game actions, so the building diamond acceleration action and the diamond store purchase action are the first game actions.
[0037] For example, the game resource data required for upgrading a building includes materials such as food, water, wood, and stone; the game resource data required for upgrading a character includes gold and food; and the game resource data required for upgrading equipment includes diamonds. Therefore, the game resource data required for upgrading a building and upgrading a character overlap, but the game resource data required for upgrading equipment does not overlap with the game resource data required for upgrading a building or upgrading a character. That is, upgrading a building and upgrading a character are considered first game actions, while upgrading equipment is considered second game actions.
[0038] like Figure 2 As shown, Figure 2 This is a screenshot of the interface of a game city. There are many rooms in the interface with different levels. Players need to collect resources through various means and then upgrade the rooms in the city. Figure 3 As shown, Figure 3 This is a screenshot of the interface outside a game city. There are many ways to collect resources in this interface, such as food, monsters, treasure chests, resource sites, etc. Players need to attack monsters or collect resources in resource sites to collect the necessary resources for development.
[0039] In one embodiment, the first game action is generated based on a set of multiple consecutive game actions. Different games may require multiple consecutive game actions to complete a game behavior. For example, if the multiple consecutive game actions include purchasing resources, using resources, and training soldiers, the multiple consecutive game actions of purchasing resources, using resources, and training soldiers can be combined into the training soldier behavior.
[0040] In one embodiment, obtaining a plurality of first state data of a game character includes: obtaining a plurality of state data sets by randomly walking through a plurality of game modules in the game, where each state data set may include a plurality of state data of a game module.
[0041] In one embodiment, the game includes multiple game modules, and multiple game actions are obtained through multiple game modules. Different game modules are configured with different game actions. For example, due to the huge action space of SLG, the number of game modules is relatively large (up to 37 in one SLG game). Exemplarily, the game modules include at least one of the following: a hero module, a soldier module, a building module, a skill module, a technology module, a resource module, and a recharge module.
[0042] It should be noted that related technologies generally use reinforcement learning (RL) modeling methods, which are relatively difficult to learn. Therefore, this application adopts a modular approach, placing game actions of the same category in a single game module. For example, soldier-related game actions (when to train soldiers, how many soldiers to train, what level of soldiers to train, how many soldiers to advance, etc.) are placed in the soldier module. This helps maintain consistency in game actions, thereby avoiding logical confusion in the game character's action strategies, and thus improving the authenticity of the game.
[0043] Step S102: Using the plurality of first state data as input to a preset large language model, the large language model is used to determine first predicted probabilities of executing a plurality of game actions under different game resource data scenarios.
[0044] The first state data serves as input to a preset large language model, enabling the large language model to output, based on the first state data, first predicted probabilities of executing multiple game actions in a scenario with corresponding game resource data. The game resource data and multiple game actions are determined by the large language model from the corresponding first state data. Given the same game resource data, multiple game actions can be executed, but the execution probabilities of different game actions vary, resulting in different first predicted probabilities for different game actions.
[0045] It should be noted that preset large language models (LLMs) are widely used in the field of natural language processing, such as text classification, question answering, translation, and conversation tasks. Exemplary large language models may include GPT-3, Chat GPT, PaLM, BERT, etc., and may also include Wenxin Yiyan, iFlytek Spark, Tongyi Qianwen, Chat GLM, Baichuan, etc., which are not specifically limited in the embodiments of this application.
[0046] In one embodiment, the first state data may also include data such as the game module to which the game action belongs, the effect of the game action, and specific requirements for output data. The specific requirements for output data may include, for example, the output format of the large language model and / or the thought chain of the large language model. The specific requirements may also include other data. For example, the currently available game action, the effect of the game action, the output format of the large language model, the thought chain of the large language model, etc. are entered as the first state data in the prompt bar of the large language model.
[0047] It is understood that multiple first state data can be input into the large language model sequentially. After the first state data is input into the large language model, the large language model can identify the intent of the first state data and determine the predicted probabilities of executing multiple game actions based on the context of the game resource data in the first state data, thereby obtaining first predicted probabilities of executing the multiple game actions.
[0048] For example, Figure 4 As shown, the first state data of the input of the large language model LLM includes the technology tree, technology effects, current status (equivalent to game resource data), optional skills (equivalent to multiple game actions), and specific requirements. The output of the large language model LLM includes skills 1 to skill 5 (equivalent to the first predicted probabilities corresponding to multiple game actions). Making specific strategic decisions through the large language model LLM can reduce labor costs.
[0049] Step S103: Use the first predicted probabilities corresponding to the multiple game actions as soft labels, and use knowledge distillation to train the lightweight neural network model to obtain a trained target language model.
[0050] It should be noted that knowledge distillation is a technique that transfers the knowledge of a large, complex model (usually called a teacher model) to a small, efficient model (usually called a student model). This method can significantly reduce the size and computational complexity of the model while maintaining model performance.
[0051] Among them, the lightweight neural network model includes any one of the following: a feedforward neural network model, a recursive neural network model, a long short-term memory network model, a convolutional neural network model, and a generative adversarial network model. In the embodiment of the present application, the lightweight neural network model can be determined according to the actual situation. For example, the lightweight neural network model can be a feedforward neural network model, such as Chat GPT.
[0052] In the embodiment of the present application, a large language model is used as a teacher model, and a lightweight neural network model is used as a student model. Compared with the conventional large language model, the lightweight neural network model has a simpler model structure, so it can be deployed in a resource-constrained game environment. While reducing costs, the model performance can be maintained, thereby ensuring the consistency of game actions, thereby avoiding logical confusion in the action strategies of game characters. Through verification, it can be known that a lightweight neural network model is trained by distillation, and the trained target language model can reach a delay of 16ms online.
[0053] In one embodiment, the first prediction probabilities of multiple target game actions are screened out from the first prediction probabilities of multiple game actions; based on the first prediction probabilities of the multiple target game actions, a lightweight neural network model is trained using knowledge distillation to obtain a trained target language model.
[0054] It should be noted that the output data of the large language model for a first state data can be the first predicted probabilities corresponding to multiple game actions. In some cases, not all output data is required. Therefore, the first predicted probabilities of multiple target game actions can be screened out from the first predicted probabilities of multiple game actions. The number of target game actions can be flexibly set according to actual conditions to ensure the efficiency of knowledge distillation. For example, if the number of target game actions to be selected is set to 5, the first predicted probabilities of the top 5 target game actions can be screened out from the first predicted probabilities of multiple game actions. The screening basis can be user screening or screening based on the value of the first predicted probability, etc.
[0055] In one embodiment, based on the first predicted probabilities of multiple target game actions, a lightweight neural network model is trained using knowledge distillation to obtain a trained target language model, including: inputting the first state data corresponding to the multiple target game actions into the input layer of the lightweight neural network model for feature extraction to obtain feature vector data; inputting the feature vector data into the normalization layer of the neural network model for processing to obtain normalized data; inputting the normalized data into the mean square error layer of the neural network model for processing to obtain mean square error data; inputting the mean square error data into the distribution function layer of the neural network model for processing to obtain distribution function data; inputting the distribution function data into the output layer of the neural network model for processing to obtain third predicted probabilities of multiple target game actions; determining the loss function of the neural network model based on the third predicted probabilities and the first predicted probabilities of the multiple target game actions, and updating the model parameters of the neural network model based on the loss function of the neural network model.
[0056] The lightweight neural network model includes an input layer, a normalization layer, a mean square error layer, a distribution function layer, and an output layer. The input layer may include multiple convolutional layers for extracting features from the input first state data to obtain feature vector data. The normalization layer is used to process the feature vector data to obtain normalized data. The mean square error layer is used to calculate the mean and variance of the normalized data to obtain mean square error data. The distribution function layer is used to process the mean square error data to obtain distribution function data. The output layer is used to output the distribution function data to obtain a third predicted probability of multiple target game actions. Negative Log-likehood Loss (NLLLoss) can be used as the loss function.
[0057] It should be noted that during the training process of the lightweight neural network model, there is an error between the third predicted probability of multiple target game actions and the first predicted probability of multiple target game actions obtained by the large language model. Therefore, it is necessary to determine the loss function of the neural network model based on the third predicted probability and the first predicted probability of multiple target game actions, and update the model parameters of the neural network model according to the loss function of the neural network model, so as to optimize the model performance of the lightweight neural network model.
[0058] Step S104: Acquire second state data of the game character, and input the second state data into the target language model for analysis to obtain second predicted probabilities of executing multiple game actions.
[0059] The second state data may be current state data of the game character, and may include game resource data of the game character and a plurality of game actions executable under the scenario of the game resource data.
[0060] It should be noted that after model training, the resulting target language model is able to effectively identify the second state data, thereby analyzing and obtaining the second predicted probabilities of multiple game actions that can be executed in the context of the game resource data in the second state data. To ensure the diversity of the output data of the lightweight neural network model, the neural network model does not directly output specific game actions. Instead, it outputs distribution function data (mean and std of normal distribution) of game actions, namely the second predicted probabilities of multiple game actions.
[0061] In one embodiment, the second state data includes the current game resource data of the game character and the corresponding current game action, which may be a plurality of game actions executable under the scenario of the game resource data. The second state data of the game character is input into the input layer of the lightweight neural network model for feature extraction to obtain feature vector data; the feature vector data is input into the normalization layer of the neural network model for processing to obtain normalized data; the normalized data is input into the mean square error layer of the neural network model for processing to obtain mean square error data; the mean square error data is input into the distribution function layer of the neural network model for processing to obtain distribution function data; the distribution function data is input into the output layer of the neural network model for processing to obtain a second predicted probability of executing the plurality of game actions.
[0062] For example, Figure 5 As shown, the process of knowledge distillation is to transfer knowledge from the teacher model to the student model to improve the performance of the student model. The lightweight neural network model is, for example, an MLP multi-layer perceptron 10, which includes an input layer, a normalization layer, a mean square error layer 11, a distribution function layer, and an output layer. The second state data input to the multi-layer perceptron 10 includes the current state (equivalent to game resource data) and optional skills (equivalent to multiple game actions).
[0063] Step S105: Generate a game action strategy based on the second predicted probabilities of the multiple game actions.
[0064] The game action strategy refers to the decision of which game action or actions to execute from among multiple corresponding game actions in the context of the second state data. By analyzing the second state data of the game character using the target language model, the second predicted probabilities of executing multiple game actions in the context of the second state data are obtained. The game action strategy is then generated based on the second predicted probabilities of the multiple game actions. This reduces game decision-making costs while maintaining consistency in game actions, thus avoiding logical confusion in the game character's action strategy and improving game realism.
[0065] In one embodiment, the plurality of game actions include a first game action and a second game action, the game resource data required to be consumed by the first game action and the other game actions overlap, and the game resource data required to be consumed by the second game action and the other game actions do not overlap. Figure 6 As shown, step S105 includes: sub-steps S1051 to S1054.
[0066] Sub-step S1051: Generate a conflict matrix for each first game action based on the game resource data consumed by each first game action.
[0067] Sub-step S1052: determining the execution order of the first game actions according to the conflict matrix of the first game actions and the second predicted probability of the first game actions.
[0068] It should be noted that when the multiple game actions corresponding to the second state data include multiple first game actions, the first game actions cannot be executed simultaneously because the game resource data consumed by these other game actions overlaps. Therefore, it is necessary to determine the execution order of the first game actions, that is, to determine which first game action should be executed first and which first game action should be executed later. For example, a building diamond acceleration action consumes diamonds, while a diamond store purchase action also consumes diamonds. These two game actions conflict in diamonds. Therefore, a conflict matrix for each first game action can be generated based on the game resource data consumed by each first game action. The execution order of each first game action can then be determined based on the conflict matrix and the second predicted probability of each first game action.
[0069] In one embodiment, the execution order of each first game action is determined based on the conflict matrix of each first game action and the second predicted probability of each first game action, including: using a preset probability distribution function to analyze the conflict matrix of each first game action to obtain probability distribution data of the conflict of each first game action; based on the probability distribution data of the conflict of each first game action and the second predicted probability of each first game action, determining the execution order of each first game action.
[0070] The probability distribution function may include a normal distribution function, a Poisson distribution function, a multinomial distribution function, and the like. The execution order of each first game action may be negatively correlated with the probability distribution data, and the execution order of each first game action may be positively correlated with the second predicted probability. For example, the greater the probability distribution data of a conflict between the first game actions, the lower the execution order of the first game action. The greater the second predicted probability of the first game action, the higher the execution order of the first game action.
[0071] It should be noted that, since the game action space in some games is huge, the embodiment of the present application reduces the game action space by distinguishing the first game actions and setting the conflict matrix of each first game action, thereby reducing the computational complexity and improving the generation efficiency and effectiveness of the game action strategy.
[0072] Sub-step S1053, and, according to the second predicted probabilities of the second game actions, determining the execution order of the second game actions.
[0073] It should be noted that since the game resource data required to consume the second game action does not overlap with that of other game actions, they can be executed simultaneously. Based on this, the execution order of each second game action can be determined based on the second predicted probability of each second game action. For example, the greater the second predicted probability of the second game action, the higher the execution order of the second game action. The timing for determining the execution order of each second game action and the execution order of each first game action can be simultaneous, or can be carried out in a time-sharing manner, for example, first determining the execution order of each second game action, and then determining the execution order of each first game action.
[0074] Sub-step S1054: Obtain the game action strategy of the game character according to the execution order of each first game action and the execution order of each second game action.
[0075] It should be noted that the execution order of each second game action can be independent of or combined with the execution order of each first game action. For example, the second game actions and the first game actions can be executed simultaneously or in turn. By combining the execution order of each first game action with the execution order of each second game action, the game action strategy of the game character can be derived. This game action strategy can maintain the consistency of the game actions, thereby avoiding logical confusion in the game character's action strategy, and thus improving the realism of the game.
[0076] In one embodiment, the game includes multiple game modules, and different game modules are configured with different game actions. Figure 7 As shown, step S105 includes: sub-steps S1055 to S1057.
[0077] Sub-step S1055: Determine the game modules corresponding to each game action.
[0078] The embodiment of the present application adopts the modularization concept, placing game actions of the same category in one game module and dividing multiple game actions into game modules for execution, which can avoid logical confusion in the action strategies of game characters.
[0079] Sub-step S1056: Determine the execution order of the multiple game actions according to the priority corresponding to each game module and the second predicted probability of each game action.
[0080] The priorities corresponding to different game modules can be different and can be set according to actual conditions. According to the priorities corresponding to the game modules and the second predicted probabilities of the game actions, the execution order of the multiple game actions can be accurately determined to avoid logical confusion in the action strategies of the game characters.
[0081] Exemplarily, the first execution order of each game action corresponding to each game module is determined based on the priority corresponding to each game module; the second execution order of each game action in each game module is determined based on the second predicted probability of each game action in each game module; and the execution order of multiple game actions is obtained by combining the first execution order and the second execution order of each game action.
[0082] Sub-step S1057: Obtain the game action strategy of the game character according to the execution order of multiple game actions.
[0083] It should be noted that the game action strategy of the game character can be obtained by combining the execution order of multiple game actions. The game action strategy can maintain the consistency of the game actions, thereby avoiding logical confusion in the game character's action strategy, and thus can improve the authenticity of the game.
[0084] Due to the huge action space of SLG, there are many game modules (up to 37 in one SLG game). To this end, this application adopts a modular approach, placing game actions of the same category in one game module. This helps to maintain the consistency of game actions, thereby avoiding logical confusion in the action strategies of game characters, and thus improving the authenticity of the game.
[0085] In one embodiment, the plurality of game actions include a first game action and a second game action, wherein the game resource data required to be consumed by the first game action and the other game actions overlap, and the game resource data required to be consumed by the second game action and the other game actions do not overlap. The plurality of game actions are obtained through a plurality of game modules, and different game modules are configured with different game actions. Specifically, a game action strategy is generated based on the second predicted probabilities of multiple game actions, including: determining the game modules corresponding to each game action; determining the execution order of each game module according to the priority corresponding to each game module; generating a conflict matrix for each first game action according to the game resource data required to be consumed by each first game action in each game module; determining the execution order of each first game action in each game module according to the conflict matrix of each first game action in each game module and the second predicted probability of each first game action in each game module; and determining the execution order of each second game action in each game module according to the second predicted probability of each second game action in each game module; determining the execution order of multiple game actions according to the execution order of each game module, the execution order of each first game action in each game module, and the execution order of each second game action; and obtaining a game action strategy for a game character according to the execution order of multiple game actions.
[0086] The game strategy generation method provided in the above embodiment involves a preset large language model and a lightweight neural network model. The large language model is used to obtain soft labels for the lightweight neural network model, which can then be trained using knowledge distillation to obtain a trained target language model. When making specific decisions about a game character's game actions, the target language model can be used to analyze the game character's state data to obtain a second predicted probability of executing multiple game actions. Game action strategies are then generated based on the second predicted probabilities of the multiple game actions. This reduces the cost of game decision-making while maintaining consistency in game actions, thereby avoiding logical confusion in the game character's action strategy and improving game realism.
[0087] See also Figure 8 , Figure 8 A schematic block diagram of a computer device provided in an embodiment of the present application.
[0088] like Figure 8 As shown, the computer device 300 includes a processor 301 and a memory 302 , and the processor 301 and the memory 302 are connected via a bus 303 , such as an I 2 C (Inter-Integrated Circuit) bus.
[0089] Specifically, the processor 301 is used to provide computing and control capabilities to support the operation of the entire computer device. The processor 301 can be a central processing unit (CPU), and the processor 301 can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0090] Specifically, the memory 302 may be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a mobile hard disk.
[0091] Those skilled in the art will understand that Figure 8The structure shown in the figure is only a block diagram of a part of the structure related to the embodiment of the present application, and does not constitute a limitation on the computer device to which the embodiment of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0092] The processor is configured to run a computer program stored in a memory, and implement any one of the game strategy generation methods provided in the embodiments of the present application when executing the computer program.
[0093] In one embodiment, the processor is configured to run a computer program stored in the memory, and implement the following steps when executing the computer program:
[0094] Acquire a plurality of first state data of the game character, wherein the plurality of first state data include a plurality of game actions corresponding to different game resource data;
[0095] using the plurality of first state data as inputs of a preset large language model, and determining, by the large language model, first predicted probabilities of executing the plurality of game actions under different scenarios of the game resource data;
[0096] Using the first predicted probabilities corresponding to the plurality of game actions as soft labels, a lightweight neural network model is trained using knowledge distillation to obtain a trained target language model;
[0097] Acquiring second state data of the game character, and inputting the second state data into the target language model for analysis to obtain second predicted probabilities of executing a plurality of game actions;
[0098] A game action strategy is generated based on the second predicted probabilities of the plurality of game actions.
[0099] In one embodiment, the multiple game actions include a first game action and a second game action, the first game action and the other game actions require the same game resource data to be consumed, and the second game action and the other game actions require the same game resource data to be consumed.
[0100] In one embodiment, when generating a game action strategy based on the second predicted probabilities of the plurality of game actions, the processor is configured to implement:
[0101] generating a conflict matrix for each of the first game actions according to the game resource data required to be consumed by each of the first game actions;
[0102] determining an execution order of each of the first game actions according to a conflict matrix of each of the first game actions and a second predicted probability of each of the first game actions; and
[0103] determining an execution order of each of the second game actions according to a second predicted probability of each of the second game actions;
[0104] The game action strategy of the game character is obtained according to the execution order of each of the first game actions and the execution order of each of the second game actions.
[0105] In one embodiment, when determining the execution order of the first game actions based on the conflict matrix of the first game actions and the second predicted probability of the first game actions, the processor is configured to implement:
[0106] Analyzing the conflict matrix of each of the first game actions using a preset probability distribution function to obtain probability distribution data of conflicts occurring among the first game actions;
[0107] An execution order of each of the first game actions is determined based on probability distribution data of conflicts among each of the first game actions and the second predicted probability of each of the first game actions.
[0108] In one embodiment, the first game action is generated according to a plurality of consecutive game action sets.
[0109] In one embodiment, the game action includes at least one of the following:
[0110] Upgrade building actions, upgrade character actions, upgrade equipment actions, upgrade skill actions, normal attack actions, skill attack actions, defensive attack actions, purchase resource actions, consume resource actions, collect resource actions, trade resource actions, pick up item actions, character movement actions, troop movement actions.
[0111] In one embodiment, the plurality of game actions are obtained through a plurality of game modules, and different game modules are configured with different game actions.
[0112] In one embodiment, when generating a game action strategy based on the second predicted probabilities of the plurality of game actions, the processor is configured to implement:
[0113] Determine the game modules corresponding to the respective game actions;
[0114] determining an execution order of the plurality of game actions according to the priority corresponding to each of the game modules and the second predicted probability of each of the game actions;
[0115] A game action strategy of the game character is obtained according to the execution order of the multiple game actions.
[0116] In one embodiment, the game module includes at least one of the following:
[0117] Hero module, soldier module, building module, skill module, technology module, resource module, and recharge module.
[0118] In one embodiment, when the processor uses the first predicted probabilities corresponding to the plurality of game actions as soft labels and trains a lightweight neural network model using knowledge distillation to obtain a trained target language model, the processor is configured to implement:
[0119] Filtering out a plurality of first predicted probabilities of target game actions from the plurality of first predicted probabilities of the game actions;
[0120] Based on the first predicted probabilities of the multiple target game actions, a lightweight neural network model is trained using knowledge distillation to obtain a trained target language model.
[0121] In one embodiment, when the processor implements the first predicted probabilities based on the multiple target game actions and trains the lightweight neural network model using knowledge distillation to obtain a trained target language model, the processor is configured to implement:
[0122] Inputting the first state data corresponding to the plurality of target game actions into an input layer of a lightweight neural network model for feature extraction to obtain feature vector data;
[0123] Inputting the feature vector data into the normalization layer of the neural network model for processing to obtain normalized data;
[0124] Inputting the normalized data into the mean square error layer of the neural network model for processing to obtain mean square error data;
[0125] Inputting the mean square error data into the distribution function layer of the neural network model for processing to obtain distribution function data;
[0126] Inputting the distribution function data into the output layer of the neural network model for processing to obtain third predicted probabilities of the multiple target game actions;
[0127] A loss function of the neural network model is determined based on the third predicted probabilities of the multiple target game actions and the first predicted probabilities, and model parameters of the neural network model are updated based on the loss function of the neural network model.
[0128] In one embodiment, the lightweight neural network model includes any one of the following:
[0129] Feedforward neural network model, recursive neural network model, long short-term memory network model, convolutional neural network model, and generative adversarial network model.
[0130] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the computer device described above can refer to the corresponding process in the aforementioned game strategy generation method embodiment, and will not be repeated here.
[0131] An embodiment of the present application also provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of any game strategy generation method provided in the embodiment of the present application.
[0132] The storage medium may be an internal storage unit of the computer device described in the aforementioned embodiment, such as a hard disk or memory of the computer device. The storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device.
[0133] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As is well known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable, and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media generally embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0134] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments. The above description is only a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A game strategy generation method based on a large language model, characterized in that: include: Acquire a plurality of first state data of a game character, wherein the plurality of first state data include a plurality of game actions corresponding to different game resource data; Using the plurality of the first state data as inputs of a preset large language model, and determining, by means of the large language model, first predicted probabilities of executing the plurality of the game actions in scenarios of different game resource data; The first predicted probabilities corresponding to the plurality of game actions are used as soft labels, and a lightweight neural network model is trained by using knowledge distillation to obtain a trained target language model; Acquire second state data of the game character, and input the second state data into the target language model for analysis to obtain second predicted probabilities of executing multiple game actions; A game action strategy is generated based on the second predicted probabilities of the plurality of game actions.
2. The game strategy generation method according to claim 1, characterized in that: The multiple game actions include a first game action and a second game action, the first game action and the other game actions need to consume game resource data that overlap, and the second game action and the other game actions need to consume game resource data that do not overlap.
3. The game strategy generation method according to claim 2, characterized in that: Generating a game action strategy according to the second predicted probabilities of the plurality of game actions comprises: generating a conflict matrix for each of the first game actions according to the game resource data required to be consumed by each of the first game actions; Determining an execution order of each of the first game actions according to the conflict matrix of each of the first game actions and the second predicted probability of each of the first game actions; and Determining an execution order of each of the second game actions according to the second predicted probability of each of the second game actions; The game action strategy of the game character is obtained according to the execution order of each of the first game actions and the execution order of each of the second game actions.
4. The game strategy generation method according to claim 3, characterized in that: Determining the execution order of each of the first game actions according to the conflict matrix of each of the first game actions and the second predicted probability of each of the first game actions includes: Analyzing the conflict matrix of each of the first game actions using a preset probability distribution function to obtain probability distribution data of conflicts occurring in each of the first game actions; The execution order of each of the first game actions is determined according to the probability distribution data of the conflict between each of the first game actions and the second predicted probability of each of the first game actions.
5. The game strategy generation method according to claim 1, characterized in that: The game action includes at least one of the following: Upgrade building actions, upgrade character actions, upgrade equipment actions, upgrade skill actions, normal attack actions, skill attack actions, defensive attack actions, purchase resource actions, consume resource actions, collect resource actions, trade resource actions, pick up item actions, character movement actions, troop movement actions.
6. The game strategy generation method according to claim 1, characterized in that: The multiple game actions are obtained through multiple game modules, and different game modules are configured with different game actions; Generating a game action strategy according to the second predicted probabilities of the plurality of game actions comprises: Determine the game modules corresponding to the game actions; Determining the execution order of the plurality of game actions according to the priority corresponding to each of the game modules and the second predicted probability of each of the game actions; According to the execution order of the plurality of game actions, a game action strategy of the game character is obtained.
7. The game strategy generation method according to any one of claims 1 to 6, characterized in that: The first predicted probabilities corresponding to the plurality of game actions are used as soft labels, and a lightweight neural network model is trained by using knowledge distillation to obtain a trained target language model, including: Filtering out first predicted probabilities of a plurality of target game actions from the first predicted probabilities of the plurality of game actions; Based on the first predicted probabilities of the multiple target game actions, a lightweight neural network model is trained using knowledge distillation to obtain a trained target language model.
8. The game strategy generation method according to claim 7, characterized in that: The first predicted probabilities based on the multiple target game actions are used to train the lightweight neural network model by using knowledge distillation to obtain a trained target language model, including: Inputting the first state data corresponding to the plurality of target game actions into the input layer of the lightweight neural network model for feature extraction to obtain feature vector data; Inputting the feature vector data into the normalization layer of the neural network model for processing to obtain normalized data; Inputting the normalized data into the mean square error layer of the neural network model for processing to obtain mean square error data; Inputting the mean square error data into the distribution function layer of the neural network model for processing to obtain distribution function data; Inputting the distribution function data into the output layer of the neural network model for processing to obtain third predicted probabilities of the multiple target game actions; The loss function of the neural network model is determined according to the third predicted probabilities of the multiple target game actions and the first predicted probabilities, and the model parameters of the neural network model are updated according to the loss function of the neural network model.
9. A computer device, characterized in that: The computer device includes a processor, a memory, a computer program stored in the memory and executable by the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, the game strategy generation method as described in any one of claims 1 to 8 is realized.
10. A storage medium for computer-readable storage, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the game strategy generation method according to any one of claims 1 to 8.