Behavior sequence generation method and device for non-player character

文档序号:248439 发布日期:2021-11-16 浏览:3次 中文

阅读说明:本技术 一种非玩家角色的行为序列生成方法及装置 (Behavior sequence generation method and device for non-player character ) 是由 张林箭 张聪 宋有伟 楼荒 刘畅 范长杰 胡志鹏 于 2021-08-16 设计创作,主要内容包括:本申请提供了一种非玩家角色的行为序列生成方法及装置,其中,该方法包括:获取用于描述行为序列关系的知识图谱;基于知识图谱中与非玩家角色相关的行为节点、状态节点和边获得子图;根据子图确定作为目标行为节点的下一步行为的多个候选行为节点;目标行为节点为行为序列中除终止节点外的任一行为节点;从中筛选满足第一预设条件的候选行为节点作为目标行为节点的下一行为节点,将其加入行为序列中;若行为序列中的目标行为节点具有对应的状态节点,则从目标行为节点的多个候选状态节点中筛选满足第二预设条件的候选状态节点,将其加入行为序列中,从而生成非玩家角色的行为序列,可提升非玩家角色剧情的多样性、新鲜感,且大大降低人力成本。(The application provides a method and a device for generating a behavior sequence of a non-player character, wherein the method comprises the following steps: acquiring a knowledge graph for describing a behavior sequence relation; obtaining a subgraph based on behavior nodes, state nodes and edges in the knowledge graph, wherein the behavior nodes, the state nodes and the edges are related to non-player characters; determining a plurality of candidate behavior nodes serving as next-step behaviors of the target behavior node according to the subgraph; the target behavior node is any behavior node except the termination node in the behavior sequence; screening candidate behavior nodes meeting the first preset condition from the behavior sequence as next behavior nodes of the target behavior node, and adding the candidate behavior nodes into the behavior sequence; if the target behavior node in the behavior sequence has the corresponding state node, the candidate state nodes meeting the second preset condition are screened from the plurality of candidate state nodes of the target behavior node and added into the behavior sequence, so that the behavior sequence of the non-player character is generated, the diversity and the freshness of the plot of the non-player character can be improved, and the labor cost is greatly reduced.)

1. A method for generating a sequence of actions for a non-player character, comprising:

acquiring a knowledge graph for describing a behavior sequence relation;

obtaining a sub-graph of the knowledge graph based on behavior nodes, state nodes and edges in the knowledge graph related to non-player characters; wherein the edges are used for representing logical relationships among the behavior nodes, among the state nodes, and between the behavior nodes and the state nodes;

acquiring a starting node of a behavior sequence of the non-player character from the behavior nodes of the subgraph;

determining a plurality of candidate behavior nodes serving as next-step behaviors of the target behavior nodes according to the subgraph; the target behavior node is any behavior node except a termination node in the behavior sequence;

selecting candidate behavior nodes meeting a first preset condition from the candidate behavior nodes, and taking the selected candidate behavior nodes as next behavior nodes of the target behavior node;

adding the next behavior node of the determined target behavior node into the behavior sequence;

and determining whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, if a target behavior node in the behavior sequence has a corresponding state node, screening candidate state nodes meeting a second preset condition from a plurality of candidate state nodes of the target behavior node, and adding the screened candidate state nodes into the behavior sequence, thereby generating the behavior sequence of the non-player character.

2. The method of claim 1, wherein the screening the candidate behavior nodes satisfying a first preset condition from the plurality of candidate behavior nodes comprises:

aiming at each candidate behavior node, calculating a first similarity between a word vector corresponding to the candidate behavior node and a word vector corresponding to each behavior node in the current behavior sequence;

calculating a first score of the candidate behavior node based on a plurality of the first similarities corresponding to the candidate behavior node;

and screening the candidate behavior nodes of which the first scores meet a first preset condition from the plurality of candidate behavior nodes.

3. The method of claim 2, wherein calculating the first score for the candidate behavior node based on a plurality of the first similarities for the candidate behavior node comprises:

weighting and summing a plurality of first similarity degrees corresponding to the candidate behavior node and a first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain a first score of the candidate behavior node; and the first weight coefficient of the behavior node is in negative correlation with the generation time of the corresponding behavior node in the current behavior sequence.

4. The method according to claim 3, wherein the weighting and summing the plurality of first similarities corresponding to the candidate behavior node and the first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain the first score of the candidate behavior node comprises:

selecting a first similarity smaller than a preset threshold value from the first similarities corresponding to the candidate behavior node;

and carrying out weighted summation on the selected first similarity and the first weight coefficient of the corresponding behavior node respectively to obtain a first score of the candidate behavior node.

5. The method according to claim 3, wherein the weighting and summing the plurality of first similarities corresponding to the candidate behavior node and the first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain the first score of the candidate behavior node comprises:

selecting a plurality of first sampling similarities from the plurality of first similarities corresponding to the candidate behavior node; the generation time of the behavior node corresponding to the first sampling similarity in the current behavior sequence is within a first preset time range;

and carrying out weighted summation on the plurality of first sampling similarities and the first weight coefficients of the corresponding behavior nodes to obtain a first score of the candidate behavior node.

6. The method according to claim 2, wherein the screening the candidate behavior nodes from the plurality of candidate behavior nodes, the first score of which satisfies a first preset condition, comprises:

sequencing the candidate behavior nodes according to the sequence of the first scores of the candidate behavior nodes from high to low to obtain a first sequencing result of the candidate behavior nodes;

screening candidate behavior nodes from the first sequencing result based on any one of the following modes:

randomly screening a preset number of candidate behavior nodes from the first sequencing result;

screening a preset number of candidate behavior nodes in sequence from the candidate behavior node positioned at the first position in the first sequencing result;

and screening a preset number of candidate behavior nodes in sequence from the candidate behavior node positioned at the last bit in the first sequencing result.

7. The method of claim 1, wherein the determining whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, and if a target behavior node in the behavior sequence has a corresponding state node, selecting a candidate state node satisfying a second preset condition from a plurality of candidate state nodes of the target behavior node comprises:

determining whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, and if a target behavior node in the behavior sequence has a corresponding state node, calculating a second similarity between a word vector corresponding to the candidate state node and a word vector corresponding to each state node in the current behavior sequence aiming at each candidate state node of the target behavior node;

calculating a second score of the candidate state node based on a plurality of second similarities corresponding to the candidate state node;

