System and method for designing game artificial intelligence task
Technical Field
The invention relates to a system and a method for designing a game artificial intelligence task, belonging to the field of computer game development.
Background
The traditional game artificial intelligence system can only utilize the computing power of a single thread whether running at a server or a client, and cannot be made into a multi-thread parallel system to run.
Disclosure of Invention
Aiming at the defects of the prior art, the technical scheme of the invention provides a system and a method for designing a game artificial intelligence task, which process artificial intelligence through a parallel virtual machine and make up the defects of the prior art in artificial intelligence processing of large tasks.
The technical scheme of the invention comprises a system for designing artificial intelligence tasks of games, which is characterized by comprising the following steps: the task creator is used for creating the granularity corresponding to the task when the task is created, wherein the granularity is used for recording the created task information, and is also used for creating an event, and the event comprises a plurality of tasks; the task memory is used for storing the created task to a task pool, also used for acquiring the task granularity created by the task creator, stored by using a granularity list and creating a reference unique identifier corresponding to the granularity; the task manager is used for acquiring the tasks and the task granularity stored in the task memory, storing task granularity lists, analyzing different events or/and tasks and sending the events and/or the tasks; and the task router is used for combining a plurality of different tasks into a task execution packet for the task or/and the event task sent by the task manager and sending the task execution packet to the corresponding processor.
According to the design system of the game artificial intelligence task, the task creator further comprises: the task creating module is used for creating a plurality of tasks of corresponding types according to different behaviors of artificial intelligence; the task granularity module is used for calculating and presetting the time and complexity of the created task, and recording the task by using granularity, wherein the information recorded by the granularity comprises the complexity of the task, the consumption of system resources for completing the task and network resources required for completing the task; and the granularity list module is used for sending the task granularity quoted by the tasks to the task manager and is also used for quoting the tasks with the same completion time and the same type by using the same granularity.
According to the design system of the game artificial intelligence task, the task memory further comprises: the task pool module is used for receiving the tasks created by the task creator and storing the tasks into a task pool, wherein the tasks are stored in the task pool by using unique identifiers and data blocks; and the dynamic granularity module is used for dynamically modifying the task granularity state information when the task is executed and the task data is interacted.
According to the design system of the game artificial intelligence task, the task manager further comprises: the analysis module is used for acquiring a task unique identifier in the task pool and further acquiring task data and granularity data; and the sending module is used for sending the analyzed task to the task router for distribution processing.
According to the design system of the game artificial intelligence task, the task router further comprises: and the task combination module is used for combining the tasks with the same type into a task group and further distributing the task group to the distributed processors for processing. And the event processing module is used for acquiring the execution time and complexity of the tasks in the event and dividing the event according to the acquired information, wherein the event processing module is used for processing the tasks with large granularity by using a single processor and processing a plurality of tasks with small granularity by using one or more processors.
The technical scheme of the invention also comprises a design method of the game artificial intelligence task, which is characterized by comprising the following steps: creating a granularity corresponding to the task when the task is created, wherein the granularity is used for recording created task information and creating an event, and the event comprises a plurality of tasks; storing the created task to a task pool, and also obtaining the task granularity created by the task creator, storing the task granularity by using a granularity list, and creating a reference unique identifier corresponding to the granularity; the task granularity and the tasks stored in the task memory are obtained and are also used for storing task granularity lists, analyzing different events or/and tasks and sending the events or/and tasks; and combining a plurality of different tasks into a task execution package for the task or/and the event task sent by the task manager, and sending the task execution package to the corresponding processor.
Further, the method also includes: creating a plurality of tasks of corresponding types according to different behaviors of artificial intelligence; calculating and presetting the time and complexity of the created task, and recording the task by using granularity, wherein the information recorded by the granularity comprises the complexity of the task, the consumption of system resources for completing the task and network resources required for completing the task; and sending the task granularity referred by the task to the task manager, and also using the same granularity to refer to the tasks with the same completion time and the same type.
Further, the method also includes: receiving a task created by the task creator, and storing the task in a task pool, wherein the task is stored in the task pool by a unique identifier and a data block; when the task is executed, the task granularity state information is dynamically modified correspondingly during the interaction process of the task data.
Further, the method also includes: acquiring a task unique identifier of a task pool, and further acquiring task data and granularity data; and sending the analyzed task to a task router for distribution processing.
Further, the method also includes: and merging the tasks with the same type into a task group, and further distributing the task group to a distributed processor for processing. The execution time and the complexity of the tasks in the event are acquired, and the event is divided according to the acquired information, wherein the event is processed by using a single processor for the tasks with large granularity and one or more processors for the tasks with small granularity.
The invention has the beneficial effects that: the development period of the game is greatly shortened, the maintainability and reusability of codes are enhanced, and the experience and the performance of the game are enhanced. Through the parallel virtual machines, the game can use a plurality of processors in one machine or a plurality of machines in one local area network, so that the game experience of the player is enhanced.
Drawings
FIG. 1 is a block diagram illustrating the general architecture of an embodiment according to the present invention;
FIG. 2 is a detailed block diagram according to an embodiment of the present invention;
fig. 3 is a task combination diagram according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments. The system and the method for designing the game artificial intelligence task are suitable for developing games such as stand-alone games, mobile phone games, web games and the like, and are particularly suitable for processing the game artificial intelligence task with a large-scale task.
Fig. 1 is a block diagram showing the overall structure of an embodiment according to the present invention. The processor may be any processor, including processors in computers, processors with processing capabilities in local area networks or the internet. The task creation module is positioned in the game program and is responsible for creating tasks, and the execution time and the complexity of the tasks need to be calculated during creation; the task storage module is used for storing task information and granularity, and can be an internal storage space of a game program or an external storage space; the task manager is responsible for preprocessing and sending tasks; the task router is mainly used for distributing tasks.
Fig. 2 is a detailed structural view illustrating an embodiment according to the present invention. All tasks take place in the processing unit. The processor on the motherboard or the computer resources in the local area network belong to the processing unit. The main game program may be understood as the "master" and all available processing units as its "workers". Thus, the relationship between the main game program and the attached processing units is clearly visible. The processing units do not host work, where they only handle some tasks for the game. A huge problem can subdivide a large number of "tasks" such as path generation, determining the spatial location of the gaming units, wall building, economic analysis, and other game-related activities. Each task is assigned a granularity to efficiently determine its scheduling ranking in the task manager. The granularity of a task may reflect the following information:
1. the size of the task;
2. the computational overhead required to accomplish this task;
3. the bandwidth required to achieve a solution.
Parallel virtual machines are generally better suited to handle those larger tasks. The process of creating a task, i.e. adding a new task to the task pool, generates considerable overhead compared to the actual processing of the task. Therefore, in order to be able to provide tasks to the parallel virtual machine that are more suitable for processing, we will typically only distribute those tasks that have a relatively wide working range, as shown in table 1 below:
fig. 3 is a task combination diagram according to an embodiment of the present invention. The path-finding tasks of the tanks and the soldiers are combined and sent to a single processor for processing due to the fact that time, complexity and types are the same and task granularity is small. The tactical map production and enclosure wall construction tasks have larger granularity and different time, complexity and types, and are processed by a plurality of processors.
Further, the embodiment of the invention also provides 2 practical cases, including a game delivery system and a production system:
(1) the game play-out system, in a typical instant strategy game, when a player conducts political negotiations with an AI body, a general AI system gives a response based on a previously scheduled response. These responses are typically generated based on finite heuristic data and based on enemy statistics (military forces, how close the enemy's unit of action is to the AI's city or base, etc.).
If the AI can evaluate the player's underlying motivation, the political environment it creates will better respond flexibly to the player's behavior and will better represent a near real-world political environment. Using the techniques described herein, a developer of an AI system may compile a series of evaluation tasks and perform the corresponding evaluation tasks based on the events that are currently occurring.
Suppose a player negotiates an out-of-the-field with an AI opponent. The player has nothing to deploy near the base of the AI, but the player has surreptitiously moved the military gradually and continuously from multiple countries to the base of the AI. The AI performs a task in the background to evaluate the whereabouts of enemy troops. By tracking the movement of enemy troops, the AI can determine that the player is staging troops from a number of different locations in the map, with the potential for intrusion into the AI base.
This type of evaluation logic must play an important role in the external negotiation. The AI can then offer to cut down the forces of a country. Since this country poses the most threat to a strategic base of AI.
(2) Another well-defined feature of the production system, for the development of a standard instant strategy game, is the ability of the AI system to manage production, food harvesting, research and development, and other economic activities of the gaming entity. All these functions are implemented as ideal background tasks, executed on other processing units. While the central control mechanism resides in the main program of the game.
In a typical instant strategy game, the core gaming entity acts to harvest a particular resource. These resources are then shipped to different factories, producing different gaming units or supplies. A parallel virtual machine task can be written to perform resource flow analysis on these plants. The task of this resource flow analysis is primarily to ensure that each factory has the appropriate resources available to produce or manufacture a particular gaming unit or other resource. Each plant may also have a direct or indirect consumer, depending entirely on the product produced by the plant.
The system can be used not only on the game AI, but also to assist the player. Many instant strategy games have managers who are responsible for managing and controlling cities or bases. These logic driving the AI system can also be used to operate a player's town and require little CPU overhead. Many AI systems can now accomplish these tasks, but if these tasks can be run in the background, more traditional resources can be released for other new tasks, providing a more immersive and complete gaming experience for the player.
The above description is only a preferred embodiment of the present invention, and the present invention is not limited to the above embodiment, and the present invention shall fall within the protection scope of the present invention as long as the technical effects of the present invention are achieved by the same means. The invention is capable of other modifications and variations in its technical solution and/or its implementation, within the scope of protection of the invention.