CN110102054A - Execution optimization method, device and the storage medium of behavior tree - Google Patents
Execution optimization method, device and the storage medium of behavior tree Download PDFInfo
- Publication number
- CN110102054A CN110102054A CN201910387868.4A CN201910387868A CN110102054A CN 110102054 A CN110102054 A CN 110102054A CN 201910387868 A CN201910387868 A CN 201910387868A CN 110102054 A CN110102054 A CN 110102054A
- Authority
- CN
- China
- Prior art keywords
- node
- behavior
- behavior tree
- function
- tree
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/55—Controlling game characters or game objects based on the game progress
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/60—Generating or modifying game content before or while executing the game program, e.g. authoring tools specially adapted for game development or game-integrated level editor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
- G06F17/10—Complex mathematical operations
- G06F17/15—Correlation function computation including computation of convolution operations
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Computational Mathematics (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Computing Systems (AREA)
- Databases & Information Systems (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Algebra (AREA)
- Human Computer Interaction (AREA)
- Stored Programmes (AREA)
Abstract
The embodiment of the present invention provides a kind of execution optimization method of behavior tree, device and storage medium, method includes: to read an initial behavior tree to execute file, obtain the control node function in the initial behavior tree execution corresponding behavior tree of file, behavior tree includes control node function and behavior node function, analysis and Control node function, obtain behavior node function executes sequence, and sequence is executed according to behavior node function, it rebuilds behavior tree and executes file, behavior tree after rebuilding executes in the corresponding behavior tree of file comprising whole behavior node functions, the number that behavior tree after rebuilding executes the control node function for including in the corresponding behavior tree of file executes the number for the control node function for including in the corresponding behavior tree of file less than initial behavior tree, file process performing tree is executed according to the behavior tree after rebuilding , to reduce execution time of the behavior tree on control skip, reduce processor resource expense.
Description
Technical field
The present embodiments relate to game artificial intelligence (Artificial Intelligence, referred to as: AI), especially relate to
And a kind of execution optimization method, device and the storage medium of behavior tree.
Background technique
In order to which player creates spectacular experience, game AI is almost present in the every nook and cranny in game, constructs one
The huge gaming world each and every one to fire one's imagination.Therefore, good game AI is designed, the interactivity of game can be increased, improves and plays
The sense of reality and stickiness of family.There are many implementation of game AI, and rule-based solidification code from the beginning is realized, to being based on
The finite-state automata of state, then the Behavior-based control tree of mainstream till now, logic that is constantly open and simplifying allow project staff
Writing for game AI can also be played an active part in.
Specifically, behavior tree includes a large amount of tree node, and program staff provides items by realizing tree node one by one
The node function on basis, wherein node function includes control node function and behavior node function.Project staff is by combining this
A little tree nodes allow game unit that can be directed to the game environment of surrounding, make suitable behavior reaction.
On the one hand, client is practised fraud in order to prevent, and behavior tree is normally operated in server-side;On the other hand, in order to which player is anti-
In time, behavior tree interior joint function by high-frequency calls again for feedback;In another aspect, there are a large amount of node function in behavior tree,
These characteristics can mean that the game AI realization of Behavior-based control tree can bring a large amount of processor resource expense.
Summary of the invention
The embodiment of the present invention provides execution optimization method, device and the storage medium of a kind of behavior tree, to reduce server-side
Operation action tree bring processor resource expense.
In a first aspect, the embodiment of the present invention provides a kind of execution optimization method of behavior tree, comprising:
It reads an initial behavior tree and executes file, obtain the control in the initial behavior tree execution corresponding behavior tree of file
Node function processed, the behavior tree include control node function and behavior node function;
The control node function is analyzed, obtain the behavior node function executes sequence;
Sequence is executed according to the behavior node function, the behavior tree is rebuild and executes file, the structure again
Behavior tree after building executes in file comprising all behavior node functions, it is described rebuild after behavior tree execution file
The number for the control node function for including in corresponding behavior tree executes the corresponding behavior tree of file less than the initial behavior tree
In include control node function number;
File, which is executed, according to the behavior tree after described rebuild executes the behavior tree.
Second aspect, the embodiment of the present invention provide a kind of execution optimization device of behavior tree, comprising:
Module is obtained, executes file for reading an initial behavior tree, it is corresponding that the acquisition initial behavior tree executes file
Behavior tree in control node function, the behavior tree include control node function and behavior node function;
Analysis module, for analyzing the control node function, obtain the behavior node function executes sequence;
Building module rebuilds the behavior tree and executes text for executing sequence according to the behavior node function
Part, it is described rebuild after behavior tree execute in file comprising all behavior node functions, it is described rebuild after
The number that behavior tree executes the control node function for including in the corresponding behavior tree of file executes text less than the initial behavior tree
The number for the control node function for including in the corresponding behavior tree of part;
Execution module executes file for the behavior tree after rebuilding according to and executes the behavior tree.
The third aspect, the embodiment of the present invention provide a kind of execution optimization device of behavior tree, comprising:
For storing the memory and processor of program instruction;
When described program instruction is executed by the processor, so that the execution optimization device of the behavior tree realizes such as the
Method described in any one of one side.
Fourth aspect, the embodiment of the present invention provide a kind of computer readable storage medium, are stored thereon with computer program,
The method as described in any one of first aspect is realized when the computer program is executed by processor.
The embodiment of the present invention provides execution optimization method, device and the storage medium of a kind of behavior tree, is read at the beginning of one first
It begins and executes file for tree, obtain the control node function in the initial behavior tree execution corresponding behavior tree of file, behavior tree
Including control node function and behavior node function, later, analysis and Control node function, the execution for obtaining behavior node function is suitable
Sequence, and sequence is executed according to behavior node function, it rebuilds behavior tree and executes file, wherein the behavior after rebuilding
It is corresponding that the behavior tree that tree executes comprising whole behavior node functions in the corresponding behavior tree of file, after rebuilding executes file
The number for the control node function for including in behavior tree executes the control for including in the corresponding behavior tree of file less than initial behavior tree
The number of node function processed executes file process performing tree according to the behavior tree after rebuilding.Due to the row after rebuilding
The control node function for including in the corresponding behavior tree of file, which is executed, for tree executes the corresponding behavior of file less than initial behavior tree
The number for the control node function for including in tree, eliminates the execution of at least partly control node function, to reduce behavior tree
The execution time on control skip reduces processor resource expense.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technical description to do one simply to introduce, it should be apparent that, the accompanying drawings in the following description is this hair
Bright some embodiments for those of ordinary skill in the art without creative efforts, can be with root
Other attached drawings are obtained according to these attached drawings.
Fig. 1 is the flow chart of the execution optimization method for the behavior tree that one embodiment of the invention provides;
Fig. 2 is hunter's AI behavior tree exemplary diagram in a game;
Fig. 3 be Fig. 2 shown in hunter's AI behavior tree after optimization jump schematic diagram;
Fig. 4 is the behavior tree exemplary diagram for including Special controlling node;
Fig. 5 is distribution example figure of the optimization rate that provides of one embodiment of the invention with respect to sheetage;
Fig. 6 is the structural schematic diagram of the execution optimization device for the behavior tree that one embodiment of the invention provides;
Fig. 7 be another embodiment of the present invention provides behavior tree execute optimize device structural schematic diagram.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical solution in the embodiment of the present invention is described, it is clear that described embodiment is a part of the invention
Embodiment, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art are not making wound
Every other embodiment obtained under the premise of the property made labour, shall fall within the protection scope of the present invention.
It should be noted that the term " first ", " second " etc. in each section of the embodiment of the present invention and attached drawing are for area
Not similar object, without being used to describe a particular order or precedence order.It should be understood that the data used in this way are appropriate
In the case of can be interchanged, so as to the embodiment of the present invention described herein can in addition to those of illustrate or describe herein with
Outer sequence is implemented.In addition, term " includes " and " having " and their any deformation, it is intended that cover non-exclusive packet
Contain, for example, what the process, method, system, product or equipment for containing a series of steps or units were not necessarily limited to be clearly listed
Those step or units, but may include be not clearly listed or it is intrinsic for these process, methods, product or equipment
Other step or units.
Method flow diagram involved in the following embodiments of the present invention is merely illustrative, it is not necessary in all
Appearance and step, nor is it necessary that and execute in the described sequence.For example, some steps can also decompose, and some steps can
To merge or partially merge, therefore, the sequence actually executed can change according to the actual situation.
Functional module in block diagram involved in the following embodiments of the present invention is only functional entity, not necessarily must be with
Physically separate entity is corresponding.I.e., it is possible to realize these functional entitys using software form, or in one or more hardware
It is realized in module or integrated circuit in these functional entitys or heterogeneous networks and/or processor and/or microcontroller and realizes this
A little functional entitys.
To solve the technical issues of game AI realization of Behavior-based control tree can bring a large amount of processor resource expense, this hair
Bright embodiment provides a kind of execution prioritization scheme of behavior tree based on control node expansion, by saving to control in behavior tree
The analysis of point function obtains next behavior section needed to be implemented after each behavior node function runs succeeded or fails
Point function, to skip control node function, direct construction goes out the behavioral chain for from the beginning going to tail.The building process can be with
Control node expansion of a function is regarded as, because will only be left to really need the behavior of execution in behavior tree after rebuilding successfully
Node function, or, the behavior node function and a small amount of control node function that need to be implemented.
Multiple examples are combined to be situated between the execution optimization method of behavior tree provided in an embodiment of the present invention, device and storage as follows
Matter is illustrated.
Fig. 1 is the flow chart of the execution optimization method for the behavior tree that one embodiment of the invention provides.The execution of behavior tree
Optimization method can execute corresponding software code realization by server-side or the processing equipment of terminal, such as processor, can also be by this
The processing equipment of server-side or terminal executes corresponding software code, and other hardware entities is combined to realize.Wherein, server-side example
Server in this way, terminal are, for example, the equipment that mobile phone, plate etc. can run single-play game.Wherein, server can be a clothes
Business device, or the server cluster consisted of several servers or a cloud computing service center, etc..
As shown in Figure 1, the execution optimization method method of behavior tree shown in the present embodiment includes the following steps:
S101, an initial behavior tree execution file is read, obtains initial behavior tree and executes in the corresponding behavior tree of file
Control node function.
Wherein, behavior tree includes control node function and behavior node function.
S102, analysis and Control node function, obtain behavior node function executes sequence.
S103, sequence is executed according to behavior node function, rebuilds behavior tree and executes file.
Wherein, the behavior tree after rebuilding executes comprising whole behavior node functions in the corresponding behavior tree of file, and,
Behavior tree after rebuilding executes the number for the control node function for including in the corresponding behavior tree of file less than initial behavior
Tree executes the number for the control node function for including in the corresponding behavior tree of file.
S104, file process performing tree is executed according to the behavior tree after rebuilding.
Fig. 2 is hunter's AI behavior tree exemplary diagram in a game.As shown in Fig. 2, the section that the hunter AI behavior tree includes
Point has:
Ingress node: Entry;
Sequential node: Sequence;
Select node: Selector;
And behavior node: morning (Morning?), starvation (Hunger?), go hunting (Hunt), at night (Night?), it sleeps
Feel (Sleep).
The logic of behavior tree goes to go hunting when being hunter's AI starvation in morning, sleeps at night.
Wherein, sequential node and selection node belong to control node.
If it is the entrance of behavior tree that in behavior tree, uppermost node, which is Ingress node, without specified otherwise;Intermediate
Node belongs to control node, executes jumping for process for controlling;Nethermost node belongs to behavior node, for executing reality
Function.Each node can return successfully or fail.Wherein, the function for being related to Ingress node is known as Ingress node function,
The function for being related to control node is known as control node function, and the function for being related to behavior node is known as behavior node function.
This hunter AI behavior tree is analyzed it is found that the behavior node of first execution must be most lower-left when executing every time
Angle " Morning? " node;It is next because its father node is Sequence node if the node runs succeeded
Execute must be " Hunger? " node;If the node executes failure, also mean that father node Sequence node executes mistake
It loses, and grandfather's node of the node is Selector node, so can go to execute first inside next Sequence node
A behavior node, that is, " Night? " node.And so on, will obtain it is as shown in Figure 3 jump figure, refer to wherein jumping line
Next behavior node to be executed when running succeeded or failing to present node, " 1 " indicate that present node runs succeeded,
" 0 " indicates that present node executes failure.
The hunter AI behavior tree of execution to be optimized includes 9 functions, 9 nodes in behavior tree is respectively corresponded, wherein 4
Control node function, 5 behavior node functions, control node function do not execute any behavioral function, are only responsible for behavior node
Function is called.
After the processing by above-mentioned S101 to S103, what is obtained executes the behavior tree after control node functional expansion
File only includes 5 behavior node functions, and 4 original control node functions are all deleted.In new behavior node letter
In number, other than comprising original function, also additionally include run succeeded or failure after, the behavior that needs to be implemented next time
Node function, so as to the execution logic of the multiple hunter AI behavior tree for carving original execution to be optimized.After optimization, eliminate at most
4 function calls, and in program language, the processor expense of function call is very big, wherein created comprising parameter pop down, frame,
The processes such as recursive protection, abnormal mechanism, so the overall execution time that behavior tree executes file can predictably be reduced.
The behavior tree code of comparison optimization front and back, the latter is than the former few part control node function bring expense.?
In the later period of game item exploitation, perfect due to game AI function, behavior tree is all very huge and too fat to move, comprising a large amount of node
Function, wherein about half is control node function, by reducing function call time to these control node expansion of a functions
Number, to improve the execution efficiency that behavior tree executes file.
It should be noted that the embodiment of the present invention can regard the primary reconstruct to original behavior tree code, therefore nothing as
The method of calling of behavior tree need to be changed, can directly Seamless integration- behavior tree execution file export process in.
In practical applications, in order to which initial behavior tree to be executed to the control node functional expansion in file respective behavior tree,
Following three functions can be introduced:
1.get_start_node is obtained under present node, the behavior node of first execution
When 2.get_next_node_true acquisition present node runs succeeded, the behavior node of next execution
When 3.get_next_node_false obtains present node execution failure, the behavior node of next execution
In this way, entire Optimizing Flow can be sketched are as follows:
Step 1 defines a container C;
Step 2, the behavior node s that lower first execution of Ingress node is obtained by get_start_node;
Container C is added in behavior node s by step 3;
Step 4 takes out a node curr_s from container;
Step 5 obtains next execution when present node curr_s runs succeeded by get_next_node_true
Behavior node next_ture_s;
Step 6 records next_ture_s on present node curr_s, and container C is added in next_ture_s;
Step 7 obtains next execution when present node curr_s execution failure by get_next_node_false
Behavior node next_false_s;
Step 8 records next_false_s on present node curr_s, and container C is added in next_false_s;
Step 9 repeats step 4-step 8, until container C is sky.
By above-mentioned Optimizing Flow, can be recorded on each behavior node behavior node run succeeded or failure after
The behavior node of next execution completes the function of entire behavior tree so as to successively execute each behavior node.
The execution optimization method of the behavior tree of the embodiment of the present invention reads an initial behavior tree first and executes file, obtains
Initial behavior tree executes the control node function in the corresponding behavior tree of file, and behavior tree includes control node function and behavior
Node function, later, analysis and Control node function obtain the sequence that executes of behavior node function, and according to behavior node function
Execute sequence, rebuild behavior tree execute file, wherein after rebuilding behavior tree execution the corresponding behavior tree of file
In comprising whole behavior node functions, the control node that includes in the behavior tree execution corresponding behavior tree of file after rebuilding
The number of function executes the number for the control node function for including in the corresponding behavior tree of file less than initial behavior tree, according to weight
Behavior tree after new building executes file process performing tree.Since the behavior tree after rebuilding executes the corresponding behavior tree of file
In include control node function less than initial behavior tree execution the corresponding behavior tree of file in include control node function
Number, eliminates the execution of at least partly control node function, to reduce execution time of the behavior tree on control skip, drops
Low processor resource overhead.
In any embodiment of the present invention, control node function can be only comprising being related to the control node of general controls node
Function.At this point, it only includes behavior node function in file that behavior tree, which executes, control node function is not included.
It is appreciated that the execution of general controls node function is eliminated since behavior tree executes in file, to reduce row
To set the execution time on control skip, processor resource expense is reduced.
Optionally, general controls node may include it is following at least one: sequential node, selection node, state successfully to save
Point, statement failure node and statement negate node etc..Wherein:
Sequential node, order of representation go to its corresponding child node, until a child node returns to failure.
Node is selected, order of representation goes to its corresponding child node, until a child node returns successfully.
It states successful node, indicates to execute its corresponding child node, and return to success.
It states failure node, indicates to execute its corresponding child node, and return to failure.
Statement negates node, indicates to execute its corresponding child node, and the return value of its child node is negated.
For the above-mentioned each node referred to, corresponding details are as shown in table 1.
Table 1
Corresponding table 1, the specific implementation of three functions introduced before being given below.
The specific implementation of 1.get_start_node
If present node is behavior node, illustrate no child node, first execution is present node;Otherwise, it says
Bright present node is a control node, comprising quantity be greater than 0 child node, first execution must be first son section
Point, but since first child node is possible to a still control node, so recurrence is needed to look for down.
The specific implementation of 2.get_next_node_true
The behavior node of next execution after running succeeded for calculating arbitrary node, needs to analyze its father node:
If the father node of present node is Ingress node, illustrate that present node has executed rear entire behavior tree and has been carried out
, and present node runs succeeded at present, so returning to successfully (True);
If the father node of present node is selection node, because selection node goes to a child node and runs succeeded i.e.
Stop and return success, so need to observe the father node of father node, here can recursive call father node get_next_
node_true;
If the father node of present node is sequential node, because the child node of sequential node, which runs succeeded, to be held always
Row goes down, so if present node has next brother node, because next brother node is likely to be control node, just
Need to return the get_start_node result of next brother node;If there is no next brother node, father's section is represented
Point, which executes, to be terminated and returns to success, so the get_next_node_true of recursive call father node;
If the father node of present node is statement successful node, no matter what the implementing result of child node is, father node
It returns successfully forever, so the get_next_node_true of recursive call father node here;
If the father node of present node is statement failure node, no matter what the implementing result of child node is, father node
Failure is returned forever, so the get_next_node_false of recursive call father node here;
If the father node of present node is that statement negates node, and present node runs succeeded, and illustrates that father node can return
Failure is returned, so the get_next_node_false of recursive call father node can here
The specific implementation of 3.get_next_node_false
The function performance is similar with get_next_node_true, and details are not described herein again explains.
Therefore, alternatively, S102, analysis and Control node function, the execution for obtaining behavior node function are suitable
Sequence may include: to obtain the behavior node letter of corresponding first execution of control node function for each control node function
Number;According to the father node of behavior node function, the behavior of next execution after the behavior node function of determination runs succeeded or fails
Node function, until all behavior node functions have executed in control node function.
Control node mentioned above only has 5 fundamental types, although most behavior tree is with this 5 in a project
Fundamental type can complete logic task, but each project more or less has oneself some dedicated Special controlling section
Point.
Therefore, in some embodiments, control node function further includes being related to the control node function of Special controlling node.This
When, it includes simultaneously to be related to the control of general controls node that initial behavior tree, which executes the control node function in the corresponding behavior tree of file,
Node function processed and it is related to the control node function of Special controlling node.Corresponding this kind of situation, the behavior tree after rebuilding are held
In the style of writing corresponding behavior tree of part while comprising whole behavior node functions and being related to the control node function of Special controlling node.
Optionally, Special controlling node may include it is following at least one: parallel node, random node, out-of-order selection section
Point and single node etc..Wherein:
Parallel node, order of representation execute its corresponding all child node.
Random node indicates that its corresponding child node of random selection executes.
Random ordering selection node, indicates its corresponding child node of Out-of-order execution, until wherein a child node is fed back successfully.
Single node indicates most Exactly-once child nodes.
For above-mentioned Special controlling node, corresponding details are as shown in table 2.
Table 2
Under these Special controlling nodes shown in table 2, to realize above-mentioned three referred to function (get_start_
Node, get_next_node_true, get_next_node_false), process is more complicated.Illustratively, parallel node
Get_next_node_false solve, when calculating to a last child node, even if knowing that the last one child node is held
Row failure, without the brotgher of node before it implementing result in the case where, and can not judge the parallel node be return at
Function still fails.Alternatively, in the get_start_node solution of random node, because random node is one son section of random selection
Point executes, so what the child node for being not aware that first execution in behavior tree optimization is.
The Special controlling node that these can not be obtained with skip chain in optimization process, during behavior tree optimization
Need to skip these nodes.By taking parallel node shown in Fig. 4 as an example, during carrying out behavior tree optimization, first by lower-left
The parallel node at angle is handled as a behavior node, then obtains the skip chain of first layer;Then, under parallel node
All subtrees (Subtree) carry out Recursion process, be respectively completed the generation of the skip chain under each subtree;Finally, by all sons
Skip chain under tree combines the expansion optimization for completing whole behavior tree.
Illustratively, nearly 700 behavior trees in the inhuman study column project of H52 are chosen, execute every behavior tree 1000 respectively
It is secondary, the overall execution time T1 and wherein behavior node function execution time T2 of behavior tree are recorded, then control node function
The execution time is T1-T2.Wherein, optimization rate can be with is defined as: (T1-T2)/T1.
Meanwhile for every behavior tree in nearly 700 behavior trees, the quantity C1 and general controls section of all nodes are counted
The quantity C2 of point, and by sheetage is defined as: C2/C1.
Fig. 5 gives distribution of the optimization rate with respect to sheetage, wherein abscissa represents sheetage, ordinate representing optimized
Rate.With reference to Fig. 5, it can be found that the optimization rate of most behavior tree all concentrates on 80% or so.To the excellent of all behavior trees
Rate, which is averaged, to be obtained, and execute the time compared to the control skip before optimization, and the control skip execution time after optimization saves
18% or so.
Following is apparatus of the present invention embodiment, can be used for executing above method embodiment of the present invention, realization principle and
Technical effect is similar.
Fig. 6 is the structural schematic diagram of the execution optimization device for the behavior tree that one embodiment of the invention provides.As shown in fig. 6,
The execution optimization device 60 of the behavior tree of the present embodiment may include: to obtain module 61, analysis module 62, building module 63 and hold
Row module 64.Wherein:
Module 61 is obtained, file is executed for reading an initial behavior tree, it is corresponding to obtain initial behavior tree execution file
Control node function in behavior tree.Wherein, behavior tree includes control node function and behavior node function.
Analysis module 62 is used for analysis and Control node function, and obtain behavior node function in behavior tree executes sequence.
Module 63 is constructed, for executing sequence according to behavior node function, behavior tree is rebuild and executes file.Its
In, which executes the behavior tree execution comprising whole behavior node functions in file, after rebuilding
The number for the control node function for including in the corresponding behavior tree of file executes the corresponding behavior tree of file less than initial behavior tree
In include control node function number.
Execution module 64, for executing file process performing tree according to the behavior tree after rebuilding.
The execution of the behavior tree of the present embodiment optimizes device, reads an initial behavior tree first and executes file, obtains initial
Behavior tree executes the control node function in the corresponding behavior tree of file, and behavior tree includes control node function and behavior node
Function, later, analysis and Control node function obtains the sequence that executes of behavior node function, and holding according to behavior node function
Row sequence rebuilds behavior tree and executes file, wherein the behavior tree after rebuilding executes wraps in the corresponding behavior tree of file
Containing whole behavior node functions, the behavior tree after rebuilding executes the control node function for including in the corresponding behavior tree of file
Number less than initial behavior tree execution the corresponding behavior tree of file in include control node function number, according to structure again
Behavior tree after building executes file process performing tree.It is wrapped since the behavior tree after rebuilding executes in the corresponding behavior tree of file
The control node function contained executes the number for the control node function for including in the corresponding behavior tree of file less than initial behavior tree,
The execution of at least partly control node function is eliminated, so that execution time of the behavior tree on control skip is reduced, at reduction
Manage device resource overhead.
In above-described embodiment, control node function may include: to be related to the control node function of general controls node;Or
Person is related to the control node function of general controls node and is related to the control node function of Special controlling node.
Behavior tree when control node function includes the control node function for being related to Special controlling node, after rebuilding
It executes in the corresponding behavior tree of file also comprising being related to the control node function of these Special controlling nodes.After rebuilding
Behavior tree execute in the corresponding behavior tree of file only comprising whole behavior node functions be related to the control of Special controlling node
Node function, eliminates the execution of at least general controls node function, to reduce behavior tree in the execution on control skip
Between, reduce processor resource expense.
Optionally, general controls node may include it is following at least one: sequential node, selection node, state successfully to save
Point, statement failure node and statement negate node etc..Wherein:
Sequential node, order of representation go to its corresponding child node, until a child node returns to failure;
Node is selected, order of representation goes to its corresponding child node, until a child node returns successfully;
It states successful node, indicates to execute its corresponding child node, and return to success;
It states failure node, indicates to execute its corresponding child node, and return to failure;
Statement negates node, indicates to execute its corresponding child node, and the return value of its child node is negated.
Optionally, Special controlling node include it is following at least one: parallel node, random node, out-of-order selection node and
Single node etc..Wherein:
Parallel node, order of representation execute its corresponding all child node;
Random node indicates that its corresponding child node of random selection executes;
Random ordering selection node, indicates its corresponding child node of Out-of-order execution, until wherein a child node is fed back successfully;
Single node indicates most Exactly-once child nodes.
Alternatively, analysis module 62 can be specifically used for:
For each control node function, the behavior node function of corresponding first execution of control node function is obtained;
According to the father node of behavior node function, next execution after the behavior node function of determination runs succeeded or fails
Behavior node function, until all behavior node functions have executed in control node function.
Fig. 7 be another embodiment of the present invention provides behavior tree execute optimize device structural schematic diagram.Such as Fig. 7 institute
Show, the execution optimization device 70 of the behavior tree of the present embodiment includes: memory 71 and processor 72.Wherein, memory 71 and place
It is connected with each other between reason device 72.
Memory 71, for storing program instruction.
When the program instruction that memory 71 stores is executed by processor 72, so that the execution optimization device 70 of behavior tree is held
Method of the row as described in above-mentioned any embodiment.
Optionally, processor 72 is CPU.
Illustratively, the execution optimization device 70 of behavior tree can be server-side or terminal.Illustratively, server-side can be with
Specially server, terminal are, for example, the equipment that mobile phone, plate etc. can run single-play game.Wherein, server can be one
Server, or the server cluster consisted of several servers or a cloud computing service center, etc..
The execution of the behavior tree of the embodiment of the present invention optimizes device, reads an initial behavior tree first and executes file, obtains
Initial behavior tree executes the control node function in the corresponding behavior tree of file, and behavior tree includes control node function and behavior
Node function, later, analysis and Control node function obtain the sequence that executes of behavior node function, and according to behavior node function
Execute sequence, rebuild behavior tree execute file, wherein after rebuilding behavior tree execution the corresponding behavior tree of file
In comprising whole behavior node functions, the control node that includes in the behavior tree execution corresponding behavior tree of file after rebuilding
The number of function executes the number for the control node function for including in the corresponding behavior tree of file less than initial behavior tree, according to weight
Behavior tree after new building executes file process performing tree.Since the behavior tree after rebuilding executes the corresponding behavior tree of file
In include control node function less than initial behavior tree execution the corresponding behavior tree of file in include control node function
Number, eliminates the execution of at least partly control node function, to reduce execution time of the behavior tree on control skip, drops
Low processor resource overhead.
The embodiment of the present invention also provides a kind of computer readable storage medium, is stored thereon with computer program, the calculating
Machine program can be executed by processor method, specific implementation and effective effect shown in the upper any embodiment of realization, reference can be made on
It states, details are not described herein.
Those of ordinary skill in the art will appreciate that: realize that all or part of the steps of above-mentioned each method embodiment can lead to
The relevant hardware of program instruction is crossed to complete.Computer program above-mentioned can store in a computer-readable storage medium
In.When being executed, execution includes the steps that above-mentioned each method embodiment to the program;And storage medium above-mentioned includes: in read-only
Deposit (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or light
The various media that can store program code such as disk.
Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention., rather than its limitations;To the greatest extent
Pipe present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: its according to
So be possible to modify the technical solutions described in the foregoing embodiments, or to some or all of the technical features into
Row equivalent replacement;And these are modified or replaceed, various embodiments of the present invention technology that it does not separate the essence of the corresponding technical solution
The range of scheme.
Claims (12)
1. a kind of execution optimization method of behavior tree characterized by comprising
It reads an initial behavior tree and executes file, obtain the control section in the initial behavior tree execution corresponding behavior tree of file
Point function, the behavior tree include control node function and behavior node function;
The control node function is analyzed, obtain the behavior node function executes sequence;
Sequence is executed according to the behavior node function, the behavior tree is rebuild and executes file, wherein the structure again
Behavior tree after building executes in the corresponding behavior tree of file comprising the whole behavior node functions, it is described rebuild after row
The number for executing the control node function for including in the corresponding behavior tree of file for tree executes file less than the initial behavior tree
The number for the control node function for including in corresponding behavior tree;
File, which is executed, according to the behavior tree after described rebuild executes the behavior tree.
2. the method according to claim 1, wherein the control node function includes: to be related to general controls section
The control node function of point.
3. according to the method described in claim 2, it is characterized in that, the general controls node include it is following at least one:
Sequential node, selection node, statement successful node, statement failure node and statement negate node;
Wherein, sequential node order of representation goes to its corresponding child node, until a child node returns to failure;
Selection node order of representation goes to its corresponding child node, until a child node returns successfully;
It states that successful node indicates to execute its corresponding child node, and returns to success;
It states that failure node indicates to execute its corresponding child node, and returns to failure;
Statement negates node and indicates to execute its corresponding child node, and the return value of its child node is negated.
4. according to the method described in claim 2, it is characterized in that, the control node function further includes being related to Special controlling section
Point control node function, it is described rebuild after behavior tree execute the corresponding behavior tree of file in also include be related to the spy
The control node function of different control node.
5. according to the method described in claim 4, it is characterized in that, the Special controlling node include it is following at least one:
Parallel node, random node, out-of-order selection node and single node;
Wherein, parallel node order of representation executes its corresponding all child node;
Random node indicates that its corresponding child node of random selection executes;
Random ordering selection node indicates its corresponding child node of Out-of-order execution, until wherein a child node is fed back successfully;
Single node indicates most Exactly-once child nodes.
6. the method according to any one of claims 1 to 5, which is characterized in that the analysis control node function,
Obtain the behavior node function executes sequence, comprising:
For each control node function, the behavior node function of corresponding first execution of control node function is obtained;
According to the father node of behavior node function, the behavior of next execution after the behavior node function of determination runs succeeded or fails
Node function, until all behavior node functions have executed in control node function.
7. a kind of execution of behavior tree optimizes device characterized by comprising
Module is obtained, file is executed for reading an initial behavior tree, obtains the initial behavior tree and execute the corresponding row of file
For the control node function in tree, the behavior tree includes control node function and behavior node function;
Analysis module, for analyzing the control node function, obtain the behavior node function executes sequence;
Module is constructed, for executing sequence according to the behavior node function, the behavior tree is rebuild and executes file, institute
The behavior tree after rebuilding is stated to execute in the corresponding behavior tree of file comprising all behavior node functions, the structure again
Behavior tree after building executes the number for the control node function for including in the corresponding behavior tree of file less than the initial behavior tree
Execute the number for the control node function for including in the corresponding behavior tree of file;
Execution module executes file for the behavior tree after rebuilding according to and executes the behavior tree.
8. device according to claim 7, which is characterized in that the control node function includes: to be related to general controls section
The control node function of point.
9. device according to claim 8, which is characterized in that the control node function further includes being related to Special controlling section
Point control node function, it is described rebuild after behavior tree execute the corresponding behavior tree of file in also include be related to the spy
The control node function of different control node.
10. device according to any one of claims 7 to 9, which is characterized in that the analysis module is specifically used for:
For each control node function, the behavior node function of corresponding first execution of control node function is obtained;
According to the father node of behavior node function, the behavior of next execution after the behavior node function of determination runs succeeded or fails
Node function, until all behavior node functions have executed in control node function.
11. a kind of execution of behavior tree optimizes device characterized by comprising
For storing the memory and processor of program instruction;
When described program instruction is executed by the processor, so that the execution optimization device of the behavior tree is realized as right is wanted
Method described in asking any one of 1 to 6.
12. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program
Such as method as claimed in any one of claims 1 to 6 is realized when being executed by processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910387868.4A CN110102054A (en) | 2019-05-10 | 2019-05-10 | Execution optimization method, device and the storage medium of behavior tree |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910387868.4A CN110102054A (en) | 2019-05-10 | 2019-05-10 | Execution optimization method, device and the storage medium of behavior tree |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110102054A true CN110102054A (en) | 2019-08-09 |
Family
ID=67489251
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910387868.4A Pending CN110102054A (en) | 2019-05-10 | 2019-05-10 | Execution optimization method, device and the storage medium of behavior tree |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110102054A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105117575A (en) * | 2015-06-17 | 2015-12-02 | 深圳市腾讯计算机系统有限公司 | Behavior processing method and device |
CN109189504A (en) * | 2018-09-20 | 2019-01-11 | 腾讯科技(深圳)有限公司 | Behavior executes method, behavior tree generation method, device and computer equipment |
JP2019018341A (en) * | 2017-07-13 | 2019-02-07 | 鴻海精密工業股▲ふん▼有限公司 | robot |
-
2019
- 2019-05-10 CN CN201910387868.4A patent/CN110102054A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105117575A (en) * | 2015-06-17 | 2015-12-02 | 深圳市腾讯计算机系统有限公司 | Behavior processing method and device |
JP2019018341A (en) * | 2017-07-13 | 2019-02-07 | 鴻海精密工業股▲ふん▼有限公司 | robot |
CN109189504A (en) * | 2018-09-20 | 2019-01-11 | 腾讯科技(深圳)有限公司 | Behavior executes method, behavior tree generation method, device and computer equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111625452A (en) | Flow playback method and system | |
CN113209633B (en) | Mirror image processing method and device, electronic equipment and readable storage medium | |
CN105739983B (en) | Shell script editing device and its implementation | |
CN112988400B (en) | Video memory optimization method and device, electronic equipment and readable storage medium | |
CN110321344A (en) | Information query method, device, computer equipment and the storage medium of associated data | |
CN109697123B (en) | Rendering method and device of game animation, storage medium and electronic device | |
CN106598735B (en) | A kind of distributed computing method, main controlled node and computing system | |
CN106021468B (en) | The update method and system of distributed caching and local cache | |
CN106325866B (en) | Across engine calling method and device | |
CN109992354A (en) | Container-treatment, device, principal server, system and storage medium | |
CN106582020B (en) | Game level processing method and device | |
CN108809855A (en) | Information management method, device and electronic equipment | |
CN107526682B (en) | Method, device and equipment for generating AI (Artificial Intelligence) behavior tree of test robot | |
CN112473144A (en) | Game resource data processing method and device | |
CN108681773A (en) | Accelerated method, device, terminal and the readable storage medium storing program for executing of data operation | |
CN114979029B (en) | Control method, device, equipment and storage medium of virtual robot | |
CN112948025B (en) | Data loading method and device, storage medium, computing equipment and computing system | |
US9229980B2 (en) | Composition model for cloud-hosted serving applications | |
CN111737166B (en) | Data object processing method, device and equipment | |
CN110102054A (en) | Execution optimization method, device and the storage medium of behavior tree | |
CN113144606B (en) | Skill triggering method of virtual object and related equipment | |
CN106911730A (en) | A kind of cloud disk service device accesses moving method and device | |
CN116302328A (en) | Intelligent contract data processing method and system | |
CN113469326A (en) | Integrated circuit device and board card for executing pruning optimization in neural network model | |
CN105843680A (en) | Method and apparatus for preventing same page from being started for multiple times due to misoperation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190809 |
|
RJ01 | Rejection of invention patent application after publication |