A game map pathfinding algorithm selection method and computer device
Patent Information
- Application Number
- CN202610980106.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-02
- Publication Date
- 2026-08-21
AI Technical Summary
[0003]在现有技术中,在游戏开发往往只是直接采用主流的寻路算法,完全忽略了不同的游戏地图环境会对各种寻路算法的生成移动路径的效率产生影响,而且不同的寻路算法对应不同的游戏地图环境所占用的运行算力资源也不同,当寻路算法占用的运行算力资源过多时,会影响游戏其他方面的运行,或者直接影响设备的运行
[0041]相对于相关技术,本申请的游戏地图寻路算法选择方法,通过对游戏地图样本进行起点和终点的随机标记,得到若干个第一地图点位样本;根据各个第一地图点位样本采用各种寻路算法生成移动路径的第一点位寻路用时和第一点位算力用量,获取游戏地图样本的最优寻路算法,并对若干个不同的游戏地图样本进行聚类分析,得到若干个地图样本分类簇,从而在目标游戏开发的时候,根据目标游戏的游戏地图数据对应的目标地图样本分类簇,获取对应的目标寻路算法。整个过程中,由于游戏地图样本的最优寻路算法是基于各种寻路算法生成移动路径的第一点位寻路用时和第一点位算力用量获取的,因此,地图样本分类簇对应的最优寻路算法也兼顾了生成移动路径的效率和占用算力资源这两方面需求,再利用聚类分析获取游戏地图数据对应的目标地图样本分类簇,即可为目标游戏快速获取兼顾生成移动路径的效率和占用算力资源这两方面需求的目标寻路算法。
Smart Images

