A checkpoint numerical distribution generation method and device based on a split tree structure

CN122998740APending Publication Date: 2026-10-30GUANGZHOU SILVER ORANGE TECHNOLOGY CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202611461688.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-20
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

一、生成结果的可通关性无法在生成阶段得到保证

Benefits of technology

一、一次求解即得满足全部约束的分布,消除了求解失败。由于元素张数守恒与数值总和守恒由分裂次数唯一确定,不存在需要迭代满足的约束。在取自实际关卡表的去重后 118 组关卡参数(含单链与双链各链)上,求解成功率为 100.0%,分布均匀性的变异系数 CV 均值为 0.4319。(作为参照,另一类依赖随机扰动的实现方式在同一测试集上的成功率为 91.7%。)需说明的是,该收益来自求解范式的替换而非计算量的节省:本发明采用动态规划,单次求解耗时均值约 12 ms,高于上述另一类实现方式的约 0.17 ms;由于关卡生成仅在关卡加载时执行一次而非逐帧执行,该量级开销可接受。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122998740A_ABST
    Figure CN122998740A_ABST
Patent Text Reader

Abstract

The application discloses a checkpoint numerical distribution generation method and device based on split tree construction. The method obtains the total number of game elements, the total sum of values, the value range, the ratio base and the aggregation base of a checkpoint; determines each gear value and gear number according to the value range; constructs and determines the split number by reverse splitting according to the aggregation base with the final aggregation result as the root node; introduces a carry variable representing the number of elements from the low gear to the current gear, and represents the number of each gear as the difference between adjacent carry variables according to the carry variable; determines the root gear serial number and fixes the last gear carry variable according to the total sum of values, and deducts the fixed consumption from the split number to obtain the budget; takes the square sum of the difference between the number of each gear and the average number of gears as a cost function, and uses dynamic programming to obtain the optimal solution under the constraints of budget and the number of gears not less than one; and expands the number of each gear into a value sequence after restoring the number of each gear and outputs the checkpoint data. The application can obtain a distribution satisfying the number conservation, the total sum conservation, the full gear and the complete elimination at one time, and the uniformity is optimal, and iteration trial and error and post-checking are not needed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer data processing technology, specifically to a method and apparatus for generating level numerical distributions in a number merging and elimination game. Background Technology

