[0045] Below in conjunction with the examples, the specific implementation of the present invention will be further described in detail. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0046] The artificial intelligence engine based on AI Designer is different in that it includes the following steps:
[0047] Step 1, complete decision-making through the situation of the game world and player input, specifically:
[0048] 1) Receive game situation and player input.
[0049] 2) Extract low-level semantic information, which is mapped to the corresponding state according to the prerequisites of each state.
[0050] 3) Generate an action plan according to the production rules of the response state, that is, copy the current state of the game system through the SFP algorithm, optimize the action, and select an optimal action plan.
[0051] 4) Execute the response action sequence and enter the game to enter the next cycle.
[0052] During implementation, feature engineering and recognition are accomplished by artificially mapping raw data to states according to rules, and decision making is accomplished by mapping states to responses based on production systems.
[0053] The reason for choosing the SFP algorithm is that the situation and rule design of many games are very complicated, and it is difficult to judge what is the real optimal decision. For such complex situations, it is impossible to get an exact optimal decision, so the optimization goal is to find an action that is likely to lead to a good outcome. At the same time, there will be some uncertainty in many situations in the game, and there will also be problems of lack of information. In addition, in the game, players will also face unknown individuals in competition or cooperation. Players not only need to decide their own actions, but also need to Guessing or anticipating the actions of other players makes making optimal decisions very difficult. Therefore, the ultimate goal of the SFP algorithm is not to find the optimal solution, but to ensure that its performance in some aspects can surpass other methods.
[0054]During implementation of the present invention, the SFP algorithm uses a forward model (also called a game world model). For real game world problems. The forward model is defined as: Given a system (game) state S, S can be perceived by multiple sensors (S1, S2,..., Sn), the state transition function f combines the current state of the system with the action of the intelligent individual At ∈A (predefined action space) maps to the next system state S(n+1).
[0055] Step 2, find the algorithm for the optimal decision-making path, the process is as follows:
[0056] 1) Use the A-STAR algorithm (A star algorithm) to find the optimal decision-making path in the static grid. Or, use the D-STAR algorithm (D-STAR R algorithm) to find the optimal decision-making path in the dynamic grid.
[0057] 2) Pathfinding through the group behavior algorithm (Flocking Behavior) In some games, the common pathfinding function of the character group is required. The advantage of this implementation is that if the individual pathfinding calculation is performed for each individual, it will cause the amount of calculation to expand and cause a lot of unnecessary repetition.
[0058] 3) Combining DFS algorithm (priority search algorithm) and BFS algorithm (breadth-first search algorithm) to complete the search for the optimal decision-making path. At the same time, it can cooperate with the heuristic function to confirm whether to use some estimated functions during the pathfinding process.
[0059] In conjunction with actual implementation, the A-STAR algorithm used in the present invention configures the evaluation function f(n)=g(n)+h(n), where f(n) is the evaluation function of node n from the initial point to the target point , g(n) is the actual cost from the initial node to node n in the state space, and h(n) is the estimated cost of the best path from n to the target node. The value of h(n) directly affects the speed and accuracy of the algorithm. The common value of h(n) is the Manhattan distance between two points. At the same time, the A-STAR algorithm is configured with an Open table, and the priority of the nodes in the Open table is arranged according to the size of f(n), and the smaller the value of f(n), the higher the priority of being searched. In this way, the optimal solution can be guaranteed to be searched.
[0060] Specifically, the function h(n) cannot be greater than the actual cost from node n to the target node. If h(n)=0, the A-STAR algorithm degenerates into Dijkstra's algorithm (Dijkstra's algorithm). It should be noted that the Dijkstra algorithm is an alternative. Although it can guarantee the optimal path, the efficiency of the algorithm is low. If there are other alternative upper-level optimization algorithms, they can be replaced. There are many more, and I will not repeat them again. If h(n) is exactly equal to the actual cost from node n to the target node, then the node explored by A-STAR algorithm is exactly the node on the optimal path.
[0061] The D-STAR algorithm implemented in the present invention is a dynamic extension of the A-STAR algorithm. When an unknown environment or dynamic obstacles appear, the A-STAR algorithm needs to discard the open table and close table completed in the initial planning to re-plan, which will easily increase the planning time. In this way, through the D-STAR algorithm, first use the Dijkstra algorithm or A-STAR algorithm to perform a reverse search from the target point to the initial point, and then the robot moves from the starting point to the target point. When encountering a dynamic obstacle, only local changes are made That's it. Thereby, the processing efficiency of artificial intelligence can be improved.
[0062] Looking further, a node is the basic unit of the above algorithm. Since the algorithm can be applied to a variety of navigation graphs, the representations of nodes in different navigation graphs are different, and a polygon is a node in a polygonal navigation graph. Each visible point in the visible point navigation map is a node, and each rectangular grid in the gridded navigation map is a node. Since the entire game map is very large and will be generated from hundreds of thousands to millions of nodes, these algorithms guarantee the search overhead of the artificial intelligence system, otherwise the huge search volume will definitely make the mobile phone chip run at full capacity, causing the mobile phone to heat up.
[0063] Step 3: Carry out artificial intelligence path planning through GOAP (Goal Oriented Action Planning). Specifically, the AI has an initial state and a goal that it needs to achieve. At the same time, AI is provided with a set of goals that can be selected by priority or current state. And, the AI decides on a sequence of actions to satisfy the current goal. Furthermore, artificial intelligence plans the action sequence that can most easily reach the target state similar to the path.
[0064] Specifically, through the GOAP method, a series of possible actions are provided to the artificial intelligence as a description of the game world, and the prerequisites for each action and the impact of the action are configured for the artificial intelligence. At the same time, the GOAP method uses reverse link search, starting from the goal to be achieved, finding the corresponding action that can achieve the goal, looking for the prerequisites of the action just now, until reaching your current (initial) state. Therefore, the heuristic forward link search is replaced by the reverse link search, which improves the overall processing efficiency and reduces the calculation burden.
[0065] In terms of actual implementation, the target can be added to the list of unresolved events through GOAP. For each resolution event, find the action to achieve the event. If the prerequisites of the action have been satisfied, add the action to the plan, and push back the action that needs to meet the prerequisite to the plan; otherwise, add the prerequisite to the unresolved time.
[0066] Furthermore, during the implementation of the present invention, support for the Influence Map algorithm can be added. In this way, additional data support can be provided for artificial intelligence decision-making. The algorithm is similar to the blurring algorithm of photo editing software such as Photoshop. When executed, the Influence Map algorithm starts by setting some influence sources in the map, and then repeatedly blurs the map by adjacent points to spread these influence sources. This way, they can be executed and customized in any order that suits them.
[0067] The working principle of the present invention is as follows:
[0068] For example, create an NPC soldier in the game, and set the goal of the NPC soldier to kill other enemies.
[0069] Actually, through the method of the present invention, the target of the NPC soldier with artificial intelligence is set as Target. Dead. In order for the target to die, the NPC soldier must have a weapon with which to shoot. So, for artificial intelligence, it's a prerequisite. However, if the NPC soldier does not have the weapon being equipped, the NPC soldier needs to perform the action of finding the weapon. Specifically, this action will have multiple derivative situations based on the judgment of artificial intelligence. For example: if there is a weapon library for NPCs, the NPC soldier will take one from the weapon library. If not, the NPC soldier will pathfind to find one. After getting the weapons and equipment, you will start looking for the set enemies. During this period, since there are many ways to find the way of the NPC, you can find it on foot, or you can drive to find it if there are cars around the NPC. To this end, NPC soldiers can be given a large number of action options, allowing NPC soldiers to use the characteristics of artificial intelligence to decide what to do, resulting in dynamic unpredictable and interesting behaviors. Also, such behavior is more natural, due to the fixed behavior execution of the developer-created row.
[0070] As can be seen from the above text expressions, after adopting the present invention, it has the following advantages:
[0071] 1. It can effectively replace the artificial intelligence engine for mobile games, and the execution effect is more realistic and efficient.
[0072] 2. It can reduce the development cost of a single product and realize the reuse of multiple products.
[0073] 3. Reduce the computing load of artificial intelligence, reduce the CPU usage to 1/3, and the memory space to 1/2. It can increase the coverage of various low-end mobile devices by 60%, and increase the user base and user perception.
[0074] 4. It can be implemented with various conventional programming tools, which is convenient for developers to adjust and use.
[0075] The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention. It should be pointed out that for those of ordinary skill in the art, some improvements can be made without departing from the technical principle of the present invention. and modifications, these improvements and modifications should also be considered as the protection scope of the present invention.