and screening the candidate state nodes of which the second scores meet a second preset condition from the plurality of candidate state nodes of the target behavior node.

8. The method of claim 7, wherein calculating the second score for the candidate state node based on a plurality of second similarities for the candidate state node comprises:

weighting and summing a plurality of second similarity degrees corresponding to the candidate state node and a second weight coefficient of each state node in the corresponding current behavior sequence to obtain a second score of the candidate state node; and the second weight coefficient of the state node is in negative correlation with the generation time of the corresponding state node in the current behavior sequence.

9. The method according to claim 8, wherein the weighted summation of the plurality of second similarities corresponding to the candidate state node and the second weight coefficient of each corresponding state node in the current behavior sequence to obtain the second score of the candidate state node comprises:

selecting a second similarity smaller than a preset threshold value from the plurality of second similarities corresponding to the candidate state node;

and carrying out weighted summation on the selected second similarity and the second weight coefficient of the corresponding state node respectively to obtain a second score of the candidate state node.

10. The method according to claim 8, wherein the weighted summation of the plurality of second similarities corresponding to the candidate state node and the second weight coefficient of each corresponding state node in the current behavior sequence to obtain the second score of the candidate state node comprises:

selecting a plurality of second sampling similarities from the plurality of second similarities corresponding to the candidate state node; the generation time of the state node corresponding to the second sampling similarity in the current behavior sequence is within a second preset time range;

and carrying out weighted summation on the plurality of second sampling similarities and the second weight coefficients of the corresponding state nodes respectively to obtain a second score of the candidate state node.

11. The method according to claim 7, wherein the screening the candidate state nodes with the second score satisfying a second preset condition from the candidate state nodes of the target behavior node comprises:

sequencing the candidate state nodes according to the sequence of the second scores of the candidate state nodes of the target behavior node from high to low to obtain a second sequencing result of the candidate state nodes;

screening candidate state nodes from the second ranking result based on any one of the following ways:

randomly screening a preset number of candidate state nodes from the second sorting result;

screening a preset number of candidate state nodes in sequence from the candidate state node positioned at the first position in the second sorting result;

and screening a preset number of candidate state nodes in sequence from the candidate state node positioned at the last bit in the first sequencing result.

12. An apparatus for generating a sequence of behaviors of a non-player character, comprising:

the map acquisition module is used for acquiring a knowledge map for describing the behavior sequence relationship;

the sub-graph obtaining module is used for obtaining a sub-graph of the knowledge graph based on behavior nodes, state nodes and edges related to non-player characters in the knowledge graph; wherein the edges are used for representing logical relationships among the behavior nodes, among the state nodes, and between the behavior nodes and the state nodes;

the node acquisition module is used for acquiring a starting node of the behavior sequence of the non-player character from the behavior nodes of the subgraph;

the node determining module is used for determining a plurality of candidate behavior nodes which are used as next-step behaviors of the target behavior node according to the subgraph; the target behavior node is any behavior node except a termination node in the behavior sequence;

the node screening module is used for screening candidate behavior nodes meeting a first preset condition from the candidate behavior nodes and taking the screened candidate behavior nodes as next behavior nodes of the target behavior node;

a first adding module, configured to add a next behavior node of the determined target behavior node into the behavior sequence;

and the second adding module is used for determining whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, screening candidate state nodes meeting a second preset condition from a plurality of candidate state nodes of the target behavior node if the target behavior node in the behavior sequence has a corresponding state node, and adding the screened candidate state nodes into the behavior sequence so as to generate the behavior sequence of the non-player role.

13. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is operating, the processor executing the machine-readable instructions to perform the steps of the method according to any one of claims 1 to 11.

14. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, is adapted to carry out the steps of the method according to any one of claims 1 to 11.

Technical Field

The application relates to the technical field of game artificial intelligence, in particular to a method and a device for generating a behavior sequence of a non-player character.

Background

With the development of the AI (Artificial Intelligence) technology of games, hundreds of Non-Player characters (NPCs) in the virtual game world can move like real human beings, creating a richer and more realistic virtual Character social group. In order to make the game world more realistic, it is usually necessary to define the behavior sequence of each non-player character in advance so that the behavior of the non-player character in the game is consistent with the behavior of a real person.

Currently, the behavior sequence of a non-player character is defined by manually writing a Story Tree (Story Tree), and the non-player character performs daily activities every day according to the defined behavior sequence of the non-player character. For example: the sequence of behavior of a non-player character of a working team is: getting up- > buying breakfast- > eating breakfast- > going to work- > buying lunch- > eating lunch- > sleeping noon shift- > the middle may be interspersed with some interactive behaviors with other non-player characters, such as that "buying breakfast" may communicate with waiters, or that a certain behavior is pre-conditioned, enters different branches according to different conditions, such as that "sleeping noon shift" is trapped after "lunch" is trapped, and "going to work" is continued without trapping.

The applicant found in the study that: the behavior sequence of the non-player character is defined in a manual story tree writing mode, and is very limited to manual creation, the behavior sequence of the non-player character can be determined by the number of templates written manually, and the plot of the non-player character has no diversity and freshness. Moreover, when the number of non-player characters is large, the form of writing the story tree manually is relied on, so that the labor cost is greatly increased.

Disclosure of Invention

In view of the above, an object of the present invention is to provide a method and an apparatus for generating a behavior sequence of a non-player character, which can improve the variety and freshness of scenarios of the non-player character and greatly reduce the labor cost.

In a first aspect, an embodiment of the present application provides a method for generating a behavior sequence of a non-player character, including:

acquiring a knowledge graph for describing a behavior sequence relation;

obtaining a sub-graph of the knowledge graph based on behavior nodes, state nodes and edges in the knowledge graph related to non-player characters; wherein the edges are used for representing logical relationships among the behavior nodes, among the state nodes, and between the behavior nodes and the state nodes;

acquiring a starting node of a behavior sequence of the non-player character from the behavior nodes of the subgraph;

determining a plurality of candidate behavior nodes serving as next-step behaviors of the target behavior nodes according to the subgraph; the target behavior node is any behavior node except a termination node in the behavior sequence;

selecting candidate behavior nodes meeting a first preset condition from the candidate behavior nodes, and taking the selected candidate behavior nodes as next behavior nodes of the target behavior node;

adding the next behavior node of the determined target behavior node into the behavior sequence;