[0002] In number merging and elimination games, a level consists of several layers of grids, with each grid containing a game element carrying a numerical value. Players place game elements into a storage area, and when game elements with the same value accumulate to the required number for aggregation, they are merged into a single game element with a higher numerical value through an aggregation operation. The numerical distribution of the level (i.e., how many game elements are in each tier) and the initial card layout are generated by the level generation process. The existing level generation paths can be summarized into four categories; in addition, there is another approach for match-3 games that modifies the layout during the running phase, which, although not part of the generation process, is also listed below. One approach is generation based on learning models. For example, the scheme described in application publication number CN121911107A (application date 2024.10.23, publication date 2026.04.24) acquires historical game level information, identifies and trains its features to establish a generative model, and then automatically generates levels based on this model. Another approach, described in application publication number CN120617962A (application date 2025.05.07, publication date 2025.09.12), generates dynamic user profile vectors through a multi-task learning network, and then uses a dual-channel adversarial network to produce a set of candidate levels, which are then filtered using playability metrics. The output of such schemes is dominated by the distribution of historical data and does not adhere to verifiable arithmetic relationships such as "level conservation" or "total conservation." For example, the scheme described in application publication number CN119425055A (application date 2024.11.22, publication date 2025.02.14) randomly generates game levels and then uses a reinforcement learning network model to solve the game and obtain the level pass rate. When the pass rate is not lower than a set threshold, the level is output. Its solvability is obtained by solving the problem, rather than by the generation process itself. The second type is generation based on rule extraction and path exploration. For example, the Sudoku level generation scheme described in application publication number CN121243778A (application date 2025.09.25, publication date 2026.01.02) extracts levels from the puzzle elements and solution elements of the initial level; and the scheme described in application publication number CN120860601A (application date 2025.08.26, publication date 2025.10.31) splits level words and explores paths based on the splitting results. These schemes generate levels based on extraction or path connectivity, with difficulty assessment occurring after generation and not constraining the generation process in reverse. Thirdly, it directly reads pre-configured level data. For example, the scheme described in application publication number CN116116003A (application date 2023.02.24, publication date 2023.05.16) obtains level configuration data from the server when the network is normal and obtains default level configuration data when the network is disconnected. The level content itself is still pre-configured static data. Fourthly, the solvability of levels is guaranteed by reverse engineering. A technical article published in July 2018, "Reading Notes on Game Artificial Intelligence (XI) Game Content Generation," states: "One of the simplest methods for content generation in decryption games is reverse engineering. Starting from the state where the puzzle is solved, step by step according to the game logic, find the possible previous steps, and then reverse engineer back." It points out that reverse engineering is the most commonly used method for level generation in slider games, "ensuring 100% that the generated level is solvable." The open-source project runar-rkmedia / gotally's target grid value generation module reverse-engineers from the desired target grid value: repeatedly dividing the target value by the merging base until it reaches the maximum grid value of the level, thus determining the minimum number of blocks required to reach the target. Then, a factor substitution step replaces some necessary blocks with their factor combinations to increase the number of synthesis steps. Finally, the solver verifies whether the board is solvable within a given time limit. If the verification fails, it is regenerated with a maximum number of retries. For match-3 games, there is another approach that guarantees solvability during runtime. For example, the scheme described in application publication number CN121588458A (application date 2026.01.20, publication date 2026.03.03) involves: scanning the game's video memory area to extract the endgame topology matrix; constructing a virtual board in shadow memory and performing a full-path elimination simulation to detect dead ends; then constructing a set of constraint equations for locked abnormal coordinate areas with the goal of "the existence of a solvable path"; iteratively solving for element type combinations using backtracking search and forward detection; and finally converting the corrected fill sequence into a graphics instruction stream and writing it into the frame buffer. This approach addresses the dynamic correction of the existing board during runtime. Its solution object is the combination of grid element types, without involving the quantity distribution of elements at each level or the conservation relationship between the number of elements and the total numerical value. In addition, application publication numbers CN121944496A (application date 2025.11.28, publication date 2026.05.01), CN121988024A (application date 2026.03.03, publication date 2026.05.08) and CN114602185A (application date 2022.01.20, publication date 2022.06.10) respectively involve the interactive closed loop of elimination and merging, the server-side implementation of motion-sensing throwing grid filling elimination and number merging games, and the game board values ​​are generated by pre-configuration or random placement of pieces. The aforementioned existing technology has the following shortcomings: First, the passability of the generated result cannot be guaranteed during the generation stage. The output of the learning model method and the extraction method is an approximation and transformation of historical data or existing elements; although the solvability of the reverse reasoning method is assumed by the construction method, its product is the minimum set of elements required to achieve the goal. Whether it can still be completely eliminated after adding extra elements still depends on the solver's post-processing verification and retry. Once there are residual elements that cannot be matched, the player will inevitably fail, and this defect can only be discovered by manual or program spot checks after generation. Second, relying on iterative trial and error and post-process verification leads to uncontrollable solution overhead and failure rate. Generation methods relying on random perturbations approximate the target by repeatedly verifying the results with an upper limit on the number of iterations; reverse-engineering methods work by setting an upper limit on the number of verification retries; methods that verify solvability through problem-solving (such as CN119425055A cited above) first randomly generate levels, then calculate the pass rate by solving the problems using a model, and only output the level if the pass rate is not lower than a set threshold; results that do not reach the threshold are not output. The common point of these three methods is that solvability is verified after generation, not guaranteed by the generation process itself; when the iteration limit, retry limit, or threshold is reached, only a generation failure message can be output or the result can be discarded, making it impossible to close the loop in the level production process. Third, structural hard constraints need to be patched afterward. If requirements such as "each value must appear at least once" are not treated as hard constraints during the solution process, there will be cases where the number of sheets in some positions is zero. Only zero-padding and transfer correction logic can be added, and the correction itself may break other constraints that have already been satisfied. Fourth, the uniformity of the distribution lacks a globally optimal objective. Shaping the distribution indirectly through weights can only determine a rough framework and cannot guarantee that the most uniform solution will be found among all feasible solutions. Fifth, it is difficult to satisfy multiple aggregation cardinalities simultaneously. When different numerical chains need to be processed according to different aggregation cardinalities within the same level, the number of sheets and the total constraint of each chain are independent. Existing solutions lack a mechanism to solve multiple chains separately and then arrange them uniformly. VI. Dynamic corrections during the runtime phase can only provide post-event remediation and cannot address defects at the distribution level. The practice of detecting deadlocks and correcting the layout during the runtime phase in match-3 games (such as CN121588458A cited above) only addresses the type combinations of grid elements. This allows for localized corrections to individual coordinate areas after the layout has been generated. If the distribution of elements across different levels is inherently unreasonable during the generation phase—for example, some levels are not fully covered or the number of elements is unbalanced—then no matter how many times local corrections are repeated during the runtime phase, only the element types can be changed; the total number of usable elements and the level composition remain unchanged. The problem is repeatedly masked and cannot be eliminated. Therefore, the root cause of this defect lies in the quantity allocation stage during generation, not in the layout adjustment stage during runtime. Summary of the Invention