Figure CN122605183A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of game map pathfinding, specifically to a method for selecting a game map pathfinding algorithm and a computer device. Background Technology
[0002] Automatic pathfinding in games refers to the function of characters or units in games autonomously calculating movement paths based on map information and algorithms, and moving to the target point along the movement path. It is commonly found in MMORPGs, MOBAs, open-world games, and RPGs, and is used to simplify travel, track quests, or support operations.
[0003] In existing technologies, game development often simply adopts mainstream pathfinding algorithms, completely ignoring the impact of different game map environments on the efficiency of various pathfinding algorithms in generating movement paths. Moreover, different pathfinding algorithms consume different amounts of computing resources for different game map environments. When a pathfinding algorithm consumes too much computing resources, it will affect other aspects of the game's operation or directly affect the operation of the device.
[0004] Therefore, to balance the efficiency of generating movement paths with the computational resources required, various pathfinding algorithms need to be tested during game development, which will significantly increase the time cost of game development. Summary of the Invention
[0005] The purpose of this application is to overcome the shortcomings and deficiencies in the existing technology and provide a method and computer device for selecting a game map pathfinding algorithm. Based on the game map data of the target game, it can quickly obtain a target pathfinding algorithm for the target game that takes into account both the efficiency of generating movement paths and the consumption of computing resources.
[0006] The first aspect of this application provides a method for selecting a pathfinding algorithm for a game map, including:
[0007] Randomly mark the start and end points of the game map samples to obtain several first map point samples;
[0008] Based on the pathfinding time and computing power consumption of the first point in each first map point sample, various pathfinding algorithms are used to generate the movement path, and the optimal pathfinding algorithm for the game map sample is obtained.
[0009] Cluster analysis was performed on several different game map samples to obtain several map sample classification clusters;
[0010] Cluster analysis is performed on the game map data of the target game to obtain the correspondence between the game map data and the several map sample classification clusters;
[0011] If the correspondence indicates the existence of a target map sample classification cluster corresponding to the game map data, the optimal pathfinding algorithm for the target map sample classification cluster is determined as the target pathfinding algorithm for the target game.
[0012] As one implementation method, the step of obtaining the optimal pathfinding algorithm for the game map sample by generating the path for each first map point sample using various pathfinding algorithms and the computational power consumption of the first point is as follows:
[0013] The time and computing power required for the first point of the movement path are calculated by obtaining samples of each first map point and using various pathfinding algorithms to generate the first point of the movement path.
[0014] Based on the pathfinding time and computing power consumption of all first points in the corresponding game map sample, obtain the pathfinding time and computing power consumption of the first algorithm for various pathfinding algorithms corresponding to the game map sample.
[0015] The optimal pathfinding algorithm for the game map sample is determined based on the ratio of the pathfinding time to the computing power consumption of the first algorithm.
[0016] As one implementation method, the step of determining the optimal pathfinding algorithm for the game map sample based on the ratio of the pathfinding time to the computing power consumption of the first algorithm includes:
[0017] The pathfinding algorithm with the smallest ratio is determined as the optimal pathfinding algorithm for the game map sample.
[0018] As one implementation, after determining the pathfinding algorithm with the smallest ratio as the optimal pathfinding algorithm for the game map sample, the method further includes the following steps:
[0019] The absolute value of the difference between the optimal pathfinding algorithm and other pathfinding algorithms is obtained as the ratio of the pathfinding time of the first algorithm to the computing power of the first algorithm, thus obtaining the first algorithm difference.
[0020] If there is a first algorithm gap smaller than a preset threshold, the corresponding pathfinding algorithm will be used as a candidate pathfinding algorithm.
[0021] The game map sample is then randomly marked with its start and end points to obtain several second map point samples; wherein the number of second map point samples is at least twice that of the first map point samples.
[0022] Based on the ratio of the pathfinding time to the computational power consumption of the second algorithm for each second map point sample using the optimal pathfinding algorithm and the candidate pathfinding algorithm, the optimal pathfinding algorithm for the game map sample is re-determined.
[0023] As one implementation method, after performing cluster analysis on several different game map samples to obtain several map sample classification clusters, the following steps are included:
[0024] The reference distance of each map sample classification cluster is obtained based on the maximum sample distance difference of each map sample classification cluster and the preset reference coefficient.
[0025] From each of the map sample classification clusters, obtain outlier game map samples whose optimal pathfinding algorithm differs from that of the cluster center sample; wherein, the cluster center sample is the game map sample that serves as the cluster center of the map sample classification cluster.
[0026] If there are out-of-category game map samples whose sample distance difference with the cluster center sample is less than or equal to the reference distance, a secondary clustering analysis is performed on the game map samples in the map sample classification cluster to obtain several new map sample classification clusters with a smaller range.
[0027] As one implementation method, after obtaining the outlier game map samples from each of the map sample classification clusters whose optimal pathfinding algorithm differs from that of the cluster center sample, the method further includes the following steps:
[0028] If there are only out-of-type game map samples whose sample distance difference with the cluster center sample is greater than the reference distance, the out-of-type game map samples are removed from the map sample classification cluster, so that all game map samples in the same map sample classification cluster correspond to the same optimal pathfinding algorithm.
[0029] As one implementation method, after performing cluster analysis on the game map data of the target game to obtain the correspondence between the game map data and the plurality of map sample classification clusters, the method further includes the following steps:
[0030] If the correspondence indicates that there is no target map sample classification cluster corresponding to the game map data, obtain the trained pathfinding algorithm selection model;
[0031] The game map data is input into the pathfinding algorithm selection model to obtain the target pathfinding algorithm selected by the pathfinding algorithm selection model.
[0032] As one implementation method, the pathfinding algorithm selection model is trained through the following steps:
[0033] Based on the ratio of the pathfinding time to the computing power of the first algorithm for each pathfinding algorithm corresponding to the game map sample, the matching score between the game map sample and each pathfinding algorithm is obtained.
[0034] The game map sample and multiple pathfinding algorithms to be selected are input into the deep learning model to obtain the sample pathfinding algorithm selected by the deep learning model from multiple pathfinding algorithms;
[0035] Based on the matching score corresponding to the sample pathfinding algorithm and the maximum matching score corresponding to the game map sample, a loss function is constructed;
[0036] Based on the loss function, the deep learning model is updated using the gradient descent algorithm to obtain the pathfinding algorithm selection model.
[0037] As one implementation method, the step of obtaining the matching score between the game map sample and various pathfinding algorithms based on the ratio of the pathfinding time to the computing power consumption of the first algorithm for each pathfinding algorithm corresponding to the game map sample includes:
[0038] The matching score is obtained using the following formula:
[0039] ;
[0040] in, For the matching score, For the game map sample corresponding to the first The ratio of the pathfinding time to the computational power used by the first algorithm in a pathfinding algorithm. The average ratio of the pathfinding time to the computing power consumption of the first algorithm for all pathfinding algorithms corresponding to the game map sample. The standard deviation of the ratio of the pathfinding time to the computing power of the first algorithm for all pathfinding algorithms corresponding to the game map sample.
[0041] Compared to related technologies, the game map pathfinding algorithm selection method of this application obtains several first map point samples by randomly marking the start and end points of game map samples. Based on the pathfinding time and computational cost of generating movement paths using various pathfinding algorithms for each first map point sample, the optimal pathfinding algorithm for the game map sample is obtained. Furthermore, cluster analysis is performed on several different game map samples to obtain several map sample classification clusters. Thus, during the development of the target game, the corresponding target pathfinding algorithm is obtained based on the target map sample classification cluster corresponding to the target game's game map data. Throughout this process, since the optimal pathfinding algorithm for the game map samples is obtained based on the pathfinding time and computational cost of generating movement paths using various pathfinding algorithms, the optimal pathfinding algorithm corresponding to the map sample classification cluster also considers both the efficiency of generating movement paths and the computational resource consumption. By using cluster analysis to obtain the target map sample classification cluster corresponding to the game map data, a target pathfinding algorithm that balances both the efficiency of generating movement paths and the computational resource consumption requirements can be quickly obtained for the target game.
[0042] A second aspect of this application provides a computer device including a storage device, a processor, and a computer program stored in the storage device and executable by the processor, wherein the processor executes the computer program to implement the steps of the game map pathfinding algorithm selection method as described above.
[0043] To provide a clearer understanding of this application, the specific embodiments of this application will be described below in conjunction with the accompanying drawings. Attached Figure Description
[0044] Figure 1 This is a flowchart of a game map pathfinding algorithm selection method according to an embodiment of this application.
[0045] Figure 2 The flowchart shows steps S31-S33 of a game map pathfinding algorithm selection method according to an embodiment of this application.
[0046] Figure 3 The flowchart shows steps S21-S23 of a game map pathfinding algorithm selection method according to an embodiment of this application.
[0047] Figure 4 The flowchart shows steps S24-S27 of the game map pathfinding algorithm selection method according to an embodiment of this application.
[0048] Figure 5 This is a schematic diagram of a computer device provided in one embodiment of this application.
[0049] 5. Computer equipment; 50. Processor; 51. Memory. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0051] It should be understood that the described embodiments are merely some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of the embodiments of this application.
[0052] In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. In the description of this application, it should be understood that the terms "first," "second," "third," etc., are used only to distinguish similar objects and are not necessarily used to describe a specific order or sequence, nor should they be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances. The singular forms "a," "the," and "the" used in this application and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. The word "if" as used herein can be interpreted as "when," "when," or "in response to determination."
[0053] Furthermore, in the description of this application, unless otherwise stated, "several" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0054] Please see Figure 1 This is a flowchart of a game map pathfinding algorithm selection method according to the first embodiment of this application. The method includes:
[0055] S1: Randomly mark the start and end points of the game map samples to obtain several first map point samples.
[0056] The number of first map point samples corresponding to a game map sample is related to the number of random markings; the more random markings, the more first map point samples are obtained. It should be noted that the start and end points of each first map point sample are not exactly the same. That is, between two first map point samples, the start and end points may be different, the start points may be the same but the end points may be different, or the start points may be different but the end points may be the same, but it is impossible for both the start and end points to be the same.
[0057] S2: Based on each first map point sample, various pathfinding algorithms are used to generate the first point pathfinding time and first point computing power consumption of the movement path, and the optimal pathfinding algorithm of the game map sample is obtained.
[0058] Among them, the pathfinding time for the first point refers to the time taken by the pathfinding algorithm to generate a movement path based on the starting point and ending point marked by the first map point sample, and the computing power consumption for the first point refers to the amount of computing power resources occupied by the pathfinding algorithm to generate the movement path.
[0059] S3: Perform cluster analysis on several different game map samples to obtain several map sample classification clusters;
[0060] Cluster analysis is an unsupervised statistical analysis and data mining method that divides physical or abstract objects into multiple clusters based on data similarity. It achieves classification results where objects within the same cluster are highly similar, while objects in different clusters are significantly different. No pre-defined categories are required, and its core function is to explore the characteristic relationships between data points. In the case of game map samples, these characteristic relationships can include map size, shape, obstacles, or the range and shape of areas that can serve as movement paths.
[0061] Please see Figure 2 To ensure that all game map samples in the same map sample classification cluster correspond to the same optimal pathfinding algorithm, the following steps are included after step S3:
[0062] S31: Obtain the reference distance of each of the map sample classification clusters based on the maximum sample distance difference of each of the map sample classification clusters and the preset reference coefficient;
[0063] The maximum sample distance difference refers to the distance between the cluster center sample and the farthest game map sample within the corresponding map sample classification cluster. All sample distance differences are absolute values. The reference coefficient is set by the user, and can be set to, for example, 0.9, 0.85, 0.8, 0.75, 0.7, etc.
[0064] S32: From each of the map sample classification clusters, obtain a different type of game map sample whose optimal pathfinding algorithm is different from that of the cluster center sample; wherein, the cluster center sample is the game map sample that serves as the cluster center of the map sample classification cluster.
[0065] S33: If there are out-of-category game map samples whose sample distance difference with the cluster center sample is less than or equal to the reference distance, perform secondary clustering analysis on the game map samples in the map sample classification cluster to obtain several new map sample classification clusters with a smaller range.
[0066] When a map sample cluster contains outlier game map samples, it cannot be used to determine the optimal pathfinding algorithm for the target game. Therefore, further processing is needed for map sample clusters containing outlier game map samples. When there are outlier game map samples whose distance difference from the cluster center sample is less than or equal to the reference distance, it indicates an anomaly in the map sample cluster. In this case, a secondary clustering analysis needs to be performed, combining the feature data of the game map samples with the corresponding optimal pathfinding algorithm. Specifically, the corresponding optimal pathfinding algorithm is added as a new dimension for secondary clustering analysis until all game map samples in the same map sample cluster correspond to the same optimal pathfinding algorithm. It should be noted that any map sample cluster must include at least three game map samples; otherwise, it is considered an invalid map sample cluster.
[0067] S34: If there are only out-of-type game map samples whose sample distance difference with the cluster center sample is greater than the reference distance, remove the out-of-type game map samples from the map sample classification cluster, so that all game map samples in the same map sample classification cluster correspond to the same optimal pathfinding algorithm.
[0068] If there are only out-of-type game map samples whose sample distance difference with the cluster center sample is greater than the reference distance, the range of the map sample classification cluster can be reduced by removing the out-of-type game map samples, so that all game map samples in the same map sample classification cluster correspond to the same optimal pathfinding algorithm.
[0069] S4: Perform cluster analysis on the game map data of the target game to obtain the correspondence between the game map data and the several map sample classification clusters;
[0070] The correspondence includes situations where the game map data is located within a certain map sample classification cluster, or where the game map data is located outside the range of all map sample classification clusters. For example, when the game map data is located within map sample classification cluster A, it means that map sample classification cluster A is the target map sample classification cluster corresponding to the game map data.
[0071] S5: If the correspondence indicates the existence of a target map sample classification cluster corresponding to the game map data, the optimal pathfinding algorithm of the target map sample classification cluster is determined as the target pathfinding algorithm of the target game.
[0072] Compared to related technologies, the game map pathfinding algorithm selection method of this application obtains several first map point samples by randomly marking the start and end points of game map samples. Based on the pathfinding time and computational cost of generating movement paths using various pathfinding algorithms for each first map point sample, the optimal pathfinding algorithm for the game map sample is obtained. Furthermore, cluster analysis is performed on several different game map samples to obtain several map sample classification clusters. Thus, during the development of the target game, the corresponding target pathfinding algorithm is obtained based on the target map sample classification cluster corresponding to the target game's game map data. Throughout this process, since the optimal pathfinding algorithm for the game map samples is obtained based on the pathfinding time and computational cost of generating movement paths using various pathfinding algorithms, the optimal pathfinding algorithm corresponding to the map sample classification cluster also considers both the efficiency of generating movement paths and the computational resource consumption. By using cluster analysis to obtain the target map sample classification cluster corresponding to the game map data, a target pathfinding algorithm that balances both the efficiency of generating movement paths and the computational resource consumption requirements can be quickly obtained for the target game.
[0073] Please see Figure 3 In a feasible embodiment, S2: the step of obtaining the optimal pathfinding algorithm for the game map sample by generating the first point path using various pathfinding algorithms based on each first map point sample and the first point pathfinding time and computing power usage, includes:
[0074] S21: Obtain the first map point samples and use various pathfinding algorithms to generate the first point pathfinding time and first point computing power usage of the movement path;
[0075] S22: Based on the pathfinding time and computing power of all first points in the corresponding game map sample, obtain the pathfinding time and computing power of the first algorithm for each pathfinding algorithm corresponding to the game map sample.
[0076] S23: Determine the optimal pathfinding algorithm for the game map sample based on the ratio of the pathfinding time of the first algorithm to the computing power consumption of the first algorithm.
[0077] Specifically, the pathfinding algorithm with the smallest ratio is determined as the optimal pathfinding algorithm for the game map sample.
[0078] Please see Figure 4 In one feasible embodiment, after determining the pathfinding algorithm with the smallest ratio as the optimal pathfinding algorithm for the game map sample, the method further includes the following steps:
[0079] S24: Obtain the absolute value of the difference between the ratio of the pathfinding time of the first algorithm to the computing power consumption of the first algorithm of the optimal pathfinding algorithm and other pathfinding algorithms, and obtain the first algorithm difference;
[0080] S25: If there is a first algorithm gap that is less than a preset threshold, the corresponding pathfinding algorithm will be used as a candidate pathfinding algorithm.
[0081] S26: Randomly mark the start and end points of the game map sample again to obtain several second map point samples; wherein the number of second map point samples is at least twice that of the first map point samples;
[0082] S27: Based on the ratio of the pathfinding time to the computational power of the second algorithm for each second map point sample using the optimal pathfinding algorithm and the candidate pathfinding algorithm, the optimal pathfinding algorithm for the game map sample is re-determined.
[0083] When there is a first algorithm gap less than a preset threshold, it means that in addition to the optimal pathfinding algorithm, there are other pathfinding algorithms that can balance the efficiency of movement path generation and the consumption of computing resources. Therefore, it is necessary to determine the optimal pathfinding algorithm for the game map sample by using a larger number of map point samples and a more accurate ratio of point pathfinding time to algorithm computing power consumption.
[0084] In a feasible embodiment, after step S4: performing cluster analysis on the game map data of the target game to obtain the correspondence between the game map data and the plurality of map sample classification clusters, the method further includes the following steps:
[0085] S6: If the correspondence indicates that there is no target map sample classification cluster corresponding to the game map data, obtain the trained pathfinding algorithm selection model;
[0086] The pathfinding algorithm selection model is trained through the following steps:
[0087] S601: Based on the ratio of the pathfinding time to the computing power consumption of the first algorithm for each pathfinding algorithm corresponding to the game map sample, obtain the matching score between the game map sample and each pathfinding algorithm.
[0088] The matching score is obtained using the following formula:
[0089] ;
[0090] in, For the matching score, For the game map sample corresponding to the first The ratio of the pathfinding time to the computational power used by the first algorithm in a pathfinding algorithm. The average ratio of the pathfinding time to the computing power consumption of the first algorithm for all pathfinding algorithms corresponding to the game map sample. The standard deviation of the ratio of the pathfinding time to the computing power of the first algorithm for all pathfinding algorithms corresponding to the game map sample.
[0091] S602: Input the game map sample and multiple pathfinding algorithms to be selected into the deep learning model to obtain the sample pathfinding algorithm selected by the deep learning model from multiple pathfinding algorithms;
[0092] S603: Based on the matching score corresponding to the sample pathfinding algorithm and the maximum matching score corresponding to the game map sample, construct the loss function:
[0093] ;
[0094] in, For loss function, For the number of training sessions, For the first The pathfinding algorithm selected during the second training session. This represents the maximum matching score corresponding to the game map sample.
[0095] S604: Based on the loss function, the deep learning model is updated using the gradient descent algorithm to obtain the pathfinding algorithm selection model.
[0096] Gradient descent is a commonly used first-order optimization iterative algorithm in the field of machine learning. Its core purpose is to find local minima of a function. It iteratively searches along the gradient in the opposite direction of the current point with a certain step size (learning rate) to continuously approach the model parameters that minimize the loss function.
[0097] S7: Input the game map data into the pathfinding algorithm selection model to obtain the target pathfinding algorithm selected by the pathfinding algorithm selection model.
[0098] In this embodiment, when the correspondence indicates that there is no target map sample classification cluster corresponding to the game map data, it means that the optimal pathfinding algorithm for the target game cannot be directly obtained through cluster analysis. Therefore, it is necessary to select a target pathfinding algorithm for the target game that balances the efficiency of movement path generation and the consumption of computing resources through a trained pathfinding algorithm selection model.
[0099] The second embodiment of this application provides a computer device 5, including a storage 51, a processor 50, and a computer program stored in the storage and executable by the processor. When the processor 50 executes the computer program, it implements the steps of the game map pathfinding algorithm selection method as described above.
[0100] It should be noted that the computer device 5 provided in the second embodiment of this application and the game map pathfinding algorithm selection method in the first embodiment of this application belong to the same concept. The implementation process is detailed in the method embodiment and will not be repeated here. Figure 5 This is a schematic diagram of a computer device provided in one embodiment of this application. Figure 5 As shown, the computer device 5 in this embodiment includes: a processor 50, a memory 51, and a computer program stored in the memory 51 and executable on the processor 50, such as a game map pathfinding algorithm selection program. When the processor 50 executes the computer program, it implements the steps in the various game map pathfinding algorithm selection method embodiments described above, for example... Figure 1 Steps 1 through 5 are shown. Or...
[0101] For example, the computer program can be divided into one or more modules / units, which are stored in the memory 51 and executed by the processor 50 to complete this application. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in the computer device 5. For example, the computer program can be divided into a synchronization module, a summarization module, an acquisition module, and a return module (a module in a virtual device), with the specific functions of each module as follows:
[0102] The computer device 5 can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will understand that... Figure 5 This is merely an example of computer device 5 and does not constitute a limitation on computer device 5. It may include more or fewer components than shown, or combine certain components, or different components. For example, the computer device may also include input / output devices, network access devices, buses, etc.
[0103] The processor 50 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0104] The memory 51 can be an internal storage unit of the computer device 5, such as a hard disk or memory of the computer device 5. The memory 51 can also be an external storage device of the computer device 5, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device 5. Furthermore, the memory 51 can include both internal and external storage units of the computer device 5. The memory 51 is used to store the computer program and other programs and data required by the computer device. The memory 51 can also be used to temporarily store data that has been output or will be output.
[0105] The embodiments described above are merely illustrative, and those skilled in the art should understand that the embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0106] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function selected in one or more boxes.
[0107] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the selected function in one or more boxes.
[0108] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0109] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0110] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0111] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for selecting a pathfinding algorithm for a game map, characterized in that, include: Randomly mark the start and end points of the game map samples to obtain several first map point samples; Based on the pathfinding time and computing power consumption of the first point in each first map point sample, various pathfinding algorithms are used to generate the movement path, and the optimal pathfinding algorithm for the game map sample is obtained. Cluster analysis was performed on several different game map samples to obtain several map sample classification clusters; Cluster analysis is performed on the game map data of the target game to obtain the correspondence between the game map data and the several map sample classification clusters; If the correspondence indicates the existence of a target map sample classification cluster corresponding to the game map data, the optimal pathfinding algorithm for the target map sample classification cluster is determined as the target pathfinding algorithm for the target game.
2. The game map pathfinding algorithm selection method according to claim 1, characterized in that, The steps for obtaining the optimal pathfinding algorithm for the game map samples, based on the pathfinding time and computational power consumption of the first point in each first map point sample using various pathfinding algorithms, include: The time and computing power required for the first point of the movement path are calculated by obtaining samples of each first map point and using various pathfinding algorithms to generate the first point of the movement path. Based on the pathfinding time and computing power consumption of all first points in the corresponding game map sample, obtain the pathfinding time and computing power consumption of the first algorithm for various pathfinding algorithms corresponding to the game map sample. The optimal pathfinding algorithm for the game map sample is determined based on the ratio of the pathfinding time to the computing power consumption of the first algorithm.
3. The game map pathfinding algorithm selection method according to claim 2, characterized in that, The step of determining the optimal pathfinding algorithm for the game map sample based on the ratio of the pathfinding time to the computing power consumption of the first algorithm includes: The pathfinding algorithm with the smallest ratio is determined as the optimal pathfinding algorithm for the game map sample.
4. The game map pathfinding algorithm selection method according to claim 3, characterized in that, After determining the pathfinding algorithm with the smallest ratio as the optimal pathfinding algorithm for the game map sample, the following steps are also included: The absolute value of the difference between the optimal pathfinding algorithm and other pathfinding algorithms is obtained as the ratio of the pathfinding time of the first algorithm to the computing power of the first algorithm, thus obtaining the first algorithm difference. If there is a first algorithm gap smaller than a preset threshold, the corresponding pathfinding algorithm will be used as a candidate pathfinding algorithm. The game map sample is then randomly marked with its start and end points to obtain several second map point samples; wherein the number of second map point samples is at least twice that of the first map point samples. Based on the ratio of the pathfinding time to the computational power consumption of the second algorithm for each second map point sample using the optimal pathfinding algorithm and the candidate pathfinding algorithm, the optimal pathfinding algorithm for the game map sample is re-determined.
5. The game map pathfinding algorithm selection method according to claim 1, characterized in that, After performing cluster analysis on several different game map samples to obtain several map sample classification clusters, the steps include: The reference distance of each map sample classification cluster is obtained based on the maximum sample distance difference of each map sample classification cluster and the preset reference coefficient. From each of the map sample classification clusters, obtain outlier game map samples whose optimal pathfinding algorithm differs from that of the cluster center sample; wherein, the cluster center sample is the game map sample that serves as the cluster center of the map sample classification cluster. If there are out-of-category game map samples whose sample distance difference with the cluster center sample is less than or equal to the reference distance, a secondary clustering analysis is performed on the game map samples in the map sample classification cluster to obtain several new map sample classification clusters with a smaller range.
6. The game map pathfinding algorithm selection method according to claim 5, characterized in that, After the step of obtaining outlier game map samples from each of the map sample classification clusters whose optimal pathfinding algorithm differs from that of the cluster center sample, the method further includes the following steps: If there are only out-of-type game map samples whose sample distance difference with the cluster center sample is greater than the reference distance, the out-of-type game map samples are removed from the map sample classification cluster, so that all game map samples in the same map sample classification cluster correspond to the same optimal pathfinding algorithm.
7. The game map pathfinding algorithm selection method according to claim 1, characterized in that, After performing cluster analysis on the game map data of the target game to obtain the correspondence between the game map data and the several map sample classification clusters, the method further includes the following steps: If the correspondence indicates that there is no target map sample classification cluster corresponding to the game map data, obtain the trained pathfinding algorithm selection model; The game map data is input into the pathfinding algorithm selection model to obtain the target pathfinding algorithm selected by the pathfinding algorithm selection model.
8. The game map pathfinding algorithm selection method according to claim 7, characterized in that, The pathfinding algorithm selection model is trained through the following steps: Based on the ratio of the pathfinding time to the computing power of the first algorithm for each pathfinding algorithm corresponding to the game map sample, the matching score between the game map sample and each pathfinding algorithm is obtained. The game map sample and multiple pathfinding algorithms to be selected are input into the deep learning model to obtain the sample pathfinding algorithm selected by the deep learning model from multiple pathfinding algorithms; Based on the matching score corresponding to the sample pathfinding algorithm and the maximum matching score corresponding to the game map sample, a loss function is constructed; Based on the loss function, the deep learning model is updated using the gradient descent algorithm to obtain the pathfinding algorithm selection model.
9. The game map pathfinding algorithm selection method according to claim 8, characterized in that, The step of obtaining the matching score between the game map sample and various pathfinding algorithms based on the ratio of the pathfinding time to the computing power consumption of the first algorithm for each pathfinding algorithm corresponding to the game map sample includes: The matching score is obtained using the following formula: ; in, For the matching score, For the game map sample corresponding to the first The ratio of the pathfinding time to the computational power used by the first algorithm in a pathfinding algorithm. The average ratio of the pathfinding time to the computing power consumption of the first algorithm for all pathfinding algorithms corresponding to the game map sample. The standard deviation of the ratio of the pathfinding time to the computing power of the first algorithm for all pathfinding algorithms corresponding to the game map sample.
10. A computer device, characterized in that: The system includes a storage device, a processor, and a computer program stored in the storage device and executable by the processor, wherein the processor executes the computer program to implement the steps of the game map pathfinding algorithm selection method as described in any one of claims 1 to 9.