and determining whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, if a target behavior node in the behavior sequence has a corresponding state node, screening candidate state nodes meeting a second preset condition from a plurality of candidate state nodes of the target behavior node, and adding the screened candidate state nodes into the behavior sequence, thereby generating the behavior sequence of the non-player character.

In a possible embodiment, the screening, from the plurality of candidate behavior nodes, a candidate behavior node that satisfies a first preset condition includes:

aiming at each candidate behavior node, calculating a first similarity between a word vector corresponding to the candidate behavior node and a word vector corresponding to each behavior node in the current behavior sequence;

calculating a first score of the candidate behavior node based on a plurality of the first similarities corresponding to the candidate behavior node;

and screening the candidate behavior nodes of which the first scores meet a first preset condition from the plurality of candidate behavior nodes.

In a possible implementation manner, the calculating a first score of the candidate behavior node based on a plurality of the first similarities corresponding to the candidate behavior node includes:

weighting and summing a plurality of first similarity degrees corresponding to the candidate behavior node and a first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain a first score of the candidate behavior node; and the first weight coefficient of the behavior node is in negative correlation with the generation time of the corresponding behavior node in the current behavior sequence.

In a possible implementation manner, the performing weighted summation on the plurality of first similarities corresponding to the candidate behavior node and the first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain the first score of the candidate behavior node includes:

selecting a first similarity smaller than a preset threshold value from the first similarities corresponding to the candidate behavior node;

and carrying out weighted summation on the selected first similarity and the first weight coefficient of the corresponding behavior node respectively to obtain a first score of the candidate behavior node.

In a possible implementation manner, the performing weighted summation on the plurality of first similarities corresponding to the candidate behavior node and the first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain the first score of the candidate behavior node includes:

selecting a plurality of first sampling similarities from the plurality of first similarities corresponding to the candidate behavior node; the generation time of the behavior node corresponding to the first sampling similarity in the current behavior sequence is within a first preset time range;

and carrying out weighted summation on the plurality of first sampling similarities and the first weight coefficients of the corresponding behavior nodes to obtain a first score of the candidate behavior node.

In a possible implementation manner, the screening, from the plurality of candidate behavior nodes, a candidate behavior node whose first score satisfies a first preset condition includes:

sequencing the candidate behavior nodes according to the sequence of the first scores of the candidate behavior nodes from high to low to obtain a first sequencing result of the candidate behavior nodes;

screening candidate behavior nodes from the first sequencing result based on any one of the following modes:

randomly screening a preset number of candidate behavior nodes from the first sequencing result;

screening a preset number of candidate behavior nodes in sequence from the candidate behavior node positioned at the first position in the first sequencing result;

and screening a preset number of candidate behavior nodes in sequence from the candidate behavior node positioned at the last bit in the first sequencing result.

In a possible implementation manner, the determining, according to the subgraph, whether each behavior node in the behavior sequence has a corresponding state node, and if a target behavior node in the behavior sequence has a corresponding state node, screening candidate state nodes meeting a second preset condition from a plurality of candidate state nodes of the target behavior node, includes:

determining whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, and if a target behavior node in the behavior sequence has a corresponding state node, calculating a second similarity between a word vector corresponding to the candidate state node and a word vector corresponding to each state node in the current behavior sequence aiming at each candidate state node of the target behavior node;

calculating a second score of the candidate state node based on a plurality of second similarities corresponding to the candidate state node;

and screening the candidate state nodes of which the second scores meet a second preset condition from the plurality of candidate state nodes of the target behavior node.

In a possible implementation manner, the calculating a second score of the candidate state node based on a plurality of second similarities corresponding to the candidate state node includes:

weighting and summing a plurality of second similarity degrees corresponding to the candidate state node and a second weight coefficient of each state node in the corresponding current behavior sequence to obtain a second score of the candidate state node; and the second weight coefficient of the state node is in negative correlation with the generation time of the corresponding state node in the current behavior sequence.

In a possible implementation manner, the performing weighted summation on the plurality of second similarities corresponding to the candidate state node and the second weight coefficient of each corresponding state node in the current behavior sequence to obtain the second score of the candidate state node includes:

selecting a second similarity smaller than a preset threshold value from the plurality of second similarities corresponding to the candidate state node;

and carrying out weighted summation on the selected second similarity and the second weight coefficient of the corresponding state node respectively to obtain a second score of the candidate state node.

In a possible implementation manner, the performing weighted summation on the plurality of second similarities corresponding to the candidate state node and the second weight coefficient of each corresponding state node in the current behavior sequence to obtain the second score of the candidate state node includes:

selecting a plurality of second sampling similarities from the plurality of second similarities corresponding to the candidate state node; the generation time of the state node corresponding to the second sampling similarity in the current behavior sequence is within a second preset time range;

and carrying out weighted summation on the plurality of second sampling similarities and the second weight coefficients of the corresponding state nodes respectively to obtain a second score of the candidate state node.

In a possible implementation manner, the screening, from a plurality of candidate state nodes of the target behavior node, a candidate state node whose second score meets a second preset condition includes:

sequencing the candidate state nodes according to the sequence of the second scores of the candidate state nodes of the target behavior node from high to low to obtain a second sequencing result of the candidate state nodes;

screening candidate state nodes from the second ranking result based on any one of the following ways:

randomly screening a preset number of candidate state nodes from the second sorting result;

screening a preset number of candidate state nodes in sequence from the candidate state node positioned at the first position in the second sorting result;

and screening a preset number of candidate state nodes in sequence from the candidate state node positioned at the last bit in the first sequencing result.

In a second aspect, an embodiment of the present application provides an apparatus for generating a behavior sequence of a non-player character, including:

the map acquisition module is used for acquiring a knowledge map for describing the behavior sequence relationship;

the sub-graph obtaining module is used for obtaining a sub-graph of the knowledge graph based on behavior nodes, state nodes and edges related to non-player characters in the knowledge graph; wherein the edges are used for representing logical relationships among the behavior nodes, among the state nodes, and between the behavior nodes and the state nodes;

the node acquisition module is used for acquiring a starting node of the behavior sequence of the non-player character from the behavior nodes of the subgraph;

the node determining module is used for determining a plurality of candidate behavior nodes which are used as next-step behaviors of the target behavior node according to the subgraph; the target behavior node is any behavior node except a termination node in the behavior sequence;