[0003] Technical problems to be solved The technical problem to be solved by this invention is: given the total number of game elements and the sum of their values, how to obtain the distribution of the number of elements in each tier at once, so that the distribution simultaneously satisfies four structural requirements: conservation of the number of elements, conservation of the sum of values, each value appearing at least once, and the generated result must be completely eliminated, and under these constraints, the one with the optimal distribution uniformity is obtained, so as not to rely on iterative trial and error and post-event verification. Technical solution To achieve the above objectives, the present invention adopts the following technical solution. A method for generating level numerical distributions includes the following steps: (1) Obtain the level parameters of the level to be generated, including the total number of game elements N to be generated in the level, the total number of values ​​S, the lower bound Vmin and the upper bound Vmax of the value range, the base of the ratio between levels step, and the aggregation base gs; where the aggregation base gs is the number of game elements required to merge gs game elements with the same value into a higher level game element after one aggregation operation, and the total number of values ​​S is the value of the game element when all game elements in the level are aggregated to the final value. (2) Using Vmin as the first term and step as the common ratio, the values ​​of each gear and the number of gears k allowed to appear in the level are gradually increased to no more than Vmax. The number of gears k is not less than two. The ratio base step and the aggregation base gs take the same value. (3) Using the final aggregation result of the level to be generated as the root node, construct the reverse split according to gs: split a game element with value v into gs game elements with value v / gs, and split level by level until the leaf value falls into the value range; determine the number of splits t required to split from the root node to all leaves according to t=(N-1) / (gs-1), and require t to be an integer, that is, N-1 can be divided by gs-1. Since the number of nodes increases by gs-1 with each split, the number of splits t is equal to the number of internal nodes of the split tree. (4) Introduce the carry variable s_j, which represents the number of game element cards carried from the (j-1)th level to the jth level, where j takes values ​​from 1 to k; and express the number of cards in each level according to the carry variable as x_0 = gs × s_1, x_j = gs × s_(j+1) - s_j (1 ≤ j ≤ k-2), x_(k-1) = gs × s_k - s_(k-1). (5) Fix the carry-over variable s_k = gs^(Tk) of the last gear by the root gear number T that satisfies Vmin × gs^T = S, and require T to be no less than k; deduct the fixed consumption from the root gear to the highest gear from t to obtain the budget that can be freely allocated, make the sum of each free carry-over variable equal to the budget, and make the number of sheets in each gear no less than one. (6) Using the sum of squares of the differences between the number of sheets in each grade and the average number of sheets N / k as the cost function, under the constraints of the equality of the budget and the feasible region constraint that the number of sheets in each grade is not less than one, dynamic programming is used to solve the problem step by step from the highest grade to the lowest grade. The state of the dynamic programming is determined by the value of the carry variable of the current grade and the sum of the accumulated carry variables. Each time the transfer is made from the current grade to the next lower grade, the number of sheets in the next lower grade is determined and its squared deviation is included in the cost. The set of carry variables with the minimum total cost is taken as the optimal solution. Specifically, the state is denoted as a tuple (v, u), where v is the value of the carry variable for the current level, and u is the cumulative sum of the carry variables from the highest level to the current level. Both v and u are bounded by the budget. When advancing from the highest level to the next lower level, the values ​​of the carry variables for the next lower level are enumerated. The number of sheets determined by this transfer is determined according to the correspondence in step (4), and the square of the difference between this number and the average number of sheets is added to the cost. After advancing to the lowest level, the square deviation of the number of sheets in the lowest level is added. Among all the states that reach the lowest level and whose cumulative sum equals the budget, the state with the smallest total cost is selected, and the optimal values ​​of the carry variables for each level are obtained by backtracking along this state. (7) Restore the number of each level according to the corresponding relationship, expand the number of each level into a numerical sequence of length N, and output it together with the level parameters as the level data of that level. The reason why the ratio base step and the aggregation base gs must be the same is as follows: the gear definition gives the ratio of two adjacent gear values ​​as step; while the split tree definition requires a node with value v to split into gs child nodes with value v / gs, and the child node values ​​must still be valid gear values, so the ratio of adjacent gears must be gs. When both are true, step ≡ gs. If step ≠ gs, then v / gs may fall within the range of the key value but is not a valid gear value, the split tree cannot be closed on the gear set, and steps (3) to (6) cannot be implemented; therefore, this condition is a prerequisite for the implementation of the scheme. In one embodiment, step and gs are both 2, or both are 3. Furthermore, before step (3), a preliminary solvability threshold check is included: checking whether N-1 is divisible by gs-1, whether the total sum S falls on a power chain starting from Vmin and divided by gs, and whether the root position number T is not lower than the position number k; and also checking whether the budget β satisfies β ≥ k-1 and does not exceed the sum of the upper bounds of the carry variables of each position, where the upper bound of the carry variable of the j-th position is given by s_j ≤ gs × s_(j+1) - 1. If any one of these conditions is not met, the process proceeds to the fallback construction path. Furthermore, the fallback construction path includes: when the gate parameters satisfy the solvability premise, a consistent construction is performed according to the same split tree model—fixing the carry variable of the last slot with s_k = gs^(Tk), each free carry variable is first set to 1, then j is sequentially set to k-1, k-2, …, 1, and the fill amount is taken for each slot according to add = min [ R, gs × s_(j+1) - 1 - s_j ] and s_j arrow s_j + add, R arrow R - add, where R is the remaining budget; then the number of sheets in each slot is restored according to the above correspondence. The upper bound cannot be omitted: by inversely solving x_j = gs × s_(j+1) - s_j and x_j ≥ 1, we get s_j ≤ gs × s_(j+1) - 1; if this upper bound is not added and the remaining budget is filled into the current slot in its entirety, x_j will decrease accordingly and may be less than one. Since the upper bound of the carry variable in the j-th gear depends only on s_(j+1) of the next higher gear, and s_(j+1) is determined when filling the current gear, the upper bound of each gear can be calculated when moving from the higher to the lower gear. Furthermore, since filling s_j only raises the upper bound of the next gear without tightening it, this rule will always use up the budget exactly when the parameters are solvable. When the remaining budget is negative after each free carry variable is set to 1, or when the remaining budget R is still greater than zero after filling to the lowest gear, the level parameters are determined to be unsolvable, and a complete placeholder distribution is output and marked as requiring manual review. Furthermore, before step (7), the process includes: starting from the lowest level, progressively carrying over each level, verifying whether the cumulative number of sheets in each level is divisible by the aggregation base gs, and verifying whether the number of sheets in each level is not less than one sheet; if any condition is not met, the distribution is not output. It should be noted that since the number of sheets in each level restored in step (4) comes from the construction relationship of the split tree, and the total value has been constrained on the power chain of the aggregation base, the divisibility of the number of sheets in each level during the progressive carrying over process is automatically established by the conservation of the total value. Therefore, this verification is a formal confirmation during normal operation, and its function is to avoid outputting invalid distributions to the gate data when the verification fails due to numerical accuracy or implementation abnormalities. Furthermore, when the level to be generated contains multiple numerical chains, the total number of game elements and the sum of values ​​of each numerical chain are obtained, and the above steps (2) to (6) are executed according to the aggregation base and power of the chain, and then merged, expanded and uniformly arranged; the sum of the total number of game elements of each chain is equal to the total number of grids in the level, so the sum of the lengths of the sequences obtained by expanding each chain is exactly equal to the number of grids, and the merged sequence corresponds one-to-one with the grids, and there is no situation where there are no grids to place after a certain chain is added; each chain is only calculated according to the aggregation base of its own chain and does not participate in the aggregation of other chains. Furthermore, in step (7), after expanding the number of cards in each level into a numerical sequence of length N, the steps also include: for a level containing multiple numerical chains, merging the sequences obtained from expanding each chain into a single sequence and then shuffling them; laying out the shuffled numerical sequence in order according to each layer of grid to form the initial card face of the level; and outputting the level data as a data structure for consumption in the level loading process. A device for generating numerical distribution of a level includes a level parameter acquisition module, a gear determination and reverse construction module, a budget determination and solution module, and a restoration output module; wherein, the level parameter acquisition module is used to perform the above step (1), the gear determination and reverse construction module is used to perform the above steps (2) to (4), the budget determination and solution module is used to perform the above steps (5) and (6), and the restoration output module is used to perform the above step (7). Regarding terminology: "Level data" as used in this invention refers to a data structure that includes the numerical sequence of game elements at each level, the arrangement of grids at each level, and level parameters, which is directly readable by the level loading process; "Game element" as used in this invention refers to an operable object in a level that carries a numerical value and occupies one grid, which is a block in this embodiment; "Aggregation operation" refers to the operation of merging several game elements with the same value into a higher-level game element, which is called merging in this embodiment; "Aggregation base" is the merging base in this embodiment; "Total number of elements" is the total number of blocks in this embodiment. Beneficial effects Compared with the prior art, the present invention has the following beneficial effects: First, a distribution satisfying all constraints is obtained in a single solution, eliminating solution failures. Since the conservation of element number and total numerical sum is uniquely determined by the number of splits, there are no constraints that need to be satisfied iteratively. On 118 sets of level parameters (including both single-chain and double-chain chains) after deduplication from the actual level table, the success rate was 100.0%, and the average coefficient of variation (CV) for distribution uniformity was 0.4319. (For reference, another implementation relying on random perturbations had a success rate of 91.7% on the same test set.) It should be noted that this benefit comes from the replacement of the solution paradigm rather than a reduction in computational cost: this invention uses dynamic programming, with an average solution time of approximately 12 ms, higher than the approximately 0.17 ms of the other implementation mentioned above; since level generation is only performed once during level loading rather than frame-by-frame, this level of overhead is acceptable. Second, the structural requirements are applied directly from the feasible region without the need for subsequent patching. The condition that "each value must appear at least once" is applied directly as a boundary condition that the number of sheets in each range is not less than one, and there will be no situation where corrections violate other constraints. Third, the uniformity of distribution is optimal among all feasible solutions. The cost function is the sum of the squares of the differences between the number of sheets in each grade and the average number of sheets, and dynamic programming is used to solve the problem. The resulting allocation is optimal among all feasible solutions under this cost function. Fourth, the output of a successful solution can be completely eliminated. Since the total numerical sum is constrained to the integer power chain of the aggregation base, the divisibility of the number of sheets in each level during the carry-over process is automatically established by the conservation of the total numerical sum, so there is no need to rely on a possible failure in the post-event judgment; the carry-over confirmation of the output level ensures that each level carries over at most once, the time cost is proportional to the number of levels, and it does not bring unacceptable overhead during the level loading stage of mobile devices. V. Closed-loop production process for gates, leaving no exit point for failure. When no result is obtained from the solution, a fallback path is constructed to produce a distribution that still meets the four structural requirements; when the parameters themselves are unsolvable, a placeholder distribution is output and marked for manual review, without outputting a failure message or interrupting gate production; at the same time, it supports solving multiple numerical chains within the same gate with different aggregation bases and aligning them with the sum of the number of sheets and the total number of grids. Attached Figure Description Figure 1 is a system block diagram of an embodiment of the present invention; Figure 2 is a flowchart of an embodiment of the present invention. Detailed Implementation The present invention will be further described below with reference to the accompanying drawings and embodiments. The following embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. As shown in Figure 1, the technical solution of the present invention is organized into four stages: "parameter and gear preparation", "constructive solution", "structural verification and fallback", and "card generation and output". Correspondingly, the level numerical distribution generation device of this embodiment includes a level parameter acquisition module, a gear determination and reverse construction module, a budget determination and solution module, and a restoration output module; wherein, the level parameter acquisition module performs the following step (1), the gear determination and reverse construction module performs the following steps (2) to (4), the budget determination and solution module performs the following steps (5) and (6), and the restoration output module performs the following step (7). As shown in Figure 2, the processing flow of this embodiment includes steps S1 to S11: S1 Receiving level parameters, S2 Constructing the power-order level set, S3 Verifying the division threshold of the number of splits, S4 Verifying the power chain of the target sum, S5 Establishing budget constraints, S6 Dynamic programming minimum variance allocation, S7 Restoring the number of cards in each level, S8 Formal verification, S9 Unfolding and shuffling the card layout, S10 Filler construction and placeholder degradation, S11 Level data output. If verification in S3 or S4 fails, proceed to S10; if no result is obtained in S6, proceed to S10; if formal verification in S8 fails, also proceed to S10; after S10, proceed to S9 and S11. All subsequent embodiments follow this flow. Example 1 This example is a nine-layer funnel level with a single chain and a aggregation base of 2 (85 grid positions). The level parameters are: total number of game elements N = 85 (the grid positions of each layer from top to bottom are 1×1, 2×2, 3×3, 4×4, 5×5, 4×4, 3×3, 2×2, 1×1), total value S = 1024, lower bound of the value range Vmin = 2, upper bound of the value range Vmax = 64, ratio base step = 2, aggregation base gs = 2. From step (2), we get the number of slots k = 6, and the corresponding card values ​​are 2, 4, 8, 16, 32, and 64 respectively; from step (3), we get the number of splits t = (85-1) / (2-1) = 84, which is an integer; from step (5), we get the root slot number T = 9, and 2 × 2^9 = 1024 = S holds true, so T = 9 ≥ k = 6; the carry-over variable s_k = 2^(9-6) = 8, and the fixed consumption from the root slot to the highest slot is 2^3 + 2^2 + 2^1 + 2^0 = 15, so the budget is 84 - 15 = 69. By using dynamic programming to solve the problem based on the average number of sheets 85 / 6 ≈ 14.17 in step (6), and then restoring the number of sheets for each grade by step (4), we get 18, 19, 18, 16, 12, and 2 respectively. Verification: The sum of the number of sheets in each grade is 18+19+18+16+12+2 = 85 = N; the weighted sum is 18×2 + 19×4 + 18×8 + 16×16 + 12×32 + 2×64 = 1024 = S; the number of sheets in each grade is not less than one; each grade from the lowest grade is divisible by 2, and finally converges to a single sheet with a value of 1024. Example 2 This embodiment is a thirteen-layer funnel gate with a base of 3 (231 grid positions). The gate parameters are: N = 231 (each layer increases from 1×1 to 7×7 and then decreases back to 1×1), S = 6561, Vmin = 3, Vmax = 243, step = 3, gs = 3. The number of slots is k = 5, corresponding to card values ​​3, 9, 27, 81, 243; the number of splits t = (231-1) / (3-1) = 115, which is an integer—because when gs = 3, N-1 must be divisible by gs-1 = 2, that is, N must be an odd number, which 231 satisfies; the root slot number T = 7, and 3 × 3^7 = 6561 = S holds true; the carry variable of the last slot is s_k = 3^(7-5) = 9, the fixed consumption is 3^2+3^1+3^0 = 13, and the budget is 115 - 13 = 102. The number of sheets in each category was obtained by dynamic programming and reconstruction, which were 63, 63, 59, 43, and 3 respectively. Verification: The sum of the number of sheets is 63 + 63 + 59 + 43 + 3 = 231 = N; the weighted sum is 63 × 3 + 63 × 9 + 59 × 27 + 43 × 81 + 3 × 243 = 6561 = S; the number of sheets in each grade is not less than one; each grade carry-over is divisible by 3, and finally converges to a single sheet with the value 6561. If the total number of cards in this level is changed to an even number (e.g., 232), then 232-1 = 231 is not divisible by 2, the pre-threshold check fails, and the process switches to the fallback path construction. At this time, the combination of parameters does not have any distribution that can be completely eliminated mathematically, so the fallback path does not produce a clearable distribution, but outputs a complete placeholder distribution and marks it as requiring manual review. Example 3 This example demonstrates a level where two numerical chains coexist within the same level, are solved separately, and then uniformly arranged (total number of cells in each layer is 91). Chain 1 parameters: N_1 = 48, S_1 = 1024, Vmin = 2, Vmax = 32, step = 2, gs = 2; Chain 2 parameters: N_2 = 43, S_2 = 729, Vmin = 3, Vmax = 27, step = 3, gs = 3. The sum of the number of sheets in the two chains, 48 ​​+ 43 = 91, matches the total number of cells in this level. Chain 1: Number of slots k_1 = 5 (card values ​​2, 4, 8, 16, 32), number of splits t_1 = 47, root slot number T_1 = 9, carry variable of the last slot 2^(9-5) = 16, fixed cost 2^4+2^3+2^2+2^1+2^0 = 31, budget 47 -31 = 16; Solve and restore to get the number of cards in each slot of Chain 1 as 2, 5, 5, 12, 24. Chain 2: Number of slots k_2 = 3 (card values ​​3, 9, 27), number of splits t_2 = 21, root slot number T_2 = 5, carry variable of the last slot 3^(5-3) = 9, fixed cost 3^2+3^1+3^0 = 13, budget 21 - 13 = 8; Solve and restore to get the number of cards in each slot of Chain 2 as 9, 12, 22. The numerical sequences obtained from expanding the two chains are then merged into a single sequence, shuffled, and then sequentially placed onto each layer of grid cells to form the initial card layout for the level and output the level data. Since the sum of the number of cards in the two chains is exactly equal to the total number of grid cells, the merged sequence corresponds one-to-one with the grid cells, and there are no unplaced or empty grid cells. The two chains are settled according to their respective aggregation bases of 2 and 3, and do not participate in each other's aggregation. Verification: The sum of the number of cards in chain 1 is 48, and the weighted total is 1024; the sum of the number of cards in chain 2 is 43, and the weighted total is 729; the number of cards in each row of both chains is not less than one, and the carry-over verification for each row passes. Optional implementation methods After finding the set of carry variables with the minimum cost, one can be randomly selected as the output from all solutions whose cost does not exceed the sum of the optimal cost and the preset increment. When the preset increment is 0, it means randomly selecting one from all equally optimal solutions. In this case, the uniformity of the output remains globally optimal, without any deviation from the cost function. Chain-1 exhaustive statistics for Examples 1 and 3 show that they have 2 and 3 equally optimal solutions, respectively. This optional implementation can be used to introduce diversity in the numerical distribution while maintaining scrambling capability and optimality. Regarding the implementation environment The above solution is executed once during the level loading phase of the mobile terminal. The time overhead of the step-by-step carry confirmation and fallback construction for generating the exit is proportional to the number of levels, thus not causing any perceptible lag. The state size of the dynamic programming is related to the budget: the state size is on the square of the budget, and the transition amount per level is on the cube of the budget. In one embodiment, an upper bound of 320 is set for the budget, that is, when the budget exceeds 320, the fallback construction path is entered, exchanging the overhead proportional to the number of levels for a certain concession in uniformity. The reason for choosing 320 is that it can constrain the state size to about 10^5 and the inner transition amount to about 3 × 10^7, thereby controlling the memory and time required for a single generation within an acceptable range. Carrier Form: The method of the present invention can be implemented by a computer program. The computer program can be stored in a computer-readable storage medium and executed by a processor. When the processor executes the computer program, it implements the steps of the method of the present invention. Accordingly, the present invention also provides an electronic device, including a processor and a memory, wherein the memory stores the computer program. The computer-readable storage medium includes, but is not limited to, read-only memory, random access memory, magnetic disk, optical disk, flash memory, etc. The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made within the scope of the present invention should be included in the scope of the present invention.

