A kind of design system and method for game artificial intelligence task
Technical field
The present invention relates to a kind of design system and method for game artificial intelligence task, belongs to computer program development neck
Domain.
Background technology
Traditional game artificial intelligence system, either still run in service end in client, can only all utilize single line
The computing capability of journey, the system operation that can not make multi-threaded parallel so waste the computing capability of multi-core CPU, the day of one's doom
The operand of artificial intelligence is made so that the artificial intelligence expressive force of game is limited, and have impact on Consumer's Experience and the game of player
Substitution sense and also artificial intelligence there is no the concept of virtual machine, transplanted between multi processor platform and several operation systems it is difficult,
Increase the development cost of game.
The content of the invention
In view of the shortcomings of the prior art, technical scheme provides a kind of design department of game artificial intelligence task
System and method, are handled artificial intelligence by parallel virtual machine, compensate for prior art to artificial intelligence in large-scale task
The shortcomings that processing is present.
Technical scheme includes a kind of design system of game artificial intelligence task, it is characterised in that the system
Including:Job creator, for creating granularity corresponding with task in the task of establishment, granularity is used to believe being created for task
Breath is remembered that be additionally operable to establishment event, wherein event includes multiple tasks;Task memory, for being created for task to be deposited
Storage is additionally operable to obtain the task granularity that the job creator creates, and stored and created using granularity list to task pool
Build the reference unique identifier of corresponding granularity;Task manager, for obtaining the task and appoint that the task memory stored
Business granularity, it is additionally operable to not store task granularity row, analyzes different events or/and task and send;Task router,
For the task or/and event task sent to the task manager, multiple different tasks are combined into tasks carrying bag,
And send it to corresponding processor.
According to the design system of described game artificial intelligence task, described job creator also includes:Task creation
Module, for the different behaviors according to artificial intelligence, create the multiple tasks of corresponding types;Task granularity module, for wound
Building for task carries out spending time and complexity to be calculated and preset, and task is recorded using granularity, wherein granularity institute
Record information includes task complexity size, the system resources consumption for completing task, the Internet resources for completing required by task;Granularity
List block, for the task granularity cited in task to be sent to task manager, it is additionally operable to the identical deadline
And the task of same type is quoted using same granularity.
According to the design system of described game artificial intelligence task, described task memory also includes:Task pool mould
Block, being created for receiving the job creator for task, and by task store tasks pond, wherein task are in task pool with only
One identifier and data block are stored;Dynamic Granulation module, for when task when executed, then in the friendship to task data
During mutual process, task granularity status information is changed to deserved dynamic.
According to the design system of described game artificial intelligence task, described task manager also includes:Parsing module,
For obtaining task unique identifier in task pool, task data and granularity data are further obtained;Sending module, for that will solve
Task after analysis sends to task router and is distributed processing.
According to the design system of described game artificial intelligence task, described task router also includes:Task combines
Module, for that there will be same type task merging into task groups, task groups are further distributed to distributed processors and carried out
Processing.Event processing module, obtained for the execution time to the task in event and complexity, according to the information of acquisition
Division processing is carried out to event, including big granularity task is handled using single processor, to multiple small grain size tasks
Handled using one or several processors.
Technical scheme also includes a kind of design method of game artificial intelligence task, it is characterised in that the party
Method includes:Granularity corresponding with task is created in the task of establishment, granularity is used to remember the mission bit stream created, also used
In the event of establishment, wherein event includes multiple tasks;Being created for task is stored to task pool, is additionally operable to obtain the task
The task granularity that creator creates, and stored using granularity list and create the reference unique identifier of corresponding granularity;Obtain
The task and task granularity that the task memory is stored are taken, is additionally operable to not store task granularity row, analysis is different
Event or/and task and send;The task or/and event task sent to the task manager, multiple different are appointed
Business is combined into tasks carrying bag, and sends it to corresponding processor.
Further, this method also includes:According to the different behaviors of artificial intelligence, the multiple tasks of corresponding types are created;It is right
The task of establishment carries out spending time and complexity to be calculated and preset, and task is recorded using granularity, wherein granularity
Recorded information includes task complexity size, the system resources consumption for completing task, the Internet resources for completing required by task;Will
Task granularity cited in task is sent to task manager, is additionally operable to the task with identical deadline and same type
Quoted using same granularity.
Further, this method also includes:Receive the task that the job creator creates, and by task store tasks pond,
Wherein task is stored in task pool with unique identifier and data block;When task when executed, then to number of tasks
According to interaction when, to deserved dynamic change task granularity status information.
Further, this method also includes:Task pool task unique identifier is obtained, further obtains task data and granularity
Data;Task after parsing is sent to task router and is distributed processing.
Further, this method also includes:There to be same type task merging into task groups, further distribute task groups
Handled to distributed processors.Execution time and complexity to the task in event obtain, according to the letter of acquisition
Breath carries out division processing to event, including big granularity task is handled using single processor, and multiple small grain sizes are appointed
Make sure and handled with one or several processors.
Beneficial effects of the present invention are:The development of games cycle is greatly shortened, strengthens code maintainability and reusability, is increased
The experience played by force and the purpose of performance.By parallel virtual machine, the game of-money can both use multiple places in a machine
Device is managed, more machines in a LAN can also be used, so as to strengthen the game experiencing of player.
Brief description of the drawings
Fig. 1 show the general structure block diagram according to embodiment of the present invention;
Fig. 2 show the detailed structure view according to embodiment of the present invention;
Fig. 3 show the task constitutional diagram according to embodiment of the present invention.
Embodiment
In order that the object, technical solutions and advantages of the present invention are clearer, below in conjunction with the accompanying drawings with specific embodiment pair
The present invention is described in detail.The design system and method for the game artificial intelligence task of the present invention are applied to single-play game, hand
The exploitation of the game such as machine game, web game, the processing for the game artificial intelligence task that large-scale task be present that is particularly suitable for use in.
Fig. 1 show the general structure block diagram according to embodiment of the present invention.Processor therein can arbitrarily be located
The processor in device, including computer is managed, in addition to there is the processor of disposal ability in LAN or internet.Task is created
Modeling block be located in games, responsible establishment task, needs during establishment the execution time to task and complexity to calculate;
Task memory module, can be that games internal storage space can also be for being stored to mission bit stream and granularity
External memory space;Task manager is responsible for pretreatment and transmission to task;Task router is mainly used in dividing task
Hair.
Fig. 2 show the detailed structure view according to embodiment of the present invention.All tasks all occur in processing unit.
Processor on mainboard, or the computer resource in LAN, belong to processing unit.Game main program can be interpreted as
" owner ", and all available processing units are interpreted as its " worker ".So, game main program and attached processing unit
Between relation with regard to high-visible.Processing unit does not preside over work, and they are only there some tasks of game processing.By
One can segment out many " task " the problem of huge, such as the locus of coordinates measurement, determination placement game unit,
Make wall, economic analysis, and other behaviors related to game.Each task is all assigned a granularity, so as to effectively true
Determine its scheduling ranking in task manager.The granularity of one task can reflect following information:
1. the size of task;
2. complete the computing cost that this required by task is wanted;
3. reach the bandwidth required for a solution.
Parallel virtual machine is generally more suitable for handling those more large-scale tasks.Compared with the actual process of task,
The establishment process of task, that is, the process to task pool addition new task, can produce considerable overhead.So
In order to provide being more suitable for processing of the task to parallel virtual machine, it is relatively very wide that we generally only can distribute those working ranges
Task, it is as shown in table 1 below:
Fig. 3 show the task constitutional diagram according to embodiment of the present invention.The pathfinding task of tank therein and multiple soldiers by
In time, complexity and type is identical and task granularity is smaller, is combined and sends to single processor progress processor.Its
In production tactical map and to build enclosure wall job granularity larger, and time, complexity and type are different, then using more
Individual processor is handled.
Further, embodiments of the present invention also provide 2 real cases, including the diplomatic system of game and production system:
(1)Play diplomatic system, in a typical real time strategy, as player and AI main bodys expansion political negotiation,
In general AI systems are all to be replied according to the response prearranged to provide.These responses are typically based on limited inspiration
Formula data, further according to the statistics of enemy state(Military strength, the close degree in the city of the combat unit of enemy army and AI or base etc.)
Generate what is come.
If AI can evaluate the potential motivation of player, then it is created that the political setting come, it becomes possible to more preferable
Flexible response is made in behavior of the ground to player, also can more show the political setting close to real world.Using introducing herein
Technology, the developer of AI systems can write out a series of assessment task, and be performed according to the event currently occurred
It is corresponding to assess task.
Assuming that player deploys a diplomatic negotiations with an AI opponent.What combat unit player, which does not have, is deployed in AI's
Near base, but player little by little, constantly moves troops from multiple countries to AI base in the dark.AI is being held from the background
A task is gone, to assess the whereabouts of hostile forces.By keeping track of the situation of movement of hostile forces, AI is assured that
Player mass troops from map by multiple different positions, there is the potentially possible of invasion AI bases.
Such assessment logic is bound to play an important role in diplomatic negotiations.Then, AI cans are proposed,
Player is allowed to cut down some national troops.Because this country threatens an AI strategic base maximum.
(2)Production system, the exploitation of the real time strategy for a standard, its another quite clear and definite spy
Color, it is to allow AI systems to have the ability to manage the production of game unit, harvest food, research and development, and other economic activities.Institute
The realization for having these functions is all used as preferable background task, is performed on other processing units.And central control machine system is then stayed
Stay in the main program of game.
In a typical real time strategy, the game unit of core takes on the angle for harvesting certain specific resources
Color.Then, these resources are transported to different factories, produce different game units or supply.One can be write simultaneously
Row virtual machine task, resources flowing amount analysis is carried out to these factories.The action of this resources flowing amount analysis is mainly to ensure that
There is appropriate resource in each factory, can be used for producing or manufacturing some specific game unit or other resources.Each work
Factory can also have a direct or indirect consumer, the product for the plant produced that places one's entire reliance upon.
This system not only can may also help in player with game AI.Have in many real time strategies
Manager, they are responsible for and controlled city or base.These logics of driving AI systems may also used to run player
Cities and towns, and only need seldom CPU overhead.Many AI systems can realize these tasks now, but if can allow
These tasks are in running background, it is possible to discharge more traditional resources for other new tasks, it is more heavy to be provided for player
Leaching sense, more complete game experiencing.
It is described above, simply presently preferred embodiments of the present invention, the invention is not limited in above-mentioned embodiment, as long as
It reaches the technique effect of the present invention with identical means, should all belong to protection scope of the present invention.In the protection model of the present invention
Its technical scheme and/or embodiment can have a variety of modifications and variations in enclosing.