the node screening module is used for screening candidate behavior nodes meeting a first preset condition from the candidate behavior nodes and taking the screened candidate behavior nodes as next behavior nodes of the target behavior node;

a first adding module, configured to add a next behavior node of the determined target behavior node into the behavior sequence;

and the second adding module is used for determining whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, screening candidate state nodes meeting a second preset condition from a plurality of candidate state nodes of the target behavior node if the target behavior node in the behavior sequence has a corresponding state node, and adding the screened candidate state nodes into the behavior sequence so as to generate the behavior sequence of the non-player role.

In a third aspect, an embodiment of the present application further provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the electronic device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any possible implementation of the first aspect.

In a fourth aspect, this application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps in the first aspect or any one of the possible implementation manners of the first aspect.

The embodiment of the application provides a method for generating a behavior sequence of a non-player character, and the method comprises the following steps of firstly, acquiring a knowledge graph for describing a behavior sequence relation as a knowledge source for generating a subsequent behavior sequence, so that the labor cost for arranging knowledge can be reduced; then, acquiring sub-graphs of the knowledge graph based on behavior nodes, state nodes and edges related to non-player characters in the knowledge graph, wherein the edges are used for representing logical relations among the behavior nodes, among the state nodes and between the behavior nodes and the state nodes, and the sub-graphs related to the non-player characters can be screened out of the knowledge graph; finally, acquiring a starting node of the behavior sequence of the non-player character from the behavior nodes of the subgraph; for any behavior node in the behavior sequence except for the termination node, namely for any target behavior node, determining a plurality of candidate behavior nodes serving as next-step behaviors of the target behavior node according to the subgraph, screening candidate behavior nodes meeting a first preset condition from the plurality of candidate behavior nodes, taking the screened candidate behavior nodes as next-step behaviors of the target behavior node, and adding the determined next-step behaviors of the target behavior node into the behavior sequence; and if the target behavior node in the behavior sequence is determined to have the corresponding state node from the subgraph, selecting the candidate state node meeting a second preset condition from a plurality of candidate state nodes of the target behavior node, and adding the selected candidate state node into the behavior sequence, thereby generating the behavior sequence of the non-player character. According to the embodiment of the application, the behavior sequence of the non-player role is defined without manually arranging knowledge and manually editing the story tree, so that the labor cost can be greatly reduced; different candidate behavior nodes and candidate state nodes can be selected by setting different preset conditions, and diversity and freshness of the plot of the non-player character can be improved.

In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.

Drawings

In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.

FIG. 1 is a flow chart illustrating a method for generating a behavior sequence of a non-player character according to an embodiment of the present application;

FIG. 2 is a schematic diagram of a Chinese common sense graph provided in the embodiments of the present application;

fig. 3 is a schematic structural diagram illustrating a behavior sequence generating apparatus of a non-player character according to an embodiment of the present application;

fig. 4 shows a schematic structural diagram of an electronic device provided in an embodiment of the present application.

Detailed Description

In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for illustrative and descriptive purposes only and are not used to limit the scope of protection of the present application. Additionally, it should be understood that the schematic drawings are not necessarily drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be performed out of order, and steps without logical context may be performed in reverse order or simultaneously. One skilled in the art, under the guidance of this application, may add one or more other operations to, or remove one or more operations from, the flowchart.

In addition, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.

It should be noted that in the embodiments of the present application, the term "comprising" is used to indicate the presence of the features stated hereinafter, but does not exclude the addition of further features.

Referring to fig. 1, fig. 1 is a flowchart of a behavior sequence generating method of a non-player character according to an embodiment of the present disclosure. As shown in fig. 1, the following steps may be included:

s101, acquiring a knowledge graph for describing a behavior sequence relationship;

s102, acquiring a sub-graph of the knowledge graph based on behavior nodes, state nodes and edges related to non-player characters in the knowledge graph; wherein the edges are used for representing logical relationships among the behavior nodes, among the state nodes, and between the behavior nodes and the state nodes;

s103, acquiring a starting node of the behavior sequence of the non-player character from the behavior nodes of the subgraph;

s104, determining a plurality of candidate behavior nodes serving as next-step behaviors of the target behavior node according to the subgraph; the target behavior node is any behavior node except a termination node in the behavior sequence;

s105, screening candidate behavior nodes meeting a first preset condition from the candidate behavior nodes, and taking the screened candidate behavior nodes as next behavior nodes of the target behavior node;

s106, adding the next behavior node of the determined target behavior node into the behavior sequence;

s107, determining whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, if a target behavior node in the behavior sequence has a corresponding state node, screening candidate state nodes meeting a second preset condition from a plurality of candidate state nodes of the target behavior node, and adding the screened candidate state nodes into the behavior sequence, so as to generate the behavior sequence of the non-player character.

In step S101, the knowledge graph for describing the behavior sequence relationship may include a chinese common sense graph, a topic graph, an encyclopedia knowledge graph, and the like. As shown in fig. 2, the chinese common sense graph is a graph constructed by screening chinese common sense on a public data set ConceptNet, and the graph includes about 13k nodes and 114k edges, wherein the types of the edges are 11 types, and the edges are in the form of triples, such as ("eat", "because", "starve") or one edge. The topic map is a map constructed based on an open topic set. The encyclopedia knowledge graph is a graph constructed based on encyclopedia data sets, such as encyclopedia, wikipedia and the like.

In step S102, the behavior nodes (i.e., verb nodes) related to the non-player character in the knowledge graph may include "eat", "work", "buy flowers", and so on. The state nodes (i.e., adjective nodes) in the knowledge-graph associated with a non-player character may include "happy," "shy," "sad," and the like. The edges are used for representing the logical relations among the behavior nodes, among the state nodes and between the behavior nodes and the state nodes, and the edges can comprise three sequential logics of 'causing', 'causing a direction to' and 'having a sub-event', and the like.

It should be noted that some other relationships may also be slightly modified to extend the sequential logic, for example, the relationship "caused" may be obtained by reversing the direction of the edge of the relationship "because". Even some action sequences representing the sequential logic can be marked continuously manually for expanding the common sense map. Furthermore, a behavior node may point to other behavior nodes or state nodes, and a state node may point to other state nodes or behavior nodes.