Claims

1. A method for generating numerical distributions for levels, characterized in that, Includes the following steps: (1) Obtain the level parameters of the level to be generated. The level parameters include: the total number of game elements to be generated in the level N, the total number of values ​​S, the lower bound of the value range Vmin and the upper bound Vmax, the ratio base between levels step, and the aggregation base gs; wherein, the aggregation base gs is the number of game elements required to merge gs game elements with the same value into a higher-level game element after one aggregation operation, and the total number of values ​​S is the value of the game element when all game elements in the level are aggregated to the final value. (2) Taking the lower limit of the numerical range Vmin as the first term and the ratio base step as the common ratio, the values ​​are gradually increased to no more than the upper limit of the numerical range Vmax. The values ​​of each gear and the number of gears k allowed to appear in the gate are determined. The number of gears k is not less than two. The ratio base step and the aggregation base gs take the same value. (3) Using the final aggregation result of the level to be generated as the root node, perform reverse splitting construction according to the aggregation base gs: split a game element with a value of v into gs game elements with a value of v / gs, and split level by level until the leaf value falls into the value range; and determine the number of splits t required from the root node to all leaves according to the following formula, and require t to be an integer: t = (N-1) / (gs-1) That is, the total number of game elements N minus one is divisible by the aggregation base gs minus one; (4) Introduce a carry variable s_j, which represents the number of game element cards carried over from the (j-1)th rank to the jth rank, where j takes values ​​from 1 to k; and express the number of cards in each rank according to the carry variable as follows: x_0 = gs × s_1, x_j = gs × s_(j+1) - s_j, x_(k-1) = gs × s_k - s_(k-1) Where x_j is the number of game elements in the j-th tier, and the value of j in x_j = gs × s_(j+1) - s_j is 1 ≤ j ≤ k-2; (5) The carry-in variable s_k = gs^(Tk) of the last gear is fixed by the root gear position number T, which satisfies the following formula, and the root gear position number T is not lower than the number of gears k: Vmin × gs^T = S Subtract the fixed consumption portion from the root gear to the highest gear from the number of splits t to obtain the budget that can be freely allocated, and make the sum of each free carry variable equal to the budget, and make the number of sheets in each gear not less than one; (6) Using the sum of squares of the differences between the number of sheets in each grade and the average number of sheets N / k as the cost function, under the constraints of the equality that the sum of the free carry variables equals the budget and the feasible region constraint that the number of sheets in each grade is not less than one, dynamic programming is used to solve the problem step by step from the highest grade to the lowest grade. The state of the dynamic programming is determined by the value of the carry variable in the current grade and the sum of the accumulated carry variables. Each time the project moves from the current grade to the next lower grade, the number of sheets in the next lower grade is determined and its squared deviation is included in the cost. The set of carry variables with the minimum total cost is taken as the optimal solution. (7) Restore the number of cards in each level according to the correspondence between the carry variable and the number of cards, expand the number of cards in each level into a numerical sequence of length N, and output it together with the level parameters as the level data of that level.

2. The generation method according to claim 1, characterized in that, The ratio base step and the polymerization base gs are both 2 or both 3.

3. The generation method according to claim 1, characterized in that, Before step (3), a preliminary solvability threshold check is included, and if the check fails, a fallback construction path is initiated; the preliminary solvability threshold check includes: Verify whether N-1 is divisible by gs-1, whether the sum of the values ​​S falls on the power chain starting from Vmin and with gs as the ratio, and whether the root gear number T is not lower than the gear number k. In addition, it is verified whether the budget β satisfies β ≥ k-1 and β does not exceed the sum of the upper bounds of the carry variables of each level; wherein the upper bound of the carry variable of the j-th level is given by s_j ≤ gs × s_(j+1) - 1, and when j = k-1, s_(j+1) is the fixed carry variable s_k of the last level.

4. The generation method according to claim 3, characterized in that, The fallback construction path includes: When the gate parameters satisfy the solvability premise, the same split tree model as in claim 1 is used for construction: the carry variable at the last level is fixed as s_k = gs^(Tk), each free carry variable is first set to 1, then j is sequentially set to k-1, k-2, …, 1, and the fill amount is obtained for each level according to the following formula. add = min [ R, gs × s_(j+1) - 1 - s_j ] And let s_j arrow s_j + add, R arrow R - add, where R is the remaining budget; then restore the number of sheets for each file according to the correspondence in step (4) of claim 1; When the remaining budget is negative after each free carry variable is set to 1, or when the remaining budget R is still greater than zero after filling to the lowest level, the level parameter is determined to be unsolvable, and a complete placeholder distribution is output and marked as requiring manual review.

5. The generation method according to claim 1, characterized in that, When the level to be generated contains multiple numerical chains, obtain the total number of game elements and the sum of values ​​for each numerical chain, and execute steps (2) to (6) according to the aggregation base and power of the chain, and then merge, expand and arrange in a unified manner; and the sum of the total number of game elements of each chain is equal to the total number of grids in the level.

6. The generation method according to claim 1 or 5, characterized in that, After expanding the number of cards in each level into a numerical sequence of length N in step (7), the method further includes: for a level containing multiple numerical chains, merging the sequences obtained from expanding each chain into a single sequence and then shuffling them; laying out the shuffled numerical sequence in order according to each layer of grid to form the initial card face of the level; and outputting the level data as a data structure for consumption in the level loading process.

7. The generation method according to claim 1, characterized in that, The game elements are blocks with numerical values ​​in a number merging and elimination game. The aggregation operation is the merging of several blocks with the same value into a block of the next higher level. The level is a level in a number merging and elimination game.

8. A device for generating numerical distributions of checkpoints, characterized in that, include: The level parameter acquisition module is used to acquire the level parameters of the level to be generated. The level parameters include the total number of game elements N, the total number of values ​​S, the lower bound of the value range Vmin and the upper bound of the value range Vmax, the ratio base between levels step, and the aggregation base gs, and the step and gs take the same value. The tier determination and reverse construction module is used to determine the tier values ​​and the number of tiers k by progressively increasing from Vmin to no more than Vmax, with step as the common ratio. It then uses the final aggregation result of the tier as the root node to perform reverse split construction according to gs, and determines the number of splits t according to t = (N-1) / (gs-1), requiring t to be an integer. At the same time, it introduces a carry variable s_j to represent the number of game element cards from the (j-1)th tier to the jth tier, and expresses the number of cards in each tier as x_0 = gs × s_1, x_j = gs × s_(j+1) - s_j, x_(k-1) = gs × s_k - s_(k-1). The budget determination and solution module is used to fix the carry variable s_k = gs^(Tk) of the last gear based on the root gear number T that satisfies Vmin × gs^T = S, and requires T to be no less than k. The budget is obtained by deducting fixed consumption from t, and the sum of all free carry variables is made equal to the budget and the number of sheets in each gear is no less than one. The module uses the sum of the squares of the differences between the number of sheets in each gear and the average number of sheets N / k as the cost function, and uses dynamic programming to advance from the highest gear to the lowest gear to find the set of carry variables with the minimum cost. The state of the dynamic programming is determined by the value of the carry variable of the current gear and the sum of the accumulated carry variables. The restoration output module is used to restore the number of sheets for each level according to the corresponding relationship, expand the number of sheets for each level into a numerical sequence of length N, and output the level data for that level along with the level parameters.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • PHP-based 2048 game data processing method, system and device and medium

    CN114602185A

  • Game level configuration method and device, electronic equipment and storage medium

    CN116116003A

  • Mahjong matching game level generation method based on reinforcement learning, medium and equipment

    CN119425055A

  • Game level generation recommendation method, system, equipment and medium

    CN120617962A

  • Virtual scene level generation method and device, electronic equipment, computer readable storage medium and computer program product

    CN120860601A