A game plot dynamic generation method, device, equipment and storage medium
Patent Information
- Application Number
- CN202611242828.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-14
- Publication Date
- 2026-09-25
AI Technical Summary
[0005]本发明提供了一种游戏剧情动态生成方法、装置、设备和存储介质,解决了现有方案由于游戏剧情的所有分支均需预先编写,导致剧情内容固定,同时随着分支数量的增加,剧情内容的编写工作量呈指数级增长,难以兼顾剧情丰富性与开发效率的技术问题
本发明通过响应于玩家对剧情推进事件的触发操作,获取玩家行为数据和剧情推进事件关联的第一虚拟对象的对象属性;根据对象属性、玩家行为数据和剧情推进事件,选取后续剧情节点对应的剧情碎片,生成剧情分支脚本;根据对象属性和玩家行为数据,对剧情分支脚本关联的第二虚拟对象的交互参数进行调整,渲染生成分支剧情事件并展示。从而通过剧情推进事件的触发进行剧情碎片的组合以及关联NPC交互参数的调整,在无需预先编写全部分支的情况下,实现了剧情内容的动态生成与个性化适配,显著提升了剧情的丰富性与开发效率。
Smart Images

Figure CN122806077A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for dynamically generating game storylines. Background Technology
[0002] Game plot refers to the narrative content presented in video games through interactive means. Essentially, it is a dynamic system composed of a narrative framework pre-designed by the game designer and the player's real-time actions. In traditional interactive plot systems, the plot is typically stored in a directed graph data structure, with nodes corresponding to narrative scenes. The system retrieves and navigates between nodes based on the player's real-time state vector.
[0003] In existing solutions, the system typically pre-programs all the branches of the game's storyline, responds to player triggers to select branches, advances the game's plot, and achieves different story endings.
[0004] However, in the above solution, since all branches of the game's plot need to be written in advance, the plot content is fixed. At the same time, as the number of branches increases, the workload of writing the plot content increases exponentially, making it difficult to balance the richness of the plot with development efficiency. Summary of the Invention
[0005] This invention provides a method, apparatus, device, and storage medium for dynamically generating game storylines, which solves the technical problem that existing solutions require all branches of the game storyline to be pre-written, resulting in fixed storyline content. Furthermore, as the number of branches increases, the workload of writing the storyline content grows exponentially, making it difficult to balance storyline richness and development efficiency.
[0006] The first aspect of this invention provides a method for dynamically generating game storylines, comprising: In response to the player's triggering of a plot-advancing event, acquire player behavior data and the object attributes of the first virtual object associated with the plot-advancing event; Based on the object attributes, the player behavior data, and the plot progression events, select plot fragments corresponding to subsequent plot nodes and generate plot branch scripts; Based on the object attributes and the player behavior data, the interaction parameters of the second virtual object associated with the story branch script are adjusted, and branch story events are rendered and displayed.
[0007] Optionally, the step of selecting plot fragments corresponding to subsequent plot nodes and generating plot branch scripts based on the object attributes, the player behavior data, and the plot advancement events includes: Based on the object attributes, the player behavior data, and the plot progression events, subsequent plot nodes are determined from the preset main plot directed graph; Select multiple plot fragments corresponding to the subsequent plot nodes from a preset plot fragment library; Combine all the aforementioned plot fragments to generate the plot branch scripts corresponding to the subsequent plot nodes.
[0008] Optionally, determining subsequent plot nodes from a preset main plot directed graph based on the object attributes, the player behavior data, and triggered plot progression events includes: The current story node is located at the point in the pre-defined main storyline directed graph that triggers a story progression event. Retrieve multiple candidate subsequent nodes associated with the current story node; By removing candidate subsequent nodes whose object attributes do not meet the unlocking conditions, multiple usable candidate nodes are obtained; Based on the object attributes and the player behavior data, calculate the preference matching degree and condition matching degree corresponding to each available candidate node; The preference matching degree and the condition matching degree are weighted and fused using immersion weight to obtain the comprehensive score corresponding to each available candidate node; The candidate node with the highest overall score is selected as the subsequent story node.
[0009] Optionally, calculating the preference matching degree and condition matching degree corresponding to each of the available candidate nodes according to the object attributes and the player behavior data includes: Multiple historical selection behavior features are extracted from the player behavior data and then subjected to an exponentially weighted average to obtain the player behavior features; The similarity between the player's behavioral characteristics and the plot content characteristics of each available subsequent node is calculated as the preference matching degree; Read the list of character items associated with the object's attributes; Based on the character item list and the object attributes, calculate the condition matching degree between the node operation conditions and each of the available subsequent nodes.
[0010] Optionally, the immersion weight includes preference weight and conditional weight, and the method further includes: According to the preset prediction cycle, the preset immersion prediction model is invoked to infer based on the player behavior data and generate an immersion trend prediction curve. If the immersion trend prediction curve is a decaying trend, the preference weight is adjusted upward according to the first preset amplitude to obtain a new preference weight. If the immersion trend prediction curve is a stationary trend, then the preference weight and the condition weight are set to preset values; If the immersion trend prediction curve is on an upward trend, the condition weights are adjusted upward according to the third preset amplitude to obtain new condition weights.
[0011] Optionally, selecting multiple plot fragments corresponding to the subsequent plot nodes from a preset plot fragment library includes: Based on the plot summary of the subsequent plot nodes, extract the corresponding node semantic vectors; Calculate the first semantic similarity between each plot fragment in the preset plot fragment library and the semantic vector of the node; Select plot fragments whose semantic similarity exceeds the similarity threshold as plot fragments to be determined; Select story fragments from the pending story fragments that meet a preset quantity range and have different fragment categories, and use them as multiple story fragments corresponding to the subsequent story nodes.
[0012] Optionally, combining all the plot fragments to generate the plot branch script corresponding to the subsequent plot node includes: The plot order of each plot fragment is matched according to the plot type of the subsequent plot nodes; Extract the initial story options corresponding to each of the aforementioned story fragments; The initial plot options are checked according to the plot sequence to obtain pending plot options associated with each plot fragment. By associating the plot fragments with their corresponding pending plot options according to the plot order, a plot branching script is obtained.
[0013] Optionally, adjusting the interaction parameters of the second virtual object associated with the story branch script based on the object attributes and the player behavior data, and rendering and displaying the branch story events, includes: The object attributes are mapped according to a preset state parameter mapping table to obtain multiple state mapping values; Locate the second virtual object associated with the plot branch script, and extract the initial interaction parameters respectively; Traverse the second virtual object, and adjust the initial interaction parameters of the second virtual object that is the same as the first virtual object according to the state mapping value to obtain intermediate interaction parameters; the intermediate interaction parameters include the object attitude value and the object behavior trigger probability; If a second virtual object exists that is different from the first virtual object, then the initial interaction parameters are determined as intermediate interaction parameters; The intermediate interaction parameters are constrained to each preset valid range to obtain the target interaction parameters; Based on the target interaction parameters, each of the second virtual objects and the plot branch scripts are rendered to generate and display branch plot events.
[0014] Optionally, the method further includes: In response to the natural language text input by the player, a large language model is invoked to perform semantic understanding on the natural language text and determine the intent classification vector; Calculate the second semantic similarity between the intent classification vector and the node semantic vector of the subsequent plot node; If the second semantic similarity is lower than the preset mapping threshold, then the semantic summary of the natural language text is extracted and combined with the preset plot fragment to create a template to generate a new plot fragment; Link the new plot fragments to the subsequent plot nodes.
[0015] Optionally, the method further includes: During the execution of the branch story events, player action data is continuously collected; Calculate the immersion deviation between the player's operation data and the preset expected behavior data; Based on the immersion deviation and the preset modulation function, the object intervention coefficient is determined; The untriggered virtual objects of the branch plot events are adjusted according to the object intervention coefficient to update the object attitude, object emotional polarity and object behavior probability of the untriggered virtual objects; When a difficulty adjustment command is received from the player, the difficulty level corresponding to the difficulty adjustment command is matched. The untriggered objects are reset according to the difficulty level, so that the object attitude, the object emotional polarity, and the object behavior probability of the untriggered objects are reset to the initial values corresponding to the difficulty level.
[0016] Optionally, the player operation data includes option switching frequency, text dwell time, text backtracking frequency, and skip ratio; the method further includes: A sequence feature vector is constructed according to a preset time window using the option switching frequency, the text dwell time, the number of text backtrackings, and the skip ratio; The preset temporal prediction network is pre-trained using the sequence feature vectors to obtain an immersion prediction model.
[0017] Optionally, the method further includes: Monitor the player's replay behavior on historical story events according to a preset replay cycle; When the number of times the backtracking behavior exceeds the preset backtracking threshold, the historical objects involved in the historical plot events are identified as objects to be recalled. When the step of selecting multiple plot fragments corresponding to the subsequent plot node from the preset plot fragment library is executed again, the plot fragment to which the object to be recalled belongs is determined as a mandatory plot fragment.
[0018] A second aspect of the present invention provides a device for generating dynamic game storylines, comprising: The player information acquisition module is used to respond to the player's triggering operation on the plot advancement event, and to acquire player behavior data and the object attributes of the first virtual object associated with the plot advancement event; The plot branch script generation module is used to select plot fragments corresponding to subsequent plot nodes and generate plot branch scripts based on the object attributes, the player behavior data and the plot advancement events; The branch story event generation module is used to adjust the interaction parameters of the second virtual object associated with the story branch script based on the object attributes and the player behavior data, and to render and generate branch story events for display.
[0019] A third aspect of the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the game plot dynamic generation method as described in any of the first aspects of the present invention.
[0020] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed, implements the game plot dynamic generation method as described in any of the first aspects of the present invention.
[0021] As can be seen from the above technical solutions, the present invention has the following advantages: This invention responds to player actions triggering plot progression events by acquiring player behavior data and the object attributes of a first virtual object associated with the plot progression event. Based on the object attributes, player behavior data, and plot progression events, it selects plot fragments corresponding to subsequent plot nodes to generate plot branch scripts. Then, based on the object attributes and player behavior data, it adjusts the interaction parameters of a second virtual object associated with the plot branch scripts, rendering and displaying the branch plot events. Thus, by combining plot fragments and adjusting associated NPC interaction parameters through the triggering of plot progression events, it achieves dynamic generation and personalized adaptation of plot content without pre-writing all branches, significantly improving the richness of the plot and development efficiency. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a schematic diagram of the application architecture provided for an embodiment of this application; Figure 2 A flowchart illustrating the steps of a method for dynamically generating game storylines, as provided in an embodiment of the present invention. Figure 3 A flowchart illustrating the steps of selecting plot fragments and generating plot branch scripts is provided in this embodiment of the invention. Figure 4 A flowchart illustrating the steps of determining subsequent plot nodes provided in this embodiment of the invention; Figure 5 A detailed flowchart of the plot branch script generation process provided in this embodiment of the invention; Figure 6 A structural block diagram of a game plot dynamic generation device provided in an embodiment of the present invention; Figure 7 This is an architectural block diagram of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0025] In virtual game applications, when players trigger plot-advancing events, the game system generates corresponding branching plot events based on player behavior data and the object attributes of virtual objects. Different branching plot events provide players with differentiated plot experiences and interactive feedback. To enhance the immersion and personalized experience of games, existing games typically design multiple plot branching paths. Common branch triggering methods include unlocking different plot content based on player dialogue options, mission completion status, or level progress, enriching the plot experience through combinations of various branches.
[0026] However, in existing story generation mechanisms, the triggering conditions and content presentation of story branches are often fixed during the game design phase. The branching paths and story content are usually only related to a single player choice or simple conditional judgment, lacking deep and dynamic connections to real-time environmental changes, the dynamic states of virtual objects, or player behavior patterns. For example, in a "rescue mission" story branch, regardless of the player's previous affinity with the target character or the presence of usable items or environmental elements in the current scene, the branch content and ending remain consistent. Even if the player's performance in combat (such as whether they rescued a specific character) differs, subsequent storylines rarely adapt. This static story generation mechanism results in insufficient strategic depth and contextual interactivity in the game. Players rely more on simple combinations of dialogue options, making it difficult to flexibly influence the storyline based on real-time game conditions, thus reducing the game's immersion and replay value to some extent. Furthermore, existing story branches are mostly limited to single-dimensional impacts, such as merely changing subsequent dialogue content or unlocking different tasks, rarely achieving dynamic composites and interactions of multi-dimensional story effects, making the story mechanism relatively thin.
[0027] Based on this, this application proposes the following technical solution to optimize the existing game plot generation mechanism, aiming to construct a plot generation method that can be deeply bound to player behavior, virtual object states, and game scenes, and supports dynamic interaction of multi-dimensional plot effects. Specifically, this application breaks the limitation of traditional plot branches being "determined once and unchanged throughout" by introducing player behavior data monitoring and multi-dimensional plot effect update mechanisms during the plot generation process. This allows the plot generation results to be adaptively adjusted according to real-time changes in the game scene (such as terrain, weather, and interactive object states) and dynamic data of plot-related virtual objects (such as character attributes, states, faction relationships, and affinity), thereby significantly improving the strategic nature, contextual interactivity, and richness of the game experience of plot generation.
[0028] Furthermore, before describing the specific implementation process of this application, the application environment of this application will first be described. Please refer to [link / reference needed]. Figure 1 , Figure 1 This is a schematic diagram of the application architecture provided for an embodiment of this application. Figure 1The application architecture shown includes server 110 and client 120. Server 110 can be of various types, such as a game server or application server, used to store game data, process player requests, and execute the core logic of the plot generation method. Server 110 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Client 120 can be a terminal device such as a smartphone, tablet, personal computer, or smartwatch. Players interact with the game system through the graphical user interface of client 120, such as triggering plot progression events and viewing branch plot displays. Server 110 and client 120 establish a communication connection through a network to achieve real-time data transmission and synchronization. For example, client 120 sends player behavior data to server 110, and server 110 returns generated branch plot event data to client 120.
[0029] It is understood that the above-mentioned plot generation method can run on personal mobile terminals, on server 110, or as a service running on third-party devices to provide plot generation functionality. The specific plot generation method can run as a program on the above-mentioned devices, or as a system component of the above-mentioned devices, or as a form of cloud service program. The specific operating mode depends on the actual scenario and is not limited here.
[0030] The aforementioned branching story events refer to story performance units within a virtual game environment that are dynamically generated by the game system based on player behavior data and virtual object attributes after players trigger story-advancing events. These units possess unique content directions and interactive forms. Their core characteristic lies in the dynamic generation and presentation of story content through code logic and data interaction. This encompasses, but is not limited to, altering dialogue content, adjusting virtual object attitudes, triggering special scene performances, and unlocking hidden quest lines, among other effects. It is one of the core elements constituting the game's narrative system, character progression system, and strategic interaction mechanisms.
[0031] Please see Figure 2 , Figure 2 A flowchart illustrating the steps of a method for generating dynamic game storylines, as provided in an embodiment of the present invention.
[0032] This invention provides a method for dynamically generating game storylines, comprising: Step 101: In response to the player's triggering of a plot progression event, obtain the player's behavior data and the object properties of the first virtual object associated with the plot progression event; Plot-driven events refer to key milestones in a game that advance the main or side quests, typically triggered by players completing specific tasks, reaching designated locations, or interacting with NPCs. Player behavior data includes a collection of historical information about a player's various actions and choices during gameplay, reflecting their gaming habits and preferences. Virtual objects refer to non-player characters (NPCs), items, or environmental elements that exist in the game world, are interactive, and possess certain attributes. Object attributes refer to the inherent characteristics and state parameters of virtual objects in the game, including but not limited to identity identifiers, personality traits, affinity values, current location, and faction affiliation.
[0033] In this embodiment, the method can be applied to a game system, which can be a server, client, or terminal device. When the system detects that a player has triggered a plot-advancing event, such as completing a dialogue with a non-player character, reaching a key location, or completing a specific task, it acquires player behavior data corresponding to the current player account, including but not limited to past dialogue choices, task completion paths, and item usage records. Simultaneously, the system reads the object attributes of the first virtual object associated with the triggered event, such as the character's affinity value, faction identifier, and current health status. Real-time acquisition of this basic data provides a data foundation for subsequently generating personalized plot branches.
[0034] Step 102: Based on object attributes, player behavior data, and plot progression events, select plot fragments corresponding to subsequent plot nodes and generate plot branch scripts; Plot fragments refer to the basic units that make up branching plot events. Each fragment contains an independent dialogue, action, or scene description. Multiple fragments can be pieced together in a logical order to form a complete plot branch.
[0035] A story branching script is an executable script composed of multiple story fragments arranged in a specific logical order, used to guide the game system to present corresponding story content at specific points.
[0036] In this embodiment, after acquiring player behavior data and the object attributes of the first virtual object, the system can filter out the plot fragments corresponding to subsequent plot nodes triggered by the plot advancement event from a preset plot fragment library based on the aforementioned data. Specifically, the system will match plot fragments that match the historical selection tendencies in the player behavior data, and further narrow down the fragment range by combining the object attributes of the first virtual object, such as favorability and faction relationship. After determining at least one plot fragment corresponding to the subsequent plot node, the system will arrange and combine these independent fragments according to the causal logic and temporal order of the plot, ultimately forming a plot branch script that can be directly run by the game engine. Through this fragmented combination method, the number of plot variations can be greatly enriched, while reducing the repetitive cost of content production.
[0037] Please see Figure 3 In one example of this application, step 102 may include the following sub-steps S11-S13: S11. Based on object attributes, player behavior data, and plot progression events, determine subsequent plot nodes from the preset main plot directed graph; S12. Select multiple plot fragments corresponding to subsequent plot nodes from the preset plot fragment library; S13. Combine all story fragments to generate the story branch scripts corresponding to subsequent story nodes.
[0038] The plot fragment library refers to a data storage structure deployed on the server side for indexing and retrieving large amounts of plot fragment data based on semantic features and category tags.
[0039] In this embodiment, the generation process of the plot branch script can be executed sequentially through S11-S13. After the system receives the object attributes and player behavior data of the first virtual object, it loads the adjacency list data of the directed graph of the main plot from the graph database, using the event identifier of the plot advancement event as an index. The system locates the current node in the adjacency list, traverses the downstream nodes pointed to by its outgoing edges, and selects subsequent plot nodes that match the object attributes and player behavior data. Subsequently, the system uses this subsequent node as a query condition to retrieve all associated plot fragments from the plot fragment library. These fragments may semantically correspond to different plot directions, such as different dialogues caused by varying levels of affinity, different branches triggered by faction selection, or different event outcomes caused by historical behavior patterns. Based on the current interaction state between the player and the first virtual object, the system filters out a subset of fragments that match the current state, and then, according to preset plot logic rules, splices these fragments together in chronological order and causal relationships to form a complete plot branch script. This script includes dialogue text, event trigger conditions, character status change commands, and subsequent available plot node markers, ensuring that the game engine can seamlessly load and execute the branch, achieving dynamic and personalized plot progression. Through these steps, the system can automatically generate highly adapted plot branches based on real-time changes in player behavior and object attributes without relying on manually writing complete branches, significantly improving the richness of game content and responsiveness.
[0040] Furthermore, buffers can be set between each stage, allowing the system to verify and roll back temporary data within the buffers when processing plot fragments, thus avoiding plot breaks or inconsistencies caused by data anomalies or logical conflicts. Simultaneously, asynchronous data processing can be performed using multiple threads, allowing the previous stage to process the next batch of data while the next batch is being processed, further improving overall throughput.
[0041] Please see Figure 4 Optionally, S11 may include the following sub-steps S111-S116: S111, Locate the current plot node corresponding to the plot advancement event triggered by the preset main plot directed graph; S112. Retrieve multiple candidate subsequent nodes associated with the current plot node; S113. Eliminate candidate subsequent nodes whose object attributes do not meet the unlocking conditions to obtain multiple usable candidate nodes; S114. Calculate the preference matching degree and condition matching degree corresponding to each available candidate node based on object attributes and player behavior data; S115. The immersion weight is used to weight and fuse the preference matching degree and the condition matching degree to obtain the comprehensive score corresponding to each available candidate node. S116. Select the available candidate node with the highest overall score as the subsequent plot node.
[0042] Unlock conditions refer to a set of logical expressions stored in the candidate node data structure, used to limit the game state constraints that must be met to enter the node, such as character level reaching 30, player affinity not lower than 60, completion of prerequisite quest A and / or no triggering of branch B, etc. Preference matching refers to analyzing player historical behavior data to identify their choice tendencies in similar story nodes, such as preferred dialogue options, faction affiliations, combat style preferences, etc., thereby quantifying the degree of fit between the current candidate node and the player's historical preferences. Condition matching refers to the objective degree of matching between the current candidate node and the player's current game state (such as character attributes, quest progress, resource quantity, etc.).
[0043] In this embodiment, a dedicated path decision thread can be set up for the game system to execute the above S111-S116. This thread uses the event identifier of the plot advancement event as the query key to perform a hash lookup on the node index table of the main plot directed graph to locate the memory pointer of the current plot node. Subsequently, the thread reads the outgoing edge pointer array stored in the adjacency list of this node, traverses the array to obtain references to all downstream candidate nodes. For each candidate node, the thread reads the unlock condition field in its data structure and obtains the object attribute set of the first virtual object from memory. The two are input into the condition parser for item-by-item comparison, and node references that do not meet the conditions are removed from the candidate list, updating the set of available candidate nodes.
[0044] For each available candidate node in the set, the thread calls two independent computation operators: the preference operator extracts multiple historical selection behavior features from the time series of player behavior data, performs an exponentially weighted average to obtain a player behavior feature vector, and then calculates the cosine of the angle between this vector and the plot content feature vector stored in the node, outputting the preference matching degree. Simultaneously, the conditional degree operator reads the character item list associated with the object attributes, performs a set operation on the list and the requirement items in the node's running condition field, calculates the ratio of the intersection to the union, and outputs the conditional matching degree. The thread reads the current immersion weight from the global configuration object and calls a weighted summation function to merge the two matching degrees into a comprehensive score. After traversing all available candidate nodes, the thread performs a linear scan, records the node reference corresponding to the maximum score, identifies it as the subsequent plot node, and writes it to the shared memory area. This decision-making process unifies graph search, set operations, and vector computation into a quantifiable scoring mechanism, making the path selection results reproducible.
[0045] In addition, a fail-fast mechanism can be introduced in the condition resolution phase. That is, when the unlocking condition of a candidate node contains a hard constraint that the current object property cannot satisfy, the node is directly removed from the candidate list without subsequent matching degree calculation, so as to reduce unnecessary computational overhead.
[0046] Furthermore, S114 may include the following sub-steps: Player behavior characteristics are obtained by extracting multiple historical selection behavior features from player behavior data and performing an exponentially weighted average. The similarity between player behavior features and the plot content features of each available subsequent node is calculated as the preference matching degree; Read the list of character items associated with the object's properties; Calculate the condition matching degree between the character's item list and object attributes and the node operation conditions of each available subsequent node.
[0047] Historical choice behavior characteristics refer to quantitative indicators extracted from the time series of player behavior data, representing a player's tendency to make specific choices at past story nodes. Examples include the frequency of choosing specific dialogue options, the proportion of choosing specific story types, and the number of times choosing a specific character route. Player behavior characteristics refer to a comprehensive feature vector representing a player's current behavioral preferences, obtained by exponentially weighted averaging of multiple historical choice behavior characteristics. Story content characteristics refer to a vectorized representation, predefined for each subsequent node, describing the story theme, emotional tendency, or character relationship type carried by that node. Node execution conditions refer to the constraints that must be met before the node is triggered, typically including character item possession status, attribute value thresholds, and the completion status of preceding nodes.
[0048] In this embodiment, the system extracts multiple historical selection behavior features within a preset time window from player behavior data. Each feature is stored as a triple (timestamp, behavior type code, selection result). After sorting these triples by timestamp, they are sequentially input into an exponentially weighted average function in ascending order. This function assigns a preset higher weight coefficient to newly input data and a lower decay coefficient to older data. After iterative calculation, a comprehensive feature vector is output as the player behavior feature.
[0049] Then, the pre-stored plot content feature vectors of each node are read from the data structure of the available subsequent nodes. The vector similarity calculation function is called to calculate the cosine similarity between the player behavior feature vector and each plot content feature vector. The calculation result is used as the preference matching degree of each node.
[0050] Simultaneously, the system reads the list of character items associated with the object attributes of the first virtual object. This list stores item identifiers in array form. The system then performs an intersection operation with the list of required items in the node execution condition field of each available subsequent node. Next, it compares each item with other state fields in the object attributes and state constraint fields in the execution conditions, calculating the proportion of matching items to the total conditions, and outputting the condition matching degree for each node. The thread writes the calculated preference matching degree and condition matching degree into a shared memory area as key-value pairs for subsequent weighted fusion steps. This process, through exponential weighted averaging, allows player behavior characteristics to dynamically follow changes in player preferences, avoiding the shortcomings of static statistics in reflecting recent behavior.
[0051] Furthermore, immersion weights include preference weights and conditional weights, and the methods also include: The preset immersion prediction model is invoked according to the preset prediction cycle, and inference is performed based on player behavior data to generate an immersion trend prediction curve. If the immersion trend prediction curve shows a decaying trend, the preference weights are adjusted upwards according to the first preset amplitude to obtain new preference weights. If the immersion trend prediction curve is a stationary trend, then the preference weight and condition weight will be set to preset values. If the immersion trend prediction curve shows an upward trend, the condition weights are adjusted upward according to the third preset amplitude to obtain new condition weights.
[0052] In this embodiment, the dynamic adjustment of immersion weights is triggered by the server-side weight scheduling thread according to a preset prediction period. Whenever the system clock reaches the preset prediction period's time node, the scheduling thread reads the current player's behavior data from the player behavior database, formats it into a model input tensor, and then feeds it into the pre-trained immersion prediction model. This model performs a forward propagation operation and outputs a floating-point sequence representing predicted values for multiple future time points, i.e., the immersion trend prediction curve.
[0053] The scheduling thread subtracts the starting value from the end value of the curve and calculates the difference to determine the trend of change: if the difference is less than the first negative threshold, it is determined to be a decaying trend. The scheduling thread reads the first preset amplitude from the configuration file, performs an addition operation on the preference weights currently stored in memory, and obtains new preference weights, while the condition weights remain unchanged; if the difference is between the first negative threshold and the first positive threshold, it is determined to be a stable trend, and the scheduling thread resets both the preference weights and condition weights to preset values; if the difference is greater than the first positive threshold, it is determined to be an upward trend. The scheduling thread reads the third preset amplitude from the configuration file, performs an addition operation on the condition weights currently stored in memory, and obtains new condition weights, while the preference weights remain unchanged. After the update is completed, the scheduling thread writes the new weight values to the global configuration object and records the update timestamp for subsequent weighted fusion steps to read. This dynamic adjustment mechanism allows the weights to adapt to changes in the player's immersion state, strengthening preference guidance to maintain interest when the player is becoming bored, and strengthening condition constraints to maintain challenge when the player's immersion is increasing.
[0054] In one example of this application, S12 may include the following sub-steps: Extract the corresponding node semantic vectors based on the plot synopsis of subsequent plot nodes; Calculate the first semantic similarity between each plot fragment and the node semantic vector in the pre-set plot fragment library; Plot fragments with a first semantic similarity exceeding the similarity threshold are selected as plot fragments to be determined; Select story fragments from the pending story fragments that meet the preset quantity range and have different fragment categories, and use them as various story fragments corresponding to subsequent story nodes.
[0055] A plot synopsis is a concise summary of the core plot points for subsequent story nodes, typically pre-written by game designers and stored in a plot node configuration table. A node semantic vector is a fixed-dimensional numerical vector obtained by encoding the plot synopsis text using a pre-trained natural language processing model, representing the node's position in the semantic space. First semantic similarity refers to the cosine similarity or Euclidean distance between plot fragments and node semantic vectors, measuring their semantic proximity. Fragment categories refer to the functional or content-based classification of plot fragments, such as dialogue, events, combat, exploration, etc. Different categories of fragments exhibit significant differences in narrative rhythm, interaction methods, and emotional tone.
[0056] In this embodiment, after selecting a subsequent plot node, the corresponding plot summary text field is retrieved from a preset plot summary database according to the node identifier of that subsequent plot node. The plot summary is then input into a preset word embedding service, which performs word segmentation, encoding, and pooling operations on the input text, outputting a fixed-dimensional floating-point array as the node semantic vector.
[0057] Meanwhile, each plot fragment in the plot fragment library pre-stores its corresponding fragment semantic vector. These fragment semantic vectors are generated when the fragment content text is encoded using the same word embedding service upon fragment entry into the library. The system traverses the plot fragment library, calculating the cosine similarity between each fragment semantic vector and the node semantic vector one by one, obtaining the first semantic similarity. Plot fragments with a first semantic similarity exceeding the similarity threshold are designated as pending plot fragments; the number of pending plot fragments can be one or more.
[0058] Subsequently, the system groups the plot fragments to be determined, categorizing them according to the category label field in each fragment's data structure to determine the fragment category of each fragment. A preset quantity range parameter is read from the configuration object, and round-robin sampling is performed on a category-group basis: one fragment is sequentially extracted from each category group and added to the candidate set until the total number of fragments in the candidate set reaches the lower limit of the preset quantity range, ensuring that the selected fragments come from at least two different category groups. The scheduling thread writes the data of the finally selected multiple plot fragments into a set format in the shared memory area for subsequent script assembly steps. Thus, by combining vector retrieval technology to match plot fragments at the semantic level, compared to keyword matching, it can more accurately recall content with different expressions but similar meanings.
[0059] Furthermore, during the retrieval of plot fragments, when the number of fragments returned by the retrieval is less than the lower limit of the preset number range, the extension layer automatically applies random noise perturbation to the node semantic vector, generates multiple variant vectors, and performs the retrieval again to expand the recall range and avoid the situation where there are not enough fragments due to overly strict matching conditions.
[0060] Please see Figure 5 In one example of this application, S13 may include the following sub-steps S131-S134: S131. Match the plot order of each plot fragment according to the plot type of the subsequent plot nodes; S132. Extract the initial story options corresponding to each story fragment; S133. Perform condition checks on each initial plot option according to the plot sequence to obtain pending plot options associated with each plot fragment; S134. By sorting the plot fragments and their corresponding pending plot options, a plot branch script is obtained.
[0061] Story type refers to the core narrative function carried by a story node, such as combat, dialogue, exploration, puzzle-solving, or cutscenes. Unlike the category labels for story fragments, story type focuses more on the node's functional positioning within the overall narrative flow. Story order refers to the sequential arrangement of story fragments within the story flow, which can be determined by the story node's hierarchy and branching relationships within the story tree. Initial story options refer to the default interaction options carried by a story fragment before it undergoes condition checks, typically including trigger conditions, jump targets, and text descriptions.
[0062] In this embodiment, the system reads the node identifier of subsequent plot nodes from the shared memory area, uses this identifier to query the corresponding plot type field from the node description database, and inputs this field as the query key into the configuration management interface to read the fragment arrangement template matching the plot type from the local configuration table. This template stores the order of various fragments in the final script in the form of an ordered list.
[0063] Then, the system iterates through various sets of story fragments in memory, matching each fragment's category label field with its order in the template to generate a sorted fragment list. For each fragment in the sorted list, the system reads the initial story option list field from its data structure. This list stores the identifier, display text, and trigger condition expression for each option in array form.
[0064] At the same time, the condition check subroutine is invoked. This subroutine obtains the state context object of the current game session, performs logical operations on the trigger condition expressions in each initial plot option, marks the options with true results as pending plot options and retains them, and discards the options with false results.
[0065] After traversal, the thread sequentially writes the content data of each fragment and its reserved pending plot options into a temporary script buffer according to the fragment order in the sorted linked list. The buffer is serialized using a protocol buffer format, and the fragment length identifier, fragment content, number of options, condition identifier for each option, and option content are written sequentially. After all fragments are written, the thread writes an end flag and a checksum at the end of the buffer, finally generating the plot branch script and storing it in the storage device. The above process, through a combination of template-driven sorting and condition-driven filtering, ensures the rationality of the output script's content order and its logical executability.
[0066] In addition, conditional branch placeholders can be introduced into the fragment arrangement template. When a certain order position is configured as a placeholder, the script assembly thread calculates in real time based on the current game state to decide which type of fragment to insert at that position, thus making the script structure itself dynamically adaptable.
[0067] Furthermore, S133 may include the following sub-steps: Initialize the state check vector; By using a state check vector to traverse each initial plot option associated with each plot fragment in the plot order, multiple plot execution paths are obtained. Remove paths that do not meet the preset logical constraints from multiple plot execution paths, and retain the plot options corresponding to the paths that meet the preset logical constraints as pending plot options associated with each plot fragment.
[0068] The state check vector refers to the numerical array created by the script assembly thread when traversing the story options, used to record the current traversal progress and the accumulated context constraint states. The story execution path refers to the complete selection sequence formed after sequentially traversing each initial story option within each story fragment, starting from the initial story fragment. Pre-defined logical constraints refer to the set of rules pre-defined during the game design phase to ensure the coherence and rationality of the story, such as multiple options in the same story fragment cannot be selected simultaneously, and the triggering conditions of subsequent options cannot conflict with the constraints of previously selected options. Pending story options refer to the story options that, after the above filtering, satisfy all logical constraints and can be actually selected by the player.
[0069] In this embodiment, a state check vector can be created in memory. This vector contains fields such as the current traversal depth, the hash value of the selected option sequence, and the flag of the triggered key events. Following the plot order determined in S131, a depth-first traversal is performed on the initial plot options associated with each plot fragment in the sorted linked list. The traversal process starts with the first option of the first fragment and recursively combines and expands the options of the next fragment. Each time an option is selected, the corresponding flag and sequence hash value in the state check vector are updated until the last fragment is reached. At this point, the complete option identifier sequence recorded in the state check vector is output as a plot execution path. The thread continues to backtrack and try other option combinations, repeating the above process until all combinations are exhausted, ultimately resulting in a set of multiple plot execution paths. Subsequently, the thread reads a preset logical constraint rule set from the configuration library. This rule set is stored in the form of condition-action pairs, with each rule containing a conditional expression and a prohibited action flag. The thread iterates through each path in the set of story execution paths, sequentially inputting the sequence of option identifiers it contains into the rule engine. The rule engine performs logical judgments on the conditional expressions of each rule. If a path triggers any prohibited action under any rule, it is marked as invalid and removed from the set. After the traversal is complete, the thread extracts the option identifiers corresponding to each depth position in each retained story execution path, associates these option identifiers with their respective fragments, and writes them as pending story options into the option list field of each fragment's data structure, replacing the original initial story option list. Thus, by traversing all possible option combinations and combining them with rule filtering, option combinations that could lead to logical contradictions can be eliminated in advance during the script generation stage, avoiding inconsistencies in the storyline during gameplay.
[0070] Step 103: Based on the object attributes and player behavior data, adjust the interaction parameters of the second virtual object associated with the story branch script, render and generate branch story events, and display them.
[0071] Interaction parameters refer to dynamically adjustable attribute parameters of the second virtual object in the story branch script, such as its response method, dialogue content, action performance, and triggering conditions. Branch story events refer to interactive story segments with unique story directions generated based on the story branch script and the adjusted interaction parameters.
[0072] In this embodiment, after generating the story branch script, due to the personalized tendencies of player behavior data and the influence of object attributes, the interaction parameters of multiple second virtual objects associated with the story branch script can be adjusted differently. This includes adjusting the dialogue tone, action frequency, or behavior trigger threshold of the second virtual objects, thereby allowing the same story branch script to exhibit differentiated interactive performances under different players or in different situations. For example, when the player character's attribute leans towards high charm, the initial dialogue tone of the second virtual object may be more friendly, increasing the probability of triggering special interactions; when the player character's attribute leans towards low charm, the initial dialogue tone of the second virtual object may be more indifferent, decreasing the probability of triggering special interactions. Simultaneously, if the player's behavior data includes multiple records of actively helping the second virtual object, the object's trust parameter will increase accordingly, thereby unlocking more hidden dialogues or special actions in subsequent interactions. Ultimately, the rendered branch story events will integrate these dynamic adjustments, presenting players with a unique interactive story segment deeply bound to their own behavior and attributes, thereby enhancing the immersion and replay value of the story.
[0073] In one example of this application, step 103 may include the following sub-steps: The object attributes are mapped according to a preset state parameter mapping table to obtain multiple state mapping values; Locate the second virtual object associated with the plot branch script and extract the initial interaction parameters for each; Traverse the second virtual object and adjust the initial interaction parameters of the second virtual object, which is the same as the first virtual object, according to the state mapping value to obtain intermediate interaction parameters; the intermediate interaction parameters include the object attitude value and the object behavior trigger probability; If a second virtual object exists that is different from the first virtual object, then the initial interaction parameters are determined as intermediate interaction parameters. The intermediate interaction parameters are constrained to each preset valid range to obtain the target interaction parameters; Based on the target interaction parameters, render each second virtual object and the plot branch script, generate branch plot events and display them.
[0074] The state parameter mapping table is a key-value data structure stored in the server's memory, used to define the conversion rules between object attribute fields and state mapping values. State mapping values are standardized numerical values obtained after object attribute fields are converted using the state parameter mapping table. The second virtual object refers to the virtual object involved in the story branch script that requires adjustment of interaction parameters. Initial interaction parameters refer to the original behavior control parameters of the second virtual object read from the object database. Intermediate interaction parameters refer to the transitional interaction parameters obtained after adjusting the state mapping values, including two fields: object attitude value and object behavior trigger probability. Object attitude value is a quantified value representing the virtual object's friendly or hostile tendency towards the player. Object behavior trigger probability is a numerical value representing the likelihood that the virtual object will actively initiate interaction behavior in a specific situation. Target interaction parameters are the final behavior control parameters obtained after constraining the intermediate interaction parameters to a valid range.
[0075] The system may be equipped with a story rendering engine, which can consist of one or more processors and memory, used to perform the mapping, adjustment, constraint, and rendering operations described above. In this embodiment, the engine is completed collaboratively by three sub-modules: a parameter mapper, a parameter adjuster, and a graphics renderer. The parameter mapper first reads the object attribute set of the first virtual object from memory, traverses each attribute field in the set, performs a hash lookup in the state parameter mapping table using the field name as the lookup key, obtains the corresponding mapping rule, performs a linear transformation on the attribute value, outputs multiple state mapping values, and stores them in a mapping value array.
[0076] The parameter adjuster then parses the header information of the story branch script, extracts a list of object identifiers for all involved second virtual objects, and initiates a query request to the object database based on each identifier to read the corresponding initial interaction parameters. The parameter adjuster iterates through the list of second virtual objects, performing an identity comparison for each object: if the identifier of the currently iterated object matches the identifier of the first virtual object, it retrieves the mapping values related to the interaction parameters from the mapping value array, and performs addition or multiplication operations on the object attitude value and object behavior trigger probability in the initial interaction parameters according to the field correspondence to obtain intermediate interaction parameters; if the identifiers do not match, the initial interaction parameters are directly assigned to the intermediate interaction parameters. After the parameter adjuster finishes iterating, all intermediate interaction parameters are input to the interval constraint function. This function performs numerical judgment on each parameter, truncating parameters exceeding the upper limit of the preset valid interval to the upper limit value, and parameters below the lower limit to the lower limit value, outputting the target interaction parameters.
[0077] The graphics renderer reads instruction sequences from the story branch scripts, loads model data and animation resources for each second virtual object from the object database, passes target interaction parameters to the rendering pipeline, calls the underlying graphics API to perform scene construction, shading, and projection calculations, and finally pushes the rendered branch story event footage to the client for display as a video stream. This process ensures that interaction parameters vary within a reasonable range through parameter mapping and range constraints, preventing uncontrolled virtual object behavior due to extreme attribute values. Simultaneously, an identity comparison mechanism avoids parameter crosstalk between non-player characters, ensuring that the interaction behavior of each virtual object is only affected by its own attributes, thereby improving the stability and realism of multi-character interaction scenes. The entire process is completed within a single rendering frame, without generating additional inter-frame latency, guaranteeing real-time interaction responses.
[0078] In addition, a differential buffer can be set in the parameter adjuster to record the parameter changes of the same virtual object before and after multiple adjustments. When it is detected that the parameter changes of an object are in the same direction and the cumulative change exceeds the preset range in multiple consecutive adjustments, the step size coefficient of subsequent adjustments is automatically reduced to avoid the virtual object's attitude or behavior from changing drastically in a short period of time and disrupting the narrative coherence.
[0079] In one example of this application, the method further includes the following steps: During the execution of branching story events, player action data is continuously collected; Calculate the immersion deviation between player action data and preset expected behavior data; Based on immersion deviation and a preset modulation function, the object intervention coefficient is determined; Adjust the non-triggered virtual objects in branching story events according to the object intervention coefficient, in order to update the object attitude, object emotional polarity and object behavior probability of the non-triggered virtual objects; When a difficulty adjustment command is received from a player, the corresponding difficulty level is matched. Untriggered objects are reset according to their difficulty level, so that their attitude, emotional polarity, and behavioral probability are reset to the initial values corresponding to the difficulty level.
[0080] Immersion deviation refers to the degree of deviation between the player's current action and the expected behavior, used to quantify whether the player is deeply immersed in the story. Object intervention coefficient refers to a scaling factor used to control the intensity of real-time adjustments to virtual objects. Untriggered virtual objects refer to second virtual objects that have not yet interacted with the player or been activated by a story event in the current branch of the story.
[0081] In this embodiment, a branching storyline event may include multiple triggered story nodes or multiple interaction processes. During the execution of this branching storyline event, the game system continuously collects player operation data, parses the specific operation type and operation timestamp, and stores it in a circular buffer, forming a real-time data stream of player operation data. The system periodically reads the operation data sequence within a preset time window from this buffer and reads the expected behavior data model corresponding to the storyline event from memory, calculating the difference between the two as an immersion deviation. This deviation value is input into a pre-configured modulation function, which internally executes a piecewise linear calculation logic and outputs a floating-point number as the object intervention coefficient. The intervention thread obtains a list of untriggered virtual objects that have not yet appeared in the current branching storyline event, reads their current object attitude, emotional polarity, and behavioral probability parameters, multiplies the object intervention coefficient as a multiplier factor with these three parameters, and writes the result back to the object state table. For example, after collecting player operation data, if calculations show that the player's operation frequency is lower than expected, the immersion deviation is 0.35, and the modulation function outputs an object intervention coefficient of 0.85, then this coefficient is multiplied by the object's attitude, emotional polarity, and behavioral probability that have not been triggered, respectively, to reduce its initial value. This reduces the interaction threshold of the object in the subsequent plot, making it easier for players to trigger its behavior or change its attitude.
[0082] In addition, when players input difficulty adjustment commands through the UI interface, the corresponding difficulty level will be matched, and all parameters of all untriggered objects will be reset to the initial values under that difficulty level, thereby quickly responding to players' subjective needs for game challenge.
[0083] Furthermore, player action data includes option switching frequency, text dwell time, text backtracking frequency, and skipping rate; training the immersion prediction model can be achieved through the following steps: Based on a preset time window, a sequence feature vector is constructed using option switching frequency, text dwell time, text backtracking count, and skip ratio. The immersion prediction model is obtained by pre-training a pre-defined temporal prediction network using sequence feature vectors.
[0084] An immersion prediction model is a neural network model that predicts the depth of a player's current immersion state based on temporal features. This model takes a sequence of feature vectors within a time window as input and outputs a continuous value representing the depth of immersion, ranging from 0 to 1. A higher value indicates a greater immersion in the current storyline.
[0085] In this embodiment, the training of the immersion prediction model is performed by a server-side model training service. This service first extracts player operation records within a preset time window from the historical player operation database, parsing four numerical fields for each record: option switching frequency, text dwell time, text backtracking count, and skip ratio. The training service arranges the four extracted values within a time window in chronological order, combining them into a multi-dimensional sequence feature vector, and labels it with the corresponding actual immersion level (this label can be determined by subsequent player retention time or questionnaire feedback data). After data normalization, the sequence feature vector is fed as an input tensor into a temporal prediction network built on a Long Short-Term Memory (LSTM) network. This network performs forward propagation to calculate the predicted value, and then updates the network's internal weight parameters based on the loss gradient between the predicted value and the label value using a backpropagation algorithm. The training service iteratively executes the above process on multiple batches of player data until the network's prediction error on the validation set converges. Finally, the trained network parameters are solidified and deployed as an online prediction model. This solution quantifies player behavior for model training, achieving computable modeling of immersion.
[0086] In addition, adversarial training strategies can be introduced during the training process to improve the robustness of the model by generating adversarial examples (such as simulated abnormal operation sequences), so that it can still maintain high prediction accuracy in real, noisy game environments.
[0087] In another example of this application, the method further includes the following steps: Monitor players' replay behavior on historical story events according to a preset replay cycle; When the number of times the backtracking behavior exceeds the preset backtracking threshold, the historical objects involved in the historical plot events will be identified as objects to be recalled. When the step of selecting multiple plot fragments corresponding to subsequent plot nodes from the preset plot fragment library is executed again, the plot fragment to which the object to be recalled belongs is determined as a mandatory plot fragment.
[0088] Rewinding refers to the player's active action of returning to view previously occurred events during the story's progression. Historical story events refer to events that the player has already experienced during the story's progression, and whose current point in time is prior to their original timeline.
[0089] In this embodiment, the system may have a backtracking monitoring thread. This thread triggers a query on backtracking behavior at a fixed backtracking cycle, such as every 10 minutes, to check the number of times a player has backtracked historical events within the most recent backtracking cycle. The monitoring thread extracts the object identifiers of historical objects involved in each backtracking record and maintains a backtracking count dictionary with the object identifiers as keys. When the number of backtrackings corresponding to a certain object identifier exceeds a preset backtracking threshold, the monitoring thread writes the object identifier into a recall list data structure and stores the list in the server's non-volatile memory.
[0090] When subsequent processes reach the step of selecting fragments from the story fragment library again, the fragment selection thread checks the recall list before reading the library. For each object identifier in the list, a forced selection operation is performed, directly inserting the unique identifier of the story fragment to which that object identifier belongs into the set of fragment identifiers to be selected, unconstrained by conventional semantic similarity filtering logic. This ensures that these fragments will inevitably be selected in this selection. Through the periodic detection of the above-mentioned backtracking behavior, the system can perceive the player's implicit interest in specific story objects. By using the explicit signal of backtracking behavior, the system transforms the player's implicit preference for historical story events into explicit constraints for the next story fragment selection. Thus, in the process of dynamically generating storylines, the system proactively responds to the player's potential interests, enhancing the personalization of story generation and player immersion.
[0091] For example, if a user clicks multiple times on historical objects involved in historical events, such as their character introductions, appearance displays, or historical dialogues, the system will record the corresponding object identifier in the recall list. During the subsequent story fragment selection phase, the system will forcibly include the story fragment to which that object belongs in the mandatory selection set, ensuring that the object reappears in subsequent story events.
[0092] Optionally, the method further includes: In response to the natural language text input by the player, a large language model is invoked to perform semantic understanding of the natural language text and determine the intent classification vector; Calculate the second semantic similarity between the intent classification vector and the node semantic vector of subsequent plot nodes; If the second semantic similarity is lower than the preset mapping threshold, the semantic summary of the natural language text is extracted and combined with the preset plot fragments to create a template to generate new plot fragments; Link new plot fragments to subsequent plot nodes.
[0093] Large language models refer to deep learning models trained on massive amounts of text data, possessing deep semantic understanding and generation capabilities. Intent classification vectors represent the distribution of player input text within a predefined intent space, such as exploration intent, social intent, or challenge intent. Node semantic vectors describe the semantic location of plot nodes within the narrative space, including dimensions such as emotional tone, conflict type, and character relationships. Plot fragment creation templates refer to a predefined structured document format used to guide how to transform unstructured text information into standardized plot fragment data.
[0094] In this embodiment, the server deploys a large language model inference service and a fragment generation service. When the server receives a natural language text data packet sent by a player client, it calls the inference service's interface to input the text into the large language model. The model performs encoder-decoder forward computation and outputs a context-related vector representing the user's intent, i.e., an intent classification vector. The server reads the node semantic vectors of the current subsequent plot nodes and calls the vector operation unit to calculate the cosine similarity between the two. If the similarity is lower than a preset mapping threshold, the fragment generation service is triggered. This service calls the large language model's summary generation function to extract core event descriptions from the natural language text and generate a semantic summary string, i.e., semantic similarity.
[0095] Subsequently, the service reads a predefined story fragment creation template (a structured document object model containing required fields), populates the template's content fields with a summary string, and automatically fills in the scene identifier and character identifier fields based on the current game context. Finally, the template is instantiated into a new story fragment data structure, written to the story fragment library, and a record is established in the edge table of the main story directed graph to associate the fragment with the current subsequent story node. This process automates the conversion from unstructured player input to structured story data.
[0096] Optionally, the method further includes: In response to player-inputted quality control commands, the rendering precision of branching story events is adjusted.
[0097] In this embodiment, the game system may include graphics precision settings or adjustments. During the execution of branching story events, quality control instructions can be generated by the player operating the progress bar, options, or other triggering methods of the graphics precision settings. After receiving the quality control instructions, the system adjusts the rendering precision of the branching story events, such as reducing texture details, shadow quality, or particle effects, to release system resources and ensure that the game can run smoothly on low-performance devices, avoiding stuttering or frame drops due to excessive resource consumption, thereby improving the overall player experience.
[0098] Optionally, the method further includes: In response to the player's command to preview the story branches, obtain summary information of all branch story events corresponding to subsequent story nodes; The summary information is visualized in a timeline format according to the chronological order of the branching story events.
[0099] Summary information refers to a concise descriptive text that highly summarizes the core content, key points, and ending of branching story events.
[0100] In this embodiment, a "Story Preview" button or interactive area can be set in the game interface. Clicking this button triggers a story branch preview command. Upon receiving the command, the system extracts summary information of all branch story events corresponding to subsequent story nodes from the story fragment library. This summary information is then visualized in a timeline format according to the chronological order of these branch story events. Each node on the timeline can be clicked to expand, displaying the triggering conditions, key choices, and final ending of that branch. This helps players fully understand the direction of each branch before making choices, enabling them to make decisions that better align with their expectations and enhancing their sense of participation and immersion in the story.
[0101] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0102] The following describes the game plot dynamic generation apparatus provided in the embodiments of this application. The game plot dynamic generation apparatus described below and the game plot dynamic generation method described above can be referred to in correspondence.
[0103] Please see Figure 6 , Figure 6 An embodiment of the present invention illustrates a game story dynamic generation device, comprising: The player information acquisition module 201 is used to respond to the player's triggering operation on the plot advancement event, and to acquire the player's behavior data and the object attributes of the first virtual object associated with the plot advancement event; The plot branch script generation module 202 is used to select plot fragments corresponding to subsequent plot nodes and generate plot branch scripts based on object attributes, player behavior data and plot advancement events. The branch story event generation module 203 is used to adjust the interaction parameters of the second virtual object associated with the story branch script based on object attributes and player behavior data, and to render and generate branch story events for display.
[0104] Optionally, the plot branch script generation module 202 includes: The plot node determination submodule is used to determine subsequent plot nodes from a pre-defined main plot directed graph based on object attributes, player behavior data, and plot progression events. The plot fragment selection submodule is used to select various plot fragments corresponding to subsequent plot nodes from a preset plot fragment library; The script generation submodule is used to combine all plot fragments and generate plot branch scripts corresponding to subsequent plot nodes.
[0105] Optionally, the plot node determination submodule specifically includes: The current plot node location unit is used to locate the current plot node corresponding to the triggered plot advancement event from the preset main plot directed graph; The node retrieval unit is used to retrieve multiple candidate subsequent nodes associated with the current plot node; The candidate node filtering unit is used to remove candidate subsequent nodes whose object attributes do not meet the unlocking conditions, thereby obtaining multiple usable candidate nodes; The matching degree calculation unit is used to calculate the preference matching degree and condition matching degree corresponding to each available candidate node according to the object attributes and player behavior data; The comprehensive scoring unit is used to weight and fuse preference matching degree and condition matching degree using immersion weight to obtain the comprehensive score corresponding to each available candidate node; The subsequent plot node selection unit is used to select the available candidate node with the highest overall score as the subsequent plot node.
[0106] Optionally, the matching degree calculation unit is specifically used for: Player behavior characteristics are obtained by extracting multiple historical selection behavior features from player behavior data and performing an exponentially weighted average. The similarity between player behavior features and the plot content features of each available subsequent node is calculated as the preference matching degree; Read the list of character items associated with the object's properties; Calculate the condition matching degree between the character's item list and object attributes and the node operation conditions of each available subsequent node.
[0107] Optionally, the immersion weight includes preference weight and condition weight, and the plot node determination submodule also includes a weight adjustment unit for: According to the preset prediction cycle, the preset immersion prediction model is invoked to infer based on player behavior data and generate an immersion trend prediction curve. If the immersion trend prediction curve shows a decaying trend, the preference weights are adjusted upwards according to the first preset amplitude to obtain new preference weights. If the immersion trend prediction curve is a stationary trend, then the preference weight and condition weight will be set to preset values. If the immersion trend prediction curve shows an upward trend, the condition weights are adjusted upward according to the third preset amplitude to obtain new condition weights.
[0108] Optionally, the plot fragment selection submodule is specifically used for: Extract the corresponding node semantic vectors based on the plot synopsis of subsequent plot nodes; Calculate the first semantic similarity between each plot fragment and the node semantic vector in the pre-set plot fragment library; Plot fragments with a first semantic similarity exceeding the similarity threshold are selected as plot fragments to be determined; Select story fragments from the pending story fragments that meet the preset quantity range and have different fragment categories, and use them as various story fragments corresponding to subsequent story nodes.
[0109] Optionally, the script generation submodule is specifically used for: The plot order of each plot fragment is matched according to the plot type of the subsequent plot nodes; Extract the initial story options corresponding to each story fragment; The conditions of each initial plot option are checked according to the plot sequence to obtain the pending plot options associated with each plot fragment; By associating each plot fragment with its corresponding pending plot options according to the plot order, a plot branching script can be obtained.
[0110] Optionally, the branching story event generation module 203 is specifically used for: The object attributes are mapped according to a preset state parameter mapping table to obtain multiple state mapping values; Locate the second virtual object associated with the plot branch script and extract the initial interaction parameters for each; Traverse the second virtual object and adjust the initial interaction parameters of the second virtual object, which is the same as the first virtual object, according to the state mapping value to obtain intermediate interaction parameters; the intermediate interaction parameters include the object attitude value and the object behavior trigger probability; If a second virtual object exists that is different from the first virtual object, then the initial interaction parameters are determined as intermediate interaction parameters. The intermediate interaction parameters are constrained to each preset valid range to obtain the target interaction parameters; Based on the target interaction parameters, render each second virtual object and the plot branch script, generate branch plot events and display them.
[0111] Optionally, the device also includes a story fragment update module, specifically used for: In response to the natural language text input by the player, a large language model is invoked to perform semantic understanding of the natural language text and determine the intent classification vector; Calculate the second semantic similarity between the intent classification vector and the node semantic vector of subsequent plot nodes; If the second semantic similarity is lower than the preset mapping threshold, the semantic summary of the natural language text is extracted and combined with the preset plot fragments to create a template to generate new plot fragments; Link new plot fragments to subsequent plot nodes.
[0112] Optionally, the device also includes an object and difficulty adjustment module, specifically used for: During the execution of branching story events, player action data is continuously collected; Calculate the immersion deviation between player action data and preset expected behavior data; Based on immersion deviation and a preset modulation function, the object intervention coefficient is determined; Adjust the non-triggered virtual objects in branching story events according to the object intervention coefficient, in order to update the object attitude, object emotional polarity and object behavior probability of the non-triggered virtual objects; When a difficulty adjustment command is received from a player, the corresponding difficulty level is matched. Untriggered objects are reset according to their difficulty level, so that their attitude, emotional polarity, and behavioral probability are reset to the initial values corresponding to the difficulty level.
[0113] Optionally, player action data includes option switching frequency, text dwell time, text backtracking frequency, and skipping rate; the device also includes an immersion prediction model pre-training module, specifically used for: Based on a preset time window, a sequence feature vector is constructed using option switching frequency, text dwell time, text backtracking count, and skip ratio. The immersion prediction model is obtained by pre-training a pre-defined temporal prediction network using sequence feature vectors.
[0114] Optionally, the device also includes a story rewind module, specifically used for: Monitor players' replay behavior on historical story events according to a preset replay cycle; When the number of times the backtracking behavior exceeds the preset backtracking threshold, the historical objects involved in the historical plot events will be identified as objects to be recalled. When the step of selecting multiple plot fragments corresponding to subsequent plot nodes from the preset plot fragment library is executed again, the plot fragment to which the object to be recalled belongs is determined as a mandatory plot fragment.
[0115] This invention provides a computer device, including a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the game plot dynamic generation method as described in any embodiment of this invention.
[0116] This invention provides a computer-readable storage medium storing a computer program thereon, which, when executed, implements the game story dynamic generation method as described in any embodiment of this invention.
[0117] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0118] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0119] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0120] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0121] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0122] Indicatively, such as Figure 7 As shown, Figure 7 This is a schematic diagram of the internal structure of a computer device 300 provided in an embodiment of this application. The computer device 300 can be provided as a server. (Refer to...) Figure 7 The computer device 300 includes a processing component 302, which further includes one or more processors, and memory resources represented by memory 301 for storing instructions, such as application programs, that can be executed by the processing component 302. The application programs stored in memory 301 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 302 is configured to execute instructions to perform the text recognition method of any of the above embodiments.
[0123] The computer device 300 may also include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on storage.
[0124] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for dynamically generating game storylines, characterized in that, include: In response to the player's triggering of a plot-advancing event, acquire player behavior data and the object attributes of the first virtual object associated with the plot-advancing event; Based on the object attributes, the player behavior data, and the plot progression events, select plot fragments corresponding to subsequent plot nodes and generate plot branch scripts; Based on the object attributes and the player behavior data, the interaction parameters of the second virtual object associated with the story branch script are adjusted, and branch story events are rendered and displayed.
2. The method for dynamically generating game storylines according to claim 1, characterized in that, The step of selecting plot fragments corresponding to subsequent plot nodes and generating plot branch scripts based on the object attributes, player behavior data, and plot progression events includes: Based on the object attributes, the player behavior data, and the plot progression events, subsequent plot nodes are determined from the preset main plot directed graph; Select multiple plot fragments corresponding to the subsequent plot nodes from a preset plot fragment library; Combine all the aforementioned plot fragments to generate the plot branch scripts corresponding to the subsequent plot nodes.
3. The method for dynamically generating game storylines according to claim 2, characterized in that, The step of determining subsequent plot nodes from a preset main plot directed graph based on the object attributes, player behavior data, and triggered plot progression events includes: The current story node is located at the point in the pre-defined main storyline directed graph that triggers a story progression event. Retrieve multiple candidate subsequent nodes associated with the current story node; By removing candidate subsequent nodes whose object attributes do not meet the unlocking conditions, multiple usable candidate nodes are obtained; Based on the object attributes and the player behavior data, calculate the preference matching degree and condition matching degree corresponding to each available candidate node; The preference matching degree and the condition matching degree are weighted and fused using immersion weight to obtain the comprehensive score corresponding to each available candidate node; The candidate node with the highest overall score is selected as the subsequent story node.
4. The method for dynamically generating game storylines according to claim 3, characterized in that, The step of calculating the preference matching degree and condition matching degree corresponding to each available candidate node according to the object attributes and the player behavior data includes: Multiple historical selection behavior features are extracted from the player behavior data and then subjected to an exponentially weighted average to obtain the player behavior features; The similarity between the player's behavioral characteristics and the plot content characteristics of each available subsequent node is calculated as the preference matching degree; Read the list of character items associated with the object's attributes; Based on the character item list and the object attributes, calculate the condition matching degree between the node operation conditions and each of the available subsequent nodes.
5. The method for dynamically generating game storylines according to claim 3, characterized in that, The immersion weight includes preference weight and conditional weight, and the method further includes: According to the preset prediction cycle, the preset immersion prediction model is invoked to infer based on the player behavior data and generate an immersion trend prediction curve. If the immersion trend prediction curve is a decaying trend, the preference weight is adjusted upward according to the first preset amplitude to obtain a new preference weight. If the immersion trend prediction curve is a stationary trend, then the preference weight and the condition weight are set to preset values; If the immersion trend prediction curve is on an upward trend, the condition weights are adjusted upward according to the third preset amplitude to obtain new condition weights.
6. The method for dynamically generating game storylines according to claim 2, characterized in that, The step of selecting multiple plot fragments corresponding to the subsequent plot nodes from a preset plot fragment library includes: Based on the plot summary of the subsequent plot nodes, extract the corresponding node semantic vectors; Calculate the first semantic similarity between each plot fragment in the preset plot fragment library and the semantic vector of the node; Select plot fragments whose semantic similarity exceeds the similarity threshold as plot fragments to be determined; Select story fragments from the pending story fragments that meet a preset quantity range and have different fragment categories, and use them as multiple story fragments corresponding to the subsequent story nodes.
7. The method for dynamically generating game storylines according to claim 2, characterized in that, The combination of all the plot fragments generates the plot branch scripts corresponding to the subsequent plot nodes, including: The plot order of each plot fragment is matched according to the plot type of the subsequent plot nodes; Extract the initial story options corresponding to each of the aforementioned story fragments; The initial plot options are checked according to the plot sequence to obtain pending plot options associated with each plot fragment. By associating the plot fragments with their corresponding pending plot options according to the plot order, a plot branching script is obtained.
8. The method for dynamically generating game storylines according to claim 1, characterized in that, The step of adjusting the interaction parameters of the second virtual object associated with the story branch script based on the object attributes and the player behavior data, rendering and generating branch story events, includes: The object attributes are mapped according to a preset state parameter mapping table to obtain multiple state mapping values; Locate the second virtual object associated with the plot branch script, and extract the initial interaction parameters respectively; Traverse the second virtual object, and adjust the initial interaction parameters of the second virtual object that is the same as the first virtual object according to the state mapping value to obtain intermediate interaction parameters; the intermediate interaction parameters include the object attitude value and the object behavior trigger probability; If a second virtual object exists that is different from the first virtual object, then the initial interaction parameters are determined as intermediate interaction parameters; The intermediate interaction parameters are constrained to each preset valid range to obtain the target interaction parameters; Based on the target interaction parameters, each of the second virtual objects and the plot branch scripts are rendered to generate and display branch plot events.
9. The method for dynamically generating game storylines according to claim 1, characterized in that, The method further includes: In response to the natural language text input by the player, a large language model is invoked to perform semantic understanding on the natural language text and determine the intent classification vector; Calculate the second semantic similarity between the intent classification vector and the node semantic vector of the subsequent plot node; If the second semantic similarity is lower than the preset mapping threshold, then the semantic summary of the natural language text is extracted and combined with the preset plot fragment to create a template to generate a new plot fragment; Link the new plot fragments to the subsequent plot nodes.
10. The method for dynamically generating game storylines according to claim 1, characterized in that, The method further includes: During the execution of the branching story events, player action data is continuously collected; Calculate the immersion deviation between the player's operation data and the preset expected behavior data; Based on the immersion deviation and the preset modulation function, the object intervention coefficient is determined; The untriggered virtual objects of the branch plot events are adjusted according to the object intervention coefficient to update the object attitude, object emotional polarity, and object behavior probability of the untriggered virtual objects; When a difficulty adjustment command is received from the player, the difficulty level corresponding to the difficulty adjustment command is matched. The untriggered objects are reset according to the difficulty level, so that the object attitude, the object emotional polarity, and the object behavior probability of the untriggered objects are reset to the initial values corresponding to the difficulty level.
11. The method for dynamically generating game storylines according to claim 10, characterized in that, The player operation data includes option switching frequency, text dwell time, text backtracking count, and skip ratio; the method also includes: A sequence feature vector is constructed according to a preset time window using the option switching frequency, the text dwell time, the number of text backtrackings, and the skip ratio; The preset temporal prediction network is pre-trained using the sequence feature vectors to obtain an immersion prediction model.
12. The method for dynamically generating game storylines according to claim 1, characterized in that, The method further includes: Monitor the player's replay behavior on historical story events according to a preset replay cycle; When the number of times the backtracking behavior exceeds the preset backtracking threshold, the historical objects involved in the historical plot events are identified as objects to be recalled. When the step of selecting multiple plot fragments corresponding to the subsequent plot node from the preset plot fragment library is executed again, the plot fragment to which the object to be recalled belongs is determined as a mandatory plot fragment.
13. A device for generating dynamic game storylines, characterized in that, include: The player information acquisition module is used to respond to the player's triggering operation on the plot advancement event, and to acquire player behavior data and the object attributes of the first virtual object associated with the plot advancement event; The plot branch script generation module is used to select plot fragments corresponding to subsequent plot nodes and generate plot branch scripts based on the object attributes, the player behavior data and the plot advancement events; The branch story event generation module is used to adjust the interaction parameters of the second virtual object associated with the story branch script based on the object attributes and the player behavior data, and to render and generate branch story events for display.
14. A computer device, characterized in that, The system includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor causes the processor to perform the steps of the game story dynamic generation method as described in any one of claims 1-12.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed, it implements the game plot dynamic generation method as described in any one of claims 1-12.