A kind of Visual Design System of the game artificial intelligence based on XML
Technical field
The present invention relates to a kind of Visual Design Systems of game artificial intelligence based on XML, belong to computer game neck
Domain.
Background technique
The artificial intelligence of game plays the role of very important in the development process of game, is directly related to the war of player
Bucket body is tested, while also being modified very frequently.When games increase new non-player role or the demand of system is sent out
Changing often will unavoidably be modified and increase more non-player role artificial intelligence, often may require that in this way it is a large amount of and
Many and diverse overprogram work, and the artificial intelligence of non-player role is realized in a manner of hard coded in general game item,
Each class realizes the special artificial intelligence logic of a non-player role, and general total amount is up to as many as tens.But game item people
The feature of work intelligence is mutability, similitude and repeatability.A large amount of substantially similar but specific logics are needed to be not quite similar again
Artificial intelligence, and the demand planned, among continuous variation with adjustment, this is to focus on user's body by this entertainment software of game
What the characteristics of inspection, determined.Therefore traditional AI implementation method disadvantage of this hard coded has:
1. planning can not directly become design realization, the excessive cycle for waiting program to realize, and propose demand change
Period it is similarly long, and test also very troublesome, effect is very uncontrollable to be realized to artificial intelligence, games need plan
It draws oneself to adjust to test repeatedly and can be only achieved good user experience, if the work of the excessive cycle meeting serious contusion planning of test
Make the efficiency of enthusiasm and exploitation.
2. program realizes that the workload of artificial intelligence is very big, a large amount of similar programs functions are wanted overlapping development and are adjusted repeatedly
It is whole, often it can give up to fall and largely plan beneficial design because workload is too big in actual operation, allow trip in turn in this way
The whole quality of play is affected.
3. project does not have the reusable artificial intelligence function of small grain size, whole development cost is too big, often under the pressure of project into
The pressure of degree can only make the artificial intelligence system of a relatively rough non-player role, seriously affect the game body of player
It tests.
Above-mentioned only a part of example, the exploitation of artificial intelligence may be because of communication, hobby during actual development
It can be more complicated.Therefore a kind of visualization, reusable, efficient artificial intelligent developed system can greatly shorten artificial intelligence
The development cycle of energy system, the reusability for enhancing code, the experience for increasing game.
Summary of the invention
For the low development efficiency of the prior art, the shortcomings that workload is excessive, artificial intelligence function that can not be multiplexed,
The game artificial intelligence Visual Design System based on XML that the present invention provides a kind of simplifies development process, the drop of artificial intelligence
Low workload, the maintainability for strengthening code.
Technical solution of the present invention uses XML language.XML language is a kind of extensible markup language, standard generalized markup
The subset of language is a kind of for marking electronic document to make it have structural markup language, has compatible existing protocol, system
Between one managing access to data mode, different application systems data it is shared with interact, bottom transmission data have more it is readable,
And a kind of data interchange format is belonged to json.
The technical scheme is that a kind of game artificial intelligence Visual Design System based on XML, the system include:
System logic device, including connection component and functional unit, the judgement that connection component is used to establish artificial intelligence in games are patrolled
Volume, functional unit is used to establish the Action logic of artificial intelligence in games, and wherein connection component includes at least one subgroup
Part;Graphic editor, including a personal-machine interaction graphics edition interface, for by the component with different graphic according to
Demand connection, forms the tree structure of artificial intelligence, wherein component includes connection component and functional unit;Function editing machine is used
Data configuration is carried out in the attribute to the component, is also used to write and store XML definition logic template, the template can answer
With being also used to edit corresponding functional interface function and realize the program function that the component is realized, and can be to program function
Interface function carries out customized editor, and the component property of data configuration and corresponding program interface functions are packaged into component Configuration
File;Figure configurator, for parsing the component profile, by the component property and program interface functions of data configuration
It is allocated to the corresponding component of tree structure of the artificial intelligence, component is made to possess complete function;Overall execution device, parsing is
The component that the artificial intelligence tree being configured is included, the component for being included to the artificial intelligence tree being configured successively into
Row is executed according to depth-first, is then traversed, is interrupted, backtracking process, become with the artificial of complete function
Intelligence.
Preferably, the connection component in the system logic device includes: sequencer, is sentenced for sequentially executing all returns
Disconnected result is genuine sub-component, if a upper sub-component judging result be it is false, no longer execute next sub-component;Selection
Device until selecting first judging result is genuine sub-component for executing, if a upper sub-component judging result be it is true,
Then no longer execute next sub-component;Circulator executes the certain number of sub-component for recycling, if the sub-component meets judgement
Condition is vacation, then exits circulation in advance and execute;Random device, for distributing an opposite probability to each sub-component, by random
Device randomly chooses one of sub-component according to probability and executes.
Further, the functional unit in the system logic device includes: behavior component, includes corresponding non-player role
Behavior belongs to the logic module of process performing, is a subassemblies, when games operation, obtains the XML data table of configuration
Show information, corresponding function interface is called to realize assembly function, to realize the behavior of non-player role in manipulation games;
Regulatory components, the behavior comprising corresponding non-player role, belong to the logic module for executing judgement, are a subassemblies, work as game
When program is run, the XML data for obtaining configuration indicates information, calls corresponding function interface to realize assembly function, to inquire
The state of non-player role.
Further, the graphic editor includes: visual edit module, using different figures to the connection group
Part and functional unit figure are indicated, and these figures are connected according to demand, form it into the tree-like of artificial intelligence
Structure.
Further, the function editing machine includes: XML data configuration module, for corresponding component property information
XML data configuration file is compiled as using xml editor;XML logic template editor module, can be to XML definition logic template
It is write, additionally it is possible to XML definition logic template is stored using tables of data, and the open parameter for defining logic template,
And XML definition logic template can be reused;Program function realizes interface configuration module, for matching to the XML data
The corresponding functional interface function of file configuration is set, the functional interface function is for realizing corresponding program function;Program function
It realizes interface editor module, for carrying out standard edition to functional interface function, enables functional interface function to the group of variation
Part function is realized.
Further, the overall execution device includes: traversal execution module, from the root component of the tree structure of artificial intelligence
Set out, according to depth-first traversal execute tree structure all components, wherein connection component include sequence, selection, circulation, with
4 kinds of logics of machine, regulatory components return to true or false, and after executing every time according to component logic, the letter of true or false is all returned to parent component
Breath then starts to execute the component until possessing the behavior component of time into some;Interrupt module, for indicating that component is being held
When row, judge whether to interrupt in the duration, indicates that rule meets if behavior is interrupted and interrupt;Backtracking module is used for
Expression behavior component can return to true or false to parent component after exiting, and parent component is recalled backward layer by layer again, until finding next hold
Every trade is, or returns to root component, then proceedes to recycle;Blocking module, for managing the state of game behavior, when game behavior
When static, the thread for controlling the game behavior will be suspended, i.e., if games are not to system return information, game row
For thread be suspended will not committed memory and game behavior will not arbitrarily change.
The invention has the benefit that greatly shortening the artificial intelligence system development cycle, Graphic Design is clear and intuitive, side
Just hierarchical logic is indicated, sequential logic, frame is simple, realizes that effect is controllable;Enhance code maintainability and reusability, editor
Device output XML file defines logic template, open parameter, and tables of data table can be multiplexed to template with design parameter convenient for template;
Enhance the experience and performance of game, graphical editor compares, by natural thinking organizational logical, to edit out letter with can be convenient
Single or more complicated artificial intelligence logic, it is natural to support the more difficult functions of doing of traditional artificial intelligences such as the continuous skill of boss;
The personnel of various positions are facilitated to share out the work and help one another, Optimizing Flow, designer and implementor reach target with specification of the same race, separation
The division of labor of program and planning.
Detailed description of the invention
Fig. 1 show the general frame of embodiment according to the present invention;
Fig. 2 a-2c show a kind of simple artificial intelligence realization figure of embodiment according to the present invention;
Fig. 3 a-3b show the functional unit realization figure of embodiment according to the present invention;
Fig. 4 a-4c show a kind of artificial intelligence realization figure of complexity of embodiment according to the present invention.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, right in the following with reference to the drawings and specific embodiments
The present invention is described in detail.A kind of game artificial intelligence Visual Design System based on XML of the invention uses specific
Field is in field of play, including single-play game, mobile phone games, web game etc..This set system is mainly non-character using object
In the game of the artificial intelligence of player (i.e. NPC).
Fig. 1 show the general frame of embodiment according to the present invention, includes system logic device, graphic editor, function
It can editing machine, figure configurator, overall execution device.Wherein, system logic device, including connection component and functional unit, connection group
Part is used to establish the decision logic of artificial intelligence in games, and functional unit is used to establish the row of artificial intelligence in games
For logic, wherein connection component includes at least one sub-component;Graphic editor, graphics edition circle including personal-machine interaction
Face forms the tree structure of artificial intelligence for will connect as desired in the component with different graphic;Function editor
Device carries out data configuration for the attribute to the component, is also used to write and store XML definition logic template, the template
It can be multiplexed, be also used to edit corresponding functional interface function and realize the program function that the component is realized, and can be to journey
Sequence functional interface function carries out customized editor, and the component property of data configuration and corresponding program interface functions are encapsulated in groups
Part configuration file;Figure configurator connects the component property of data configuration and program for parsing the component profile
Mouth function is allocated to the corresponding component of tree structure of the artificial intelligence, and component is made to possess complete function;Overall execution device,
Parse the component that the artificial intelligence tree being configured is included, the component for being included to the artificial intelligence tree being configured
It successively carries out being executed according to depth-first, is then traversed, interrupted, backtracking process, become with complete function
Artificial intelligence.For the tree structure of the artificial intelligence, each tree structure be by it is multiple can be by according to the present invention
Sub-component and the parent component composition that the system executes.
Fig. 2 a-2c show a kind of simple artificial intelligence figure implemented according to the present invention, and wherein Fig. 2 a is connection component
With functional unit graphic definition figure, Fig. 2 b is the tree structure of simple artificial intelligence, and Fig. 3 is the logical definition of functional unit.Its
Implementing procedure is, to functional unit and behavior component with graph-based, shown in figure respectively represent as circle represents non-object for appreciation
Family's character object, i.e. human skeleton monster, the oval random device in connection component, the sequencer for the connection component that hexagon indicates,
Rectangle indicates the behavior component in functional unit, and what octagon indicated is the regulatory components in functional unit;According to human skeleton
The component by graph-based of artificial intelligence and Fig. 2 c compile the tree structure of an artificial intelligence in graphic editor, so
Again the component for having formed tree structure is carried out configuring in order attribute afterwards and interface function realizes function, wherein XML attribute is matched
It is as follows to set part attribute,
<Node Name="ding_buff" type="Sequence" Node_id="9651">
<Conector Identifier="GenericChildren">
<Node event=">" Name="light_on" Operation="svo" range="(0,40)"
state="1" target="1149" Type="Condition" Node_id="9652"/>
<Node buff="120205" cd="-1" clearcd="0" Name="ding_buff"
Operation="buff" time="1" Type="Action" Node_id="9653"/>
</Conector>
</Node>
One functional unit of Node tag representation, main attribute are as follows: Name, title, for planning one group of annotation
Part function;
Type, the big classification of component, such as sequencer, selector etc.;Operation, the small classification of component, as program is specific
The various conditions realized, behavior component;The ID of Node_id, component can also define various make by oneself according to specific component programs
Adopted attribute is to user configuration.Then it configures corresponding interface function and realizes function, part of interface function realizes that function is defined as follows
Shown, Init function initializes artificial intelligence tree, transfers XML configuration attribute data;Execute function, every frame execute entrance;
Can_use function judges whether to be able to use, and mainly whether technical ability or behavior are in cooling (CD) state;activate
Function, each behavior are called, for sending agreement, pathfinding calculating etc.;Step function, every frame process performing;Update function, to
Parent component returns to true or false state;Terminate function, each process performing is called, for the state of clearing up.It finally executes artificial
The allomeric function of intelligent tree realizes that it is shown that steps are as follows, traverses AI tree, connection group from root component by the method for depth-first
Part has sequence, selects, circulation, random four kinds of semantemes, and regulatory components return to true or false, when each component executes, all according to component
Definition successively executive module, wherein sequencer is for executing all returns judging results sequentially from left to right as genuine subgroup
Part no longer executes next sub-component if the upper sub-component judging result executed is vacation;Selector be used for from a left side to
Being executed rightly until selecting first judging result is genuine sub-component, if the upper sub-component judging result executed is
Very, then next sub-component is no longer executed;Circulator executes the certain number of sub-component for recycling, if sub-component satisfaction is sentenced
Broken strip part is vacation, then exits circulation in advance and execute;Random device is used to distribute an opposite probability to each sub-component, by random
Device is randomly selected one of sub-component according to probability and executes.It executes every time and needs all to report true or false to parent component, until
Into the behavior component of some having time, start to execute the behavior;Have after housing choice behavior continue and interrupt, be persistently primarily referred to as by
Time continues, and behavior interruption refers to that ad hoc rules meets and interrupts;Behavior can report true or false to parent component after exiting, and parent component is again
Recall layer by layer, until finding next process performing, or returns to root component, and so on execute;Behavior component is obstruction, more
Meet the characteristics of efficiency is pursued in game, not will lead to the frequent switching of behavior.
Fig. 3 a-3b show functional unit realization figure according to the present invention, and wherein Fig. 3 a indicates behavior components example,
Fig. 3 b indicates functional unit few examples.Behavior component, the behavior comprising corresponding non-player role, belongs to the logic of process performing
Component is a subassemblies, and when games operation, the XML data for obtaining configuration indicates information, and corresponding function is called to connect
Cause for gossip shows assembly function, to realize the behavior of non-player role in manipulation games;Regulatory components include corresponding non-player
The behavior of role belongs to the logic module for executing judgement, is a subassemblies, when games operation, obtains the XML of configuration
Data representing information calls corresponding function interface to realize assembly function, to inquire the state of non-player role.Shown Fig. 3 a
All behaviors comprising a non-player role therefrom call behavior component, configuration pair when needing to implement certain behavior
Attribute and interface function is answered to realize.Fig. 3 b indicates the option that regulatory components are likely to occur, and according to possible condition, executes corresponding
Behavior.
Fig. 4 a-4c show a kind of artificial intelligence figure for the complexity implemented according to the present invention, and shown circle represents non-player
Character object, i.e. butcher's monster, ellipse are the random device in connection component, and the sequencer for the connection component that hexagon indicates is long
Behavior component in rectangular expression functional unit, what octagon indicated is the regulatory components in functional unit;It is real shown in the figure
Example possesses more complicated logic and configuration as Fig. 2 institute example process.Then Fig. 4 a connection 4b connects 4c and is combined into one
A artificial intelligence tree for completely possessing complicated behavior act.
The above, only presently preferred embodiments of the present invention, the invention is not limited to above embodiment, as long as
It reaches technical effect of the invention with identical means, all should belong to protection scope of the present invention.In protection model of the invention
Its technical solution and/or embodiment can have a variety of different modifications and variations in enclosing.