In this step, action nodes, state nodes and edges representing the logical relations among the action nodes, among the state nodes and between the action nodes and the state nodes are screened out from the knowledge graph, so as to obtain a subgraph of the knowledge graph. Meanwhile, a starting node and a terminating node of the non-player character are marked in the subgraph, the starting node is used for controlling the beginning of the behavior sequence, and the terminating node is used for controlling the ending of the behavior sequence.

In step S103, the start node of the behavior sequence of the non-player character is obtained from the behavior node of the sub-graph, and may refer to a start node labeled in advance in the sub-graph or a behavior node in the sub-graph designated at random.

In step S104, the target behavior node is any behavior node in the behavior sequence except the termination node, for example: an initiation node, any behavior node in the behavior sequence except the initiation node and the termination node.

As shown in fig. 2, assuming that the target behavior node is "motion", a plurality of candidate behavior nodes as next behaviors of the target behavior node are determined according to the subgraph: "leisure", "heatstroke", "enjoy", "hurt", etc.

In step S105, after determining a plurality of candidate behavior nodes of a target behavior node, a candidate behavior node satisfying a first preset condition is screened from the plurality of candidate behavior nodes as a next behavior node of the target behavior node.

The step of screening candidate behavior nodes satisfying a first preset condition from the plurality of candidate behavior nodes may include the following sub-steps:

s1051, aiming at each candidate behavior node, calculating a first similarity between a word vector corresponding to the candidate behavior node and a word vector corresponding to each behavior node in the current behavior sequence;

s1052, calculating a first score of the candidate behavior node based on a plurality of first similarities corresponding to the candidate behavior node;

s1053, screening the candidate behavior nodes with the first scores meeting the first preset condition from the plurality of candidate behavior nodes.

In step S1051, the first similarity refers to a cosine similarity between the word vector corresponding to the candidate behavior node and the word vector corresponding to the behavior node in the current behavior sequence. Specifically, for each candidate behavior node ciCalculating the candidate behavior node ciCorresponding word vector eciWith each behavior node p in the current behavior sequencejCorresponding word vector epjFirst similarity cos (e) therebetweenci,epj) Due to a behavior node p in the current behavior sequencejA plurality of first similarity cos (e) corresponding to the candidate behavior node are obtainedci,epj)。

In step S1052, specifically, node c is acted on based on the candidate behavioriCorresponding multiple first similarity cos (e)ci,epj) Computing the candidate behavior node ciFirst score of (c)i)。

Wherein, the step S1052 may include: weighting and summing a plurality of first similarity degrees corresponding to the candidate behavior node and a first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain a first score of the candidate behavior node; and the first weight coefficient of the behavior node is in negative correlation with the generation time of the corresponding behavior node in the current behavior sequence. It should be noted that the later the generation time of the behavior node in the current behavior sequence is, the larger the corresponding first weight coefficient is; the earlier the generation time of the behavior node in the current behavior sequence is, the smaller the corresponding first weight coefficient is.

In specific implementation, the node c is operated by the candidate behavioriCorresponding multiple first similarity cos (e)ci,epj) Calculating the candidate behavior node c by carrying out weighted summationiFirst score of (2)where cos(eci,epj) < alpha. Wherein n represents the length of the behavior sequence,and to omegajPerforming normalization processingBehavior node pjThe later the generation time in the current behavior sequence, the corresponding first weight coefficient ωjThe larger. Behavior node pjThe earlier the generation time in the current behavior sequence, the corresponding first weight coefficient ωjThe smaller

In a possible implementation manner, for the step of performing weighted summation on the plurality of first similarities corresponding to the candidate behavior node and the first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain the first score of the candidate behavior node in the foregoing embodiment, the step may specifically include: selecting a first similarity smaller than a preset threshold value from the first similarities corresponding to the candidate behavior node; and carrying out weighted summation on the selected first similarity and the first weight coefficient of the corresponding behavior node respectively to obtain a first score of the candidate behavior node.

In the specific implementation, in order to avoid that the repetition degree of the behavior node corresponding to the next action is too high with the existing behavior node of the current behavior sequence, the score of the candidate behavior node is reduced for the candidate behavior node which is very close to the existing behavior node of the current behavior sequence. In particular, if the first similarity cos (e)ci,epj) If the value is greater than or equal to a preset threshold value alpha, the node represents a candidate behavior node ciCorresponding word vector eciWith the action node p in the current action sequencejCorresponding word vector epjVery closely, the first weight coefficient corresponding to the first similarity is zero, and the final first score is not accumulated. In the present embodiment, the preset threshold α may be set to 0.84, to which the present embodiment is not limited.

In another possible implementation manner, for the step of performing weighted summation on the plurality of first similarities corresponding to the candidate behavior node and the first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain the first score of the candidate behavior node in the foregoing embodiment, the step may specifically include: selecting a plurality of first sampling similarities from the plurality of first similarities corresponding to the candidate behavior node; the generation time of the behavior node corresponding to the first sampling similarity in the current behavior sequence is within a first preset time range; and carrying out weighted summation on the plurality of first sampling similarities and the first weight coefficients of the corresponding behavior nodes to obtain a first score of the candidate behavior node.

It should be noted that, when calculating the first score of each candidate behavior node, the weighted score of the first similarity between the candidate behavior node and all existing behavior nodes of the current behavior sequence may be considered, or the weighted score of the first sampling similarity between the candidate behavior node and only the latest behavior nodes of the current behavior sequence may be considered. Only considering the weighted scores of the first sampling similarity between the candidate behavior nodes and the existing several recent behavior nodes of the current behavior sequence means that only the current small-range behavior rationality is concerned, and the phenomenon that the generated behavior nodes are not attached to the behavior nodes at the previous moment due to too long concerned historical behaviors is avoided.

In step S1053, from the plurality of candidate behavior nodes ciScreening for the first score (c)i) Candidate behavior node c meeting first preset conditioni

Specifically, step S1053 may include: sequencing the candidate behavior nodes according to the sequence of the first scores of the candidate behavior nodes from high to low to obtain a first sequencing result of the candidate behavior nodes; screening candidate behavior nodes from the first sequencing result based on any one of the following modes: screening a preset number of candidate behavior nodes in sequence from the candidate behavior node positioned at the first position in the first sequencing result; screening a preset number of candidate behavior nodes in sequence from the candidate behavior node positioned at the last position in the first sequencing result; and randomly screening a preset number of candidate behavior nodes from the first sequencing result. It should be noted that the "preset number" in the three modes is not necessarily the same.

In the first mode, the candidate behavior nodes ranked first, for example, the candidate behavior nodes ranked three times first, are screened in order from the candidate behavior node located first in the first ranking result, and this is not limited. Therefore, the behavior sequence of the non-player character, which has no storyline fluctuation and certain logic, can be obtained, the behavior sequence of the non-player character is defined without manually arranging knowledge and manually editing a story tree, and the labor cost can be greatly reduced.

For example, starting from "overtime", only considering the weighted scores of the first sampling similarity between the candidate behavior node and the last three current behavior nodes existing in the current behavior sequence, the obtained behavior sequence without plot fluctuation and with certain logic of the non-player character can be: overtime, stay up, sleep, not sleep, read, go to sleep, wake up, take a bath, wash the face, be allergic, cold.

From "overtime", only considering the weighted score of the first sampling similarity between the candidate behavior node and the latest behavior node of the current behavior sequence, the obtained behavior sequence without storyline fluctuation and with certain logic of the non-player character can be: overtime, stay up, sleep, go to sleep, read, go to sleep, go nothing, doze, sleep, wake up, eat, and eat.

With regard to the second manner, the candidate behavior nodes that are ranked later, for example, the last five candidate behavior nodes are ranked, and the like, are screened in order from the candidate behavior node that is located at the last position in the first ranking result. Therefore, the behavior sequence of the non-player character with the storyline fluctuation can be obtained, and the freshness of the storyline of the non-player character can be improved.

For example, in the case of specifying the number of steps, starting from "overtime", only considering the weighted score of the first sampling similarity between the candidate behavior node and the behavior node of the latest four rounds existing in the current behavior sequence, the obtained behavior sequence with storyling fluctuation of the non-player character may be: overtime, stay up, sleep, read, eat, drink water, do nothing, get stupid, sleep, dreaming, giggle, and get in the corrugated.

With regard to the third method, a preset number of candidate behavior nodes are randomly screened from the first ranking result, for example, any one of the first five candidate behavior nodes is randomly screened, so that a plurality of non-repetitive behavior sequences without plot fluctuation of the non-player character are obtained, and the diversity of plots of the non-player character is improved. Or randomly screening any one of the five sequenced candidate behavior nodes, thereby obtaining a plurality of non-repetitive behavior sequences with plot fluctuation of the non-player character and improving the diversity of plots of the non-player character.

For example, starting from "overtime", only considering the weighted scores of the first sampling similarity between the candidate behavior node and the last three current behavior nodes existing in the current behavior sequence, the obtained multiple non-repetitive behavior sequences without storyline fluctuation of the non-player character can be:

overtime, sleep, get up, work, rest, get home, drive, stop, arrive late, go to class, read, take an examination;

overtime, sleep, get up, go out, start, plug, overtake, abuse;

overtime, reward, eating, sleeping, getting up, bathing, and washing hair.

In particular, the plurality of candidate behavior nodes may also be ranked and scored based on the context of the behavior nodes, non-player characters, that have been generated.

In step S106, after the candidate behavior node obtained by screening is used as a next behavior node of the target behavior node, adding the determined next behavior node of the target behavior node into the behavior sequence. And then, taking the next action node as a new target action node, and continuously repeating the process of the steps S104-S106 until no subsequent action node exists in the next step, or the length of the action sequence reaches a preset threshold value, or a pre-marked termination node is reached.

In step S107, for a target behavior node in the behavior sequence, whether the target behavior node has a corresponding state node is queried through the subgraph. And aiming at a target behavior node with a state node, screening candidate state nodes meeting a second preset condition from a plurality of candidate state nodes of the target behavior node, and adding the screened candidate state nodes into the behavior sequence.

Specifically, step S107 may include the following sub-steps:

s1071, determining whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, and if a target behavior node in the behavior sequence has a corresponding state node, calculating a second similarity between a word vector corresponding to the candidate state node and a word vector corresponding to each state node in the current behavior sequence aiming at each candidate state node of the target behavior node;

s1072, calculating a second score of the candidate state node based on the plurality of second similarity degrees corresponding to the candidate state node;

s1073, screening the candidate state nodes of which the second scores meet a second preset condition from the plurality of candidate state nodes of the target behavior node.

In step S1071, the second similarity refers to a cosine similarity between the word vector corresponding to the candidate state node and the word vector corresponding to the state node in the current behavior sequence.

In this step, for a target behavior node in the behavior sequence, querying whether the target behavior node has a corresponding state node through the subgraph. And aiming at the target behavior node with the state node, calculating the cosine similarity between the word vector corresponding to the candidate state node and the word vector corresponding to each state node in the current behavior sequence. And obtaining a plurality of second similarity degrees corresponding to the candidate state nodes because a plurality of state nodes exist in the current behavior sequence.

In step S1072, performing weighted summation on the plurality of second similarities corresponding to the candidate state node and the second weight coefficient of each state node in the corresponding current behavior sequence, to obtain a second score of the candidate state node; and the second weight coefficient of the state node is in negative correlation with the generation time of the corresponding state node in the current behavior sequence. It should be noted that the later the generation time of the state node in the current behavior sequence is, the larger the corresponding second weight coefficient is; the earlier the generation time of the state node in the current behavior sequence is, the smaller the corresponding second weight coefficient is.

In a possible implementation manner, for the step of performing weighted summation on the plurality of second similarities corresponding to the candidate state node and the second weight coefficient of each state node in the corresponding current behavior sequence to obtain the second score of the candidate state node in the foregoing embodiment, the step may specifically include: selecting a second similarity smaller than a preset threshold value from the plurality of second similarities corresponding to the candidate state node; and carrying out weighted summation on the selected second similarity and the second weight coefficient of the corresponding state node respectively to obtain a second score of the candidate state node.

In specific implementation, in order to avoid that the repetition degree of the state node corresponding to the next action and the existing state node of the current behavior sequence is too high, the score of the candidate state node is reduced for the candidate state node which is very close to the existing state node of the current behavior sequence. Specifically, if the second similarity is greater than or equal to the preset threshold, it indicates that the word vector corresponding to the candidate state node is very close to the word vector corresponding to the state node in the current behavior sequence, and the second weight coefficient corresponding to the second similarity is zero, and the final second score is not accumulated. In the present embodiment, the preset threshold may be set to 0.84, and the present embodiment is not limited thereto.

In another possible implementation manner, for the step of performing weighted summation on the plurality of second similarities corresponding to the candidate state node and the second weight coefficient of each state node in the corresponding current behavior sequence to obtain the second score of the candidate state node in the foregoing embodiment, the step may specifically include: selecting a plurality of second sampling similarities from the plurality of second similarities corresponding to the candidate state node; the generation time of the state node corresponding to the second sampling similarity in the current behavior sequence is within a second preset time range; and carrying out weighted summation on the plurality of second sampling similarities and the second weight coefficients of the corresponding state nodes respectively to obtain a second score of the candidate state node.

It should be noted that, when calculating the second score of each candidate state node, the weighted score of the second similarity between the candidate state node and all the existing state nodes of the current behavior sequence may be considered, or only the weighted score of the second sampling similarity between the candidate state node and the latest several existing wheel state nodes of the current behavior sequence may be considered. Only considering the weighted scores of the second sampling similarity between the candidate state nodes and the existing several wheel state nodes of the current behavior sequence means only paying attention to the state rationality of the current small range, and the condition that the generated state nodes are not attached to the state nodes at the previous moment due to too long concerned historical state is avoided.

In step S1073, the plurality of candidate state nodes of the target behavior node are ranked in order of their second scores from high to low to obtain a second ranking result of the plurality of candidate state nodes; screening candidate state nodes from the second ranking result based on any one of the following ways: screening a preset number of candidate state nodes in sequence from the candidate state node positioned at the first position in the second sorting result; screening a preset number of candidate state nodes in sequence from the candidate state node positioned at the last bit in the first sequencing result; and randomly screening a preset number of candidate state nodes from the second sorting result. It should be noted that the "preset number" in the three modes is not necessarily the same.

With regard to the first mode, the candidate state nodes with the highest rank, for example, the first three candidate state nodes, are screened in order from the candidate state node with the first rank in the second ranking result. Therefore, the behavior sequence of the non-player character without storyline fluctuation can be obtained, the behavior sequence of the non-player character is defined without manually arranging knowledge and manually editing a story tree, and the labor cost can be greatly reduced. For example, from "looking at a cartoon", the resulting sequence of behavior of a non-player character that includes state nodes (no storyline fluctuations) may be: see comics (joyful), laugh, stupid (cool and quiet), sleep, read books (quiet), and eat (joyful).

In the second mode, the candidate state nodes that are ranked later, for example, the last five candidate state nodes are ranked, are sequentially screened from the candidate state node that is located at the last position in the second ranking result. Thus, the behavior sequence including the state node (with plot fluctuation) of the non-player character can be obtained, and the fresh feeling of the plot of the non-player character can be improved. For example, from "looking at a cartoon", the resulting behavior sequence of the non-player character that includes state nodes (with storyline fluctuations) may be: see the caricature (sadness), laugh, slow-start (coolness), sleep, read the book (laugh), eat the meal (vomiting).

With regard to the third method, a preset number of candidate state nodes are randomly screened from the second ranking result, for example, any one of the first five candidate state nodes is randomly screened, so that a plurality of non-repetitive behavior sequences including the state nodes (without plot fluctuation) of the non-player character are obtained, and the diversity of plots of the non-player character is improved. Or randomly screening any one of the five sorted candidate state nodes, thereby obtaining a plurality of non-repetitive behavior sequences containing the state nodes (with plot fluctuation) of the non-player character and improving the diversity of the plot of the non-player character.

It should be noted that, the embodiment of the present application can generate a large number of behavior sequences with logicality, diversity and storyline fluctuation offline, deliver the behavior sequences to a document for review and labeling, label a reasonable whole behavior sequence or a reasonable part of the behavior sequence, and apply the behavior sequences to the schedule activities of non-player characters in a game. And a behavior sequence can be generated on line to control the action behavior of the non-player character in the game in real time.

The embodiment of the application provides a method for generating a behavior sequence of a non-player character, and the method comprises the following steps of firstly, acquiring a knowledge graph for describing a behavior sequence relation as a knowledge source for generating a subsequent behavior sequence, so that the labor cost for arranging knowledge can be reduced; then, acquiring sub-graphs of the knowledge graph based on behavior nodes, state nodes and edges related to non-player characters in the knowledge graph, wherein the edges are used for representing logical relations among the behavior nodes, among the state nodes and between the behavior nodes and the state nodes, and the sub-graphs related to the non-player characters can be screened out of the knowledge graph; finally, acquiring a starting node of the behavior sequence of the non-player character from the behavior nodes of the subgraph; for any behavior node in the behavior sequence except for the termination node, namely for any target behavior node, determining a plurality of candidate behavior nodes serving as next-step behaviors of the target behavior node according to the subgraph, screening candidate behavior nodes meeting a first preset condition from the plurality of candidate behavior nodes, taking the screened candidate behavior nodes as next-step behaviors of the target behavior node, and adding the determined next-step behaviors of the target behavior node into the behavior sequence; and if the target behavior node in the behavior sequence is determined to have the corresponding state node from the subgraph, selecting the candidate state node meeting a second preset condition from a plurality of candidate state nodes of the target behavior node, and adding the selected candidate state node into the behavior sequence, thereby generating the behavior sequence of the non-player character. According to the embodiment of the application, the behavior sequence of the non-player role is defined without manually arranging knowledge and manually editing the story tree, so that the labor cost can be greatly reduced; different candidate behavior nodes and candidate state nodes can be selected by setting different preset conditions, and diversity and freshness of the plot of the non-player character can be improved.

Based on the same technical concept, embodiments of the present application further provide a behavior sequence generating apparatus of a non-player character, an electronic device, a computer storage medium, and the like, and refer to the following embodiments specifically.

Referring to fig. 3, fig. 3 is a schematic structural diagram of a behavior sequence generating device of a non-player character according to an embodiment of the present disclosure. The apparatus may include:

the map acquisition module 10 is used for acquiring a knowledge map for describing a behavior sequence relationship;

an subgraph obtaining module 20, configured to obtain a subgraph of the knowledge graph based on behavior nodes, state nodes, and edges in the knowledge graph that are related to a non-player character; wherein the edges are used for representing logical relationships among the behavior nodes, among the state nodes, and between the behavior nodes and the state nodes;

a node obtaining module 30, configured to obtain a starting node of the behavior sequence of the non-player character from the behavior nodes of the subgraph;

a node determining module 40, configured to determine, according to the subgraph, multiple candidate behavior nodes serving as next-step behaviors of the target behavior node; the target behavior node is any behavior node except a termination node in the behavior sequence;

a node screening module 50, configured to screen candidate behavior nodes that meet a first preset condition from the multiple candidate behavior nodes, and use the candidate behavior nodes obtained through screening as next behavior nodes of the target behavior node;

a first adding module 60, configured to add a next behavior node of the determined target behavior node into the behavior sequence;

a second adding module 70, configured to determine whether each behavior node in the behavior sequence has a corresponding state node according to the subgraph, if a target behavior node in the behavior sequence has a corresponding state node, screen a candidate state node that meets a second preset condition from multiple candidate state nodes of the target behavior node, and add the screened candidate state node to the behavior sequence, thereby generating the behavior sequence of the non-player character.

In one possible implementation, the node screening module 50 may include:

the first similarity calculation unit is used for calculating first similarity between a word vector corresponding to each candidate behavior node and a word vector corresponding to each behavior node in the current behavior sequence aiming at each candidate behavior node;

the first score calculating unit is used for calculating a first score of the candidate behavior node based on a plurality of first similarities corresponding to the candidate behavior node;

and the candidate behavior node screening unit is used for screening the candidate behavior nodes of which the first scores meet a first preset condition from the plurality of candidate behavior nodes.

In a possible implementation manner, the first score calculating unit is specifically configured to: weighting and summing a plurality of first similarity degrees corresponding to the candidate behavior node and a first weight coefficient of each behavior node in the corresponding current behavior sequence to obtain a first score of the candidate behavior node; and the first weight coefficient of the behavior node is in negative correlation with the generation time of the corresponding behavior node in the current behavior sequence.

In a possible implementation manner, the first score calculating unit is specifically configured to:

selecting a first similarity smaller than a preset threshold value from the first similarities corresponding to the candidate behavior node;

and carrying out weighted summation on the selected first similarity and the first weight coefficient of the corresponding behavior node respectively to obtain a first score of the candidate behavior node.

In a possible implementation manner, the first score calculating unit is specifically configured to:

selecting a plurality of first sampling similarities from the plurality of first similarities corresponding to the candidate behavior node; the generation time of the behavior node corresponding to the first sampling similarity in the current behavior sequence is within a first preset time range;

and carrying out weighted summation on the plurality of first sampling similarities and the first weight coefficients of the corresponding behavior nodes to obtain a first score of the candidate behavior node.

In a possible implementation manner, the candidate behavior node screening unit is specifically configured to:

sequencing the candidate behavior nodes according to the sequence of the first scores of the candidate behavior nodes from high to low to obtain a first sequencing result of the candidate behavior nodes;

screening candidate behavior nodes from the first sequencing result based on any one of the following modes:

randomly screening a preset number of candidate behavior nodes from the first sequencing result;

screening a preset number of candidate behavior nodes in sequence from the candidate behavior node positioned at the first position in the first sequencing result;

and screening a preset number of candidate behavior nodes in sequence from the candidate behavior node positioned at the last bit in the first sequencing result.

In one possible embodiment, the second joining module 70 includes:

the second similarity calculation unit is used for determining whether each behavior node in the behavior sequence has a corresponding state node or not according to the subgraph, and if a target behavior node in the behavior sequence has a corresponding state node, calculating a second similarity between a word vector corresponding to the candidate state node and a word vector corresponding to each state node in the current behavior sequence aiming at each candidate state node of the target behavior node;

the second score calculating unit is used for calculating a second score of the candidate state node based on a plurality of second similarity degrees corresponding to the candidate state node;

and the candidate state node screening unit is used for screening the candidate state nodes of which the second scores meet a second preset condition from a plurality of candidate state nodes of the target behavior node.

In a possible implementation manner, the second score calculating unit is specifically configured to: weighting and summing a plurality of second similarity degrees corresponding to the candidate state node and a second weight coefficient of each state node in the corresponding current behavior sequence to obtain a second score of the candidate state node; and the second weight coefficient of the state node is in negative correlation with the generation time of the corresponding state node in the current behavior sequence.

In a possible implementation manner, the second score calculating unit is specifically configured to:

selecting a second similarity smaller than a preset threshold value from the plurality of second similarities corresponding to the candidate state node;

and carrying out weighted summation on the selected second similarity and the second weight coefficient of the corresponding state node respectively to obtain a second score of the candidate state node.

In a possible implementation manner, the second score calculating unit is specifically configured to:

selecting a plurality of second sampling similarities from the plurality of second similarities corresponding to the candidate state node; the generation time of the state node corresponding to the second sampling similarity in the current behavior sequence is within a second preset time range;

and carrying out weighted summation on the plurality of second sampling similarities and the second weight coefficients of the corresponding state nodes respectively to obtain a second score of the candidate state node.

In a possible implementation manner, the candidate state node screening unit is specifically configured to:

sequencing the candidate state nodes according to the sequence of the second scores of the candidate state nodes of the target behavior node from high to low to obtain a second sequencing result of the candidate state nodes;

screening candidate state nodes from the second ranking result based on any one of the following ways:

randomly screening a preset number of candidate state nodes from the second sorting result;

screening a preset number of candidate state nodes in sequence from the candidate state node positioned at the first position in the second sorting result;

and screening a preset number of candidate state nodes in sequence from the candidate state node positioned at the last bit in the first sequencing result.

Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. As shown in fig. 4, includes: the processor 401, the storage medium 402, and the bus 403, where the storage medium 402 stores machine-readable instructions executable by the processor 401, when the electronic device runs, the processor 401 communicates with the storage medium 402 through the bus 403, and the processor 401 executes the machine-readable instructions to execute the method described in the foregoing method embodiment.

The computer program product of the behavior sequence generation method for a non-player character provided in the embodiment of the present application includes a computer readable storage medium storing a non-volatile program code executable by a processor, where instructions included in the program code may be used to execute the method described in the foregoing method embodiment, and specific implementation may refer to the method embodiment, and will not be described herein again.

It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to corresponding processes in the method embodiments, and are not described in detail in this application. In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and there may be other divisions in actual implementation, and for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or modules through some communication interfaces, and may be in an electrical, mechanical or other form.

The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.

The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.

The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

21页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:游戏中处理信息的方法、装置、电子设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类