AOI algorithm performance optimization method and system and electronic equipment
By adding data caching to the AOI algorithm, the cached data can be directly used as the target object of interest, which solves the problem of excessive CPU consumption and improves user experience and server performance.
Patent Information
- Application Number
- CN202410770406.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-11-05
AI Technical Summary
When the number of objects is large, the AOI algorithm consumes too much CPU, causing server lag and a poor user experience.
Adding data caching to the AOI algorithm allows the cache space to store the target user's objects of interest. When the cached data is valid, it is directly used as the target objects of interest, avoiding continuous calls to the AOI algorithm and reducing the computation frequency and workload.
By optimizing cached data, the frequency of AOI algorithm usage is reduced, processor resource consumption is decreased, server lag is avoided, and user experience is improved.
Smart Images

Figure CN118892646A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of game development technology, and in particular to an AOI algorithm performance optimization method, system and electronic device. Background Art
[0002] Area Of Interest (AOI) is a very important basic module in massively multiplayer online game servers, which largely determines the operating efficiency of the game server. AOI is a technology used by game servers to manage players and NPCs. The core idea is to quickly find objects of interest near players to facilitate interaction management between objects.
[0003] However, the AOI algorithm is used frequently. When the number of objects is large, the AOI algorithm will cause excessive CPU performance consumption and even server lag, resulting in a poor user experience. Summary of the invention
[0004] The embodiments of the present application provide an AOI algorithm performance optimization method, system, and electronic device to at least solve the problems of excessive CPU performance consumption and poor user experience in the related art.
[0005] In a first aspect, an embodiment of the present application provides an AOI algorithm performance optimization method, comprising: In response to receiving a request to call the AOI algorithm, determining whether cached data in a cache is valid, wherein the cache is used to store objects of interest to a target user, and the cached data is valid including: the cached data is not empty and the cached data is within a data validity period; In response to the cached data being valid, the cached data is used as a target object of interest.
[0006] In one embodiment, the method further comprises: In response to the cache data being invalid, clearing the cache data in the cache; Determine an object of interest to a target user by using an AOI algorithm, store the object of interest in the cache, and set a data validity period for the object of interest; The object of interest is taken as a target object of interest.
[0007] In one embodiment, clearing cache data in the cache includes: Setting the cache data in the cache to empty; or, Delete the cached data in the cache.
[0008] In one embodiment, the cache data invalidation is configured as follows: Receive information that the cache data is invalid from the game system, and set the cache data to empty.
[0009] In one embodiment, the receiving of information that cache data is invalid from the game system includes: receiving a cache data invalidation message sent by the game system in response to the disappearance of the object of interest; or Receiving information indicating that cached data is invalid, sent by the gaming system in response to the object of interest exceeding a preset area of interest; or The receiving game system sends a message indicating that cached data is invalid in response to a new object appearing in the area of interest.
[0010] In one embodiment, the method further includes: initial cache data in the cache is invalidated.
[0011] In a second aspect, an embodiment of the present application provides an AOI algorithm performance optimization system, including: A judgment module: used for judging whether the cached data in the cache is valid in response to receiving a request to call the AOI algorithm, wherein the cache is used to store the object of interest of the target user, and the cached data is valid including: the cached data is not empty and the cached data is within the data validity period; A determination module is configured to use the cached data as a target object of interest in response to the cached data being valid.
[0012] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the AOI algorithm performance optimization method described in the first aspect when executing the computer program.
[0013] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the AOI algorithm performance optimization method described in the first aspect is implemented.
[0014] An AOI algorithm performance optimization method, system, and electronic device provided in the embodiments of the present application have at least the following technical effects.
[0015] This application adds data cache to the AOI algorithm and uses the cache space to store the target user's objects of interest. When the cache data is valid, the cache data is directly used as the target object of interest to avoid continuous calls to the AOI algorithm, reduce the calculation frequency and amount of the AOI algorithm, reduce the processor's resource consumption, and improve the user experience.
[0016] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 is a flow chart of a method for optimizing AOI algorithm performance according to an exemplary embodiment; Figure 2 is a structural block diagram of an AOI algorithm performance optimization system according to an exemplary embodiment; Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0019] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.
[0020] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0021] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantity limitation, and may indicate the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0022] In a first aspect, an embodiment of the present application provides an AOI algorithm performance optimization method, which is mainly used in the game process. Figure 1 is a flow chart of a method for optimizing AOI algorithm performance according to an exemplary embodiment. Figure 1 As shown, the method includes: Step S101, in response to receiving a request to call the AOI algorithm, determining whether cached data in the cache is valid, wherein the cache is used to store objects of interest to the target user, and cached data validity includes: the cached data is not empty and the cached data is within the data validity period.
[0023] Optionally, based on the AOI algorithm, a cache area is added, and the cache area is used to store the target user's objects of interest. In the game, the objects of interest generally refer to other players and monsters within a certain distance area around the player. The objects of interest are related to the specific game type and the player's field of view. The validity period of the cached data is generally around 100 milliseconds to 1000 milliseconds, which is related to the specific game requirements and can be set according to the specific application scenario.
[0024] In one example, the initial cache data in the cache is invalid. Optionally, the cache data is a pointer to the object of interest, and the initial cache data is usually set to a null value.
[0025] Step S102: In response to the cached data being valid, taking the cached data as a target object of interest.
[0026] Optionally, if the cache data is valid, that is, the object of interest of the target user has not changed, when it is necessary to obtain the object of interest of the target user, the object of interest previously calculated and stored in the cache may be directly used as the current target object of interest.
[0027] In this way, when the cached data is valid, the cached data is directly used as the target object of interest, which reduces the calculation frequency of the AOI algorithm, reduces the resource consumption of the processor, avoids the problem of server freezing due to excessive processor resource consumption, and improves the user experience.
[0028] In one example, the method further includes: Step S103, in response to the cache data being invalid, clearing the cache data in the cache. Optionally, when the object of interest needs to be obtained, if the cache data is invalid, it indicates that the object of interest of the target user has changed, or the stored cache data has exceeded the data validity period, or the AOI algorithm has not been run, and there is only initial cache data in the cache space.
[0029] In one example, the invalidation of cache data in step S103 is configured as: receiving information of invalidation of cache data sent by the game system, and setting the cache data to empty.
[0030] Optionally, when an object of interest changes, other game systems can actively invalidate data during execution. For example, when new objects are generated, destroyed, or teleported in other game systems, a leave event is actively sent to players interested in these changed objects, that is, information that the cached data is invalid. After receiving the data invalidation information, the cached data is set to invalid. Generally, setting the cache invalid is to set the cached data to a null value.
[0031] In one example, receiving information that cache data is invalid sent by a game system includes: receiving information that cache data is invalid sent by the game system in response to the disappearance of an object of interest; or receiving information that cache data is invalid sent by the game system in response to an object of interest exceeding a preset area of interest; or receiving information that cache data is invalid sent by the game system in response to the appearance of a new object in the area of interest.
[0032] Optionally, when the object of interest disappears or exceeds the preset area of interest, it indicates that the object of interest that the target user is concerned about has changed, and the object of interest stored in the cache has become invalid and needs to be recalculated. When a new object appears in the area of interest, it also indicates that the object of interest that the target user is concerned about has changed, and the object of interest stored in the cache has become invalid and needs to be recalculated.
[0033] In one example, clearing the cached data in the cache in step S103 includes: setting the cached data in the cache to null, or deleting the cached data in the cache. Optionally, the cached data is a pointer to an object of interest, and the object pointer of the cached data in the program is set to null. If the language is C++, the object pointer needs to be deleted.
[0034] Step S104: determine the object of interest of the target user through the AOI algorithm, store the object of interest in the cache, and set a data validity period for the object of interest.
[0035] Optionally, the target user's object of interest is searched by conventional AOI algorithms such as nine-square grid traversal, cross linked list or quadtree. The area of interest means that the target user is only interested in objects within a certain distance area around him. The object of interest is mainly related to the specific game type and the player's field of view. The specific range of the area of interest can be set according to the actual game scene. When the player's field of view is a local space, for example, objects within 10 meters around the target user belong to the object of interest. Among them, the types of objects of interest include but are not limited to: other players, monsters, props, special effects, etc. The types of objects of interest are mainly related to the specific game content and are not limited to the types listed in this application. The data validity period of cached data is generally set at about 100 milliseconds to 1000 milliseconds, and the data validity period of cached data can be set according to specific game requirements.
[0036] Step S105, taking the object of interest as the target object of interest. Optionally, when the cached data is invalid, the object of interest of the target user is recalculated by the AOI algorithm, and the recalculated object of interest is not taken as the target object of interest at the current moment.
[0037] In this way, the cache space is used to store the target user's objects of interest. When the object of interest needs to be obtained, if the cache data stored in the cache space is invalid, the object of interest at the current moment is recalculated. This avoids continuous calculations through the AOI algorithm, reduces the frequency of use of the AOI algorithm, and effectively reduces CPU consumption.
[0038] In summary, the present application adds data cache to the AOI algorithm, and uses the cache space to store the target user's objects of interest. When the cache data is valid, the cache data is directly used as the target object of interest; when the cache data is invalid, the object of interest at the current moment is obtained through the AOI algorithm. In this way, it avoids uninterrupted calculations through the AOI algorithm, reduces the frequency of use of the AOI algorithm, reduces processor resource consumption, avoids server freezes due to excessive processor resource consumption, and improves user experience.
[0039] In a second aspect, the present application embodiment provides an AOI algorithm performance optimization system. Figure 2 is a structural block diagram of an AOI algorithm performance optimization system according to an exemplary embodiment. Figure 2 As shown, the system includes: Judgment module 100: used to judge whether cached data in the cache is valid in response to receiving a request to call the AOI algorithm, wherein the cache is used to store objects of interest to the target user, and the cached data is valid including: the cached data is not empty and the cached data is within the data validity period.
[0040] Determining module 200: is used to use the cached data as a target object of interest in response to the cached data being valid.
[0041] In one example, the system further includes: invalidating initial cache data in the cache.
[0042] In one example, the system further includes: Cleaning unit: used for cleaning cache data in the cache in response to the cache data being invalid.
[0043] Computing unit: used to determine the object of interest of the target user through the AOI algorithm, store the object of interest in the cache, and set the data validity period for the object of interest.
[0044] Determining unit: used for taking the object of interest as the target object of interest.
[0045] In one example, the cleaning unit includes: setting the cache data in the cache to empty, or deleting the cache data in the cache.
[0046] In one example, the invalidation of cache data in the cleaning unit is configured to: receive the invalidation information of cache data sent by the game system, and set the cache data to empty.
[0047] In one example, receiving the information that the cached data is invalid from the game system includes: Receiving a cache data invalidation message sent by the game system in response to the death of the object of interest; or Receiving a message indicating that cached data is invalid, sent by the gaming system in response to the object of interest exceeding a preset region of interest; or The receiving game system sends a message indicating that cached data is invalid in response to a new object appearing in the area of interest.
[0048] In summary, the present application adds data cache to the AOI algorithm, and uses the cache space to store the target user's objects of interest. When the cache data is valid, the cache data is directly used as the target object of interest; when the cache data is invalid, the object of interest at the current moment is obtained through the AOI algorithm. In this way, it avoids uninterrupted calculations through the AOI algorithm, reduces the frequency of use of the AOI algorithm, reduces processor resource consumption, avoids server freezes due to excessive processor resource consumption, and improves user experience.
[0049] In a third aspect, an embodiment of the present application provides an electronic device, Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the AOI algorithm performance optimization method provided in the first aspect is implemented. Figure 3 The electronic device 60 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0050] The electronic device 60 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 60 may include but are not limited to: at least one processor 61, at least one memory 62, and a bus 63 connecting different system components (including the memory 62 and the processor 61).
[0051] The bus 63 includes a data bus, an address bus, and a control bus.
[0052] The memory 62 may include a volatile memory, such as a random access memory (RAM) 621 and / or a cache memory 622 , and may further include a read-only memory (ROM) 623 .
[0053] The memory 62 may also include a program / utility 625 having a set (at least one) of program modules 624, such program modules 624 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0054] The processor 61 executes various functional applications and data processing by running the computer programs stored in the memory 62, such as the AOI algorithm performance optimization method of the first aspect of the present application.
[0055] The electronic device 60 may also communicate with one or more external devices 64 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 65. Furthermore, the model-generated device 60 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 66. As shown, the network adapter 66 communicates with other modules of the model-generated device 60 via a bus 63. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the model-generated device 60, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.
[0056] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.
[0057] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a program stored thereon, and when the program is executed by a processor, the AOI algorithm performance optimization method provided in the first aspect is implemented.
[0058] The readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination of the above.
[0059] In a possible implementation, the present invention can also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to enable the terminal device to execute the steps of the AOI algorithm performance optimization method provided in the first aspect.
[0060] The program code for executing the present invention may be written in any combination of one or more programming languages, and may be executed entirely on a user device, partially on a user device, as an independent software package, partially on a user device and partially on a remote device, or entirely on a remote device.
[0061] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0062] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for optimizing AOI algorithm performance, characterized in that: include: In response to receiving a request to call the AOI algorithm, determining whether cached data in a cache is valid, wherein the cache is used to store objects of interest to a target user, and the cached data is valid including: the cached data is not empty and the cached data is within a data validity period; In response to the cached data being valid, the cached data is used as a target object of interest.
2. The AOI algorithm performance optimization method according to claim 1, characterized in that: The method further comprises: In response to the cache data being invalid, clearing the cache data in the cache; Determine an object of interest to a target user by using an AOI algorithm, store the object of interest in the cache, and set a data validity period for the object of interest; The object of interest is taken as a target object of interest.
3. The AOI algorithm performance optimization method according to claim 2, characterized in that: The clearing of cache data in the cache includes: Setting the cache data in the cache to empty; or, Delete the cached data in the cache.
4. The AOI algorithm performance optimization method according to claim 2, characterized in that: The cache data invalidation is configured as: Receive information that the cache data is invalid from the game system, and set the cache data to empty.
5. The AOI algorithm performance optimization method according to claim 4, characterized in that: The receiving of the information that the cache data is invalid sent by the game system includes: receiving a cache data invalidation message sent by the game system in response to the disappearance of the object of interest; or Receiving information indicating that cached data is invalid, sent by the gaming system in response to the object of interest exceeding a preset area of interest; or The receiving game system sends a message indicating that cached data is invalid in response to a new object appearing in the area of interest.
6. The AOI algorithm performance optimization method according to claim 1, characterized in that: The method further comprises: The initial cache data in the cache is invalidated.
7. An AOI algorithm performance optimization system, characterized in that: include: A judgment module: used for judging whether the cached data in the cache is valid in response to receiving a request to call the AOI algorithm, wherein the cache is used to store the object of interest of the target user, and the cached data is valid including: the cached data is not empty and the cached data is within the data validity period; A determination module is configured to use the cached data as a target object of interest in response to the cached data being valid.
8. An electronic device, characterized in that: include Memory, processor, and A computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the AOI algorithm performance optimization method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the AOI algorithm performance optimization method according to any one of claims 1 to 6 is implemented.
