Connected terrain generation method and apparatus, electronic device, and storage medium

By improving the wave function collapse algorithm and combining adjacency and connectivity relationships to generate connected terrain, the problems of low terrain generation efficiency and insufficient diversity are solved, and efficient, diverse and connected terrain generation is achieved.

CN121810866BActive Publication Date: 2026-06-23TSINGHUA SHENZHEN INTERNATIONAL GRADUATE SCHOOL
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202610271090.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-03-06
Publication Date
2026-06-23
Estimated Expiration
2046-03-06

AI Technical Summary

Technical Problem

Existing terrain generation methods are inefficient and lack diversity. Traditional WFC algorithms may lead to terrain islands, which require complex repair or regeneration after generation, resulting in low efficiency and inability to guarantee connectivity.

Method used

An improved wave function collapse algorithm is introduced. By defining the adjacency and connectivity relationships between tiles, the grid cell with the smallest entropy value that is adjacent to the already connected region is selected as the collapse object. The algorithm also ensures that the target tile is connected to the already connected region, which is the determined state of the collapse object, and thus generates connected terrain.

Benefits of technology

It improves terrain generation efficiency, ensures connectivity, reduces post-repair costs, avoids misjudgment of isolated noise points, generates highly diverse connected terrain, and reduces computational complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121810866B_ABST
    Figure CN121810866B_ABST
Patent Text Reader

Abstract

The application provides a connected terrain generation method and device, electronic equipment and storage medium, and relates to the technical field of computer graphics. The method completely distinguifies the adjacency relationship and the connected relationship between each tile by defining the adjacency relationship and the connected relationship between each tile, introduces the connected relationship, and provides a basis for subsequent generation of connected terrain. The method introduces an improved wave function collapse algorithm. When selecting a collapse object in the improved wave function collapse algorithm, a limitation of being adjacent to a connected region is added, and when determining the state of selecting a collapse object, a limitation of being connectable with at least one boundary tile in the connected region is added. The adjacency relationship and the connected relationship can be used as constraint conditions in the generation process, which fundamentally prevents the generation of unconnected regions. With the progress of the generation steps, the connected region is continuously expanded to cover the entire terrain grid, and then the connected terrain is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer graphics technology, and in particular to a method, apparatus, electronic device, and storage medium for generating connected terrain. Background Technology

[0002] Terrain generation has important applications in computer graphics, game development, robot navigation, and virtual reality. Existing terrain generation methods typically rely on manually constructing different types of tiles beforehand, and then manually piecing them together to form a complete terrain.

[0003] This traditional workflow, centered on manual piecing together, suffers from both overall inefficiency and a lack of diversity. On one hand, to construct vast terrains, modelers must perform a large amount of tedious work, like repeatedly assembling a jigsaw puzzle, placing and aligning a limited number of tiles. Any modification to the overall layout triggers a chain reaction of rework and adjustments, making the marginal cost of terrain generation extremely high and severely limiting development efficiency. On the other hand, there is a fundamental contradiction between the limited number of tiles and the complexity that manual piecing together can handle. Either diversity is sacrificed in favor of extensive reuse, resulting in a strong sense of repetition in the scene and a lack of terrain diversity, or a large number of variant tiles are created in pursuit of the uniqueness of each terrain feature, making the construction of large-scale terrains almost impractical in terms of both economy and time.

[0004] While wave function collapse (WFC) algorithms can alleviate generation efficiency issues to some extent, traditional WFC algorithms only focus on the adjacency relationships between tiles and typically select the grid cell with the lowest entropy value when choosing the grid cell to collapse. This can lead to the loss of key connectivity points, generating multiple disconnected regions and forming terrain islands. If a post-checking method is used to check terrain connectivity after generation, complex repair operations or regeneration are required for disconnected terrain, which is inefficient and cannot guarantee success. Summary of the Invention

[0005] This invention provides a method, apparatus, electronic device, and storage medium for generating connected terrain, in order to overcome the deficiencies existing in related technologies.

[0006] This invention provides a method for generating connected terrain, comprising:

[0007] Define a terrain grid, wherein the terrain grid comprises multiple grid cells;

[0008] Based on the predefined adjacency and connectivity relationships between each tile, an improved wave function collapse algorithm is applied to progressively determine the target tile to be filled in each grid cell of the terrain grid in order to generate connected terrain.

[0009] In each generation step of the improved wavefunction collapse algorithm, only the grid cell with the smallest entropy value that is adjacent to the connected region is selected as the collapse object, and only the target tile that is connected to at least one boundary tile in the connected region is selected as the determined state of the collapse object; the connected region is composed of the determined state of the collapsed object.

[0010] According to a method for generating connected terrain provided by the present invention, each of the aforementioned tiles corresponds to a difficulty parameter; the step of generating connected terrain by applying an improved wave function collapse algorithm based on predefined adjacency and connectivity relationships between the tiles to progressively determine the target tile to be filled in each grid cell of the terrain grid. This step includes determining the terrain difficulty level.

[0011] Based on the predefined adjacency and connectivity relationships between each tile, an improved wave function collapse algorithm is applied to progressively determine the target tile to be filled in each grid cell of the terrain grid to generate connected terrain, including:

[0012] Based on the terrain difficulty level and the difficulty parameter, the sampling probability of each of the map tiles is calculated, and based on the sampling probability of each of the map tiles, the determined state of the collapsed object in each generation step is selected.

[0013] According to a method for generating connected terrain provided by the present invention, the step of calculating the sampling probability of each of the map tiles based on the terrain difficulty level and the difficulty parameter includes:

[0014] Based on the terrain difficulty level and the difficulty parameter, a Gaussian distribution is applied to calculate the original probability weight of each of the map tiles;

[0015] The original probability weights of each of the aforementioned blocks are normalized to obtain the sampling probability of each of the aforementioned blocks.

[0016] According to the connected terrain generation method provided by the present invention, the grid parameters of the terrain grid and the terrain difficulty level are both input by the user.

[0017] According to a method for generating connected terrain provided by the present invention, the method further includes: based on predefined adjacency and connectivity relationships between tiles, applying an improved wave function collapse algorithm to progressively determine the target tile to be filled in each grid cell of the terrain grid to generate connected terrain;

[0018] The connected regions are tracked in real time after each generation step.

[0019] According to a method for generating connected terrain provided by the present invention, the method involves applying an improved wave function collapse algorithm based on predefined adjacency and connectivity relationships between each tile to progressively determine the target tile to be filled in each grid cell of the terrain grid in order to generate connected terrain, and then includes:

[0020] Retrieve the user-specified target start and end points;

[0021] In the connected terrain, at least one connecting path is determined between the target starting point and the target ending point.

[0022] According to a method for generating connected terrain provided by the present invention, each of the said tiles includes at least flat land, high land, pit land, lower slope and upper slope.

[0023] The present invention also provides a connected terrain generation device, comprising:

[0024] A grid determination module is used to determine a terrain grid, wherein the terrain grid comprises multiple grid cells;

[0025] The terrain generation module is used to gradually determine the target tile to be filled in each grid cell of the terrain grid based on the predefined adjacency and connectivity relationships between each tile, and to generate connected terrain by applying an improved wave function collapse algorithm.

[0026] In each generation step of the improved wavefunction collapse algorithm, only the grid cell with the smallest entropy value that is adjacent to the connected region is selected as the collapse object, and only the target tile that is connected to at least one boundary tile in the connected region is selected as the determined state of the collapse object; the connected region is composed of the determined state of the collapsed object.

[0027] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the connected terrain generation method as described above.

[0028] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the connected terrain generation method as described above.

[0029] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the connected terrain generation method as described above.

[0030] This invention provides a method, apparatus, electronic device, and storage medium for generating connected terrain. The method thoroughly distinguishes between adjacency and connectivity relationships between tiles and introduces connectivity relationships, providing a foundation for subsequent connected terrain generation. This method incorporates an improved wavefunction collapse algorithm. When selecting collapse objects, the algorithm adds a constraint that they are adjacent to already connected regions. Furthermore, when determining the selection state of collapse objects, it adds a constraint that they are connected to at least one boundary tile within the already connected regions. This allows both adjacency and connectivity relationships to be used as constraints during the generation process, fundamentally preventing the generation of disconnected regions. As the generation process progresses, the already connected regions are continuously expanded to cover the entire terrain grid, resulting in connected terrain. Moreover, by expanding outwards from the grid cell with the smallest entropy value adjacent to the already connected regions, this method ensures that the generated connected terrain is always the result of a gradual expansion of single connected regions. This guarantees the connectivity of the connected terrain, significantly reducing the processing costs associated with complex connectivity checks and repairs in later stages, lowering the computational complexity of each generation step, and improving terrain generation efficiency. Simultaneously, it avoids isolated noise points being misidentified as terrain regions, improving the accuracy of connected terrain generation. Furthermore, this method employs an improved wave function collapse algorithm, which can not only automatically generate connected terrain and improve terrain generation efficiency, but also utilize the randomness of the wave function to ensure the diversity of connected terrain. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in this invention or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0032] Figure 1 This is one of the flowcharts illustrating the connected terrain generation method provided by the present invention.

[0033] Figure 2 This is a schematic diagram of each tile in the connected terrain generation method provided by the present invention.

[0034] Figure 3 This is a schematic diagram of the expansion of the connected region in the connected terrain generation method provided by the present invention.

[0035] Figure 4 This is a schematic diagram of connected terrains with different difficulty levels obtained by the connected terrain generation method provided by the present invention.

[0036] Figure 5 This is the second flowchart of the connected terrain generation method provided by the present invention.

[0037] Figure 6 This is a flowchart illustrating the improved wavefunction collapse algorithm used in this invention.

[0038] Figure 7 This is a schematic diagram of the connected terrain generation device provided by the present invention.

[0039] Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0040] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0041] In existing technologies, when generating terrain using the WFC algorithm, global terrain that satisfies adjacency relationships is generated through the propagation of local constraints. Specifically, the WFC algorithm requires pre-defining different types of tiles and their adjacency relationships, and propagating these adjacency relationships as constraints. Through an iterative process of selection-collapse-propagation, the tiles filling each grid cell in the terrain mesh are gradually determined, thereby ensuring that the generated terrain satisfies the constraints.

[0042] However, existing WFC algorithms, by not considering the connectivity between tiles, may result in the loss of key connection points, leading to the generation of multiple disconnected regions and the formation of terrain islands. If a post-checking method is used to check terrain connectivity after generation, complex repair operations or regeneration are required for disconnected terrain, which is inefficient and cannot guarantee success.

[0043] To address the problems of existing WFC algorithms, this invention provides a method for generating connected terrain. For example... Figure 1 As shown, the method includes:

[0044] S1, Determine the terrain grid, which includes multiple grid cells;

[0045] S2, based on the predefined adjacency and connectivity relationships between each tile, an improved wave function collapse algorithm is applied to gradually determine the target tile to be filled in each grid cell of the terrain grid in order to generate connected terrain;

[0046] In each generation step of the improved wavefunction collapse algorithm, only the grid cell with the smallest entropy value that is adjacent to the connected region is selected as the collapse object, and only the target tile that is connected to at least one boundary tile in the connected region is selected as the determined state of the collapse object; the connected region is composed of the determined state of the collapsed object.

[0047] Specifically, the connected terrain generation method provided in this embodiment of the invention is executed by a connected terrain generation device, which can be configured in a computer. The computer can be a local computer or a cloud computer. The local computer can be a computer, tablet, etc., and no specific limitation is made here.

[0048] First, perform step S1 to determine the terrain grid. This terrain grid can be either the default grid or a user-defined grid; no specific limitation is made here.

[0049] A terrain grid can include multiple grid cells, and all grid cells are the same size.

[0050] Then, step S2 is executed, introducing a dual-relationship definition system. This system pre-defines the adjacency and connectivity relationships between each tile. In this embodiment of the invention, the types of each tile include at least flat land, high ground, pit land, lower slope, and upper slope. For example... Figure 2 As shown, the tiles from left to right are flat land (F), high ground (H), lower slope (BR), and upper slope (TR). The lower slope refers to the downhill portion of the slope, and the upper slope refers to the uphill portion. Figure 2 In the center, E represents East and N represents North.

[0051] In the bi-relation definition system, each adjacency relation contains two tiles and their corresponding directions, indicating that the two tiles can be adjacent in the corresponding direction, i.e., they can be placed next to each other. Each connectivity relation contains two tiles and their corresponding directions, indicating that the two tiles can be connected in the corresponding direction, i.e., they can reach each other. For example, (F_E, H_W) means that the east side of the flat land can be adjacent to the west (W) side of the high land, but the two are not connected. On the other hand, [F_N, BR_S] means that the north side of the flat land can be connected to the south (S) side of the lower slope.

[0052] It's understandable that connectivity is a special case of adjacency; tiles with connectivity always have adjacency, but tiles with adjacency do not necessarily have connectivity. For example, a flat area and a high area can be placed adjacently and have an adjacency relationship, but without a ramp connecting them, the flat area and the high area cannot reach each other; that is, they do not have a connectivity relationship. Therefore, adjacency and connectivity are two sets of relationships that are related but independent of each other, and can jointly guide the improvement of the terrain generation process in wavefunction collapse algorithms.

[0053] Furthermore, by utilizing the predefined adjacency and connectivity relationships between each tile, and applying the improved wavefunction collapse algorithm, the target tile to be filled in each grid cell of the terrain grid can be determined step by step to generate connected terrain. Here, the improved WFC algorithm is based on the WFC algorithm, introducing predefined connectivity relationships between each tile, and introducing a connectivity guarantee mechanism in each generation step. That is, only the grid cell adjacent to the already connected region and with the minimum entropy value is selected as the collapse object, and only one target tile that is connected to at least one boundary tile in the already connected region is selected as the determined state of the collapse object. The connectivity guarantee mechanism uses adjacency and connectivity relationships as constraints, which can ensure that the already connected region obtained in each generation step is a connected whole, and as the generation steps proceed, the already connected region continuously expands to cover the entire terrain grid. This connectivity guarantee mechanism can not only guarantee the connectivity of the obtained connected terrain, but also guarantee the local optimum characteristics of the collapse object due to the minimum entropy value.

[0054] It is understandable that each generation step is a step of determining a target tile to fill a grid cell. The connected region used in each generation step consists of the determined states of the collapsed objects that have been collapsed in all previous generation steps. Here, collapse is the selection of a definite state from the fuzzy possible states of the collapsed object. Possible states refer to all tiles that can fill the collapsed object, and the determined state refers to the target tile that will ultimately fill the collapsed object.

[0055] The entropy value of each grid cell in the terrain grid can be determined by sampling the probability of each tile in the possible states of each grid cell. The sampling probability of each tile can be predefined or calculated by introducing the difficulty parameter of each tile and combining it with the terrain difficulty level; no specific limitation is made here. For example, if any grid cell has N possible states, the entropy value of any grid cell can be calculated using the sampling probability of each tile, using the following formula:

[0056] ;

[0057] in, Let be the entropy value of any grid cell. Let be the sampling probability of the i-th patch.

[0058] For the initial generation step of the improved wavefunction collapse algorithm, either any grid cell in the terrain grid can be randomly selected as the initial collapse object, i.e., the starting point of the connected region; for example, any grid cell could be a corner cell of the terrain grid. Alternatively, the grid cell with the minimum entropy value in the terrain grid can be selected as the initial collapse object. Afterward, a tile can be randomly selected from each tile as the target tile for the initial collapse object; this target tile can serve as the defined state of the initial collapse object.

[0059] Figure 3 This is a schematic diagram illustrating the expansion of a connected region. For example... Figure 3 As shown, it includes the initial generation step, intermediate generation steps, and the connected regions under the final generation step. Figure 3 The boxes in the text represent grid cells in the terrain grid.

[0060] The connected terrain generation method provided in this embodiment of the invention first determines the terrain grid, and then, using the predefined adjacency and connectivity relationships between each tile, applies an improved wavefunction collapse algorithm to progressively determine the target tile to fill each grid cell in the terrain grid, thereby generating connected terrain. This method thoroughly distinguishes between adjacency and connectivity relationships between tiles by defining them, and introduces connectivity relationships to provide a foundation for subsequent connected terrain generation. The improved wavefunction collapse algorithm adds a constraint of adjacency to already connected regions when selecting collapse objects, and adds a constraint of connectivity to at least one boundary tile in already connected regions when determining the selection state of collapse objects. This allows adjacency and connectivity relationships to be used as constraints simultaneously during the generation process, fundamentally preventing the generation of disconnected regions. As the generation steps proceed, the already connected regions are continuously expanded to cover the entire terrain grid, thus obtaining connected terrain. Moreover, this method, by expanding outward from the grid cell with the minimum entropy value adjacent to already connected regions, ensures that the generated connected terrain is always the result of a gradual expansion of single connected regions. This guarantees the connectivity of the connected terrain, significantly reducing the processing costs associated with complex connectivity checks and repairs in later stages, lowering the computational complexity of each generation step, and improving terrain generation efficiency. Simultaneously, it avoids misclassifying isolated noise points as terrain regions, improving the accuracy of connected terrain. Furthermore, this method employs an improved wavefunction collapse algorithm, which not only automatically generates connected terrain, improving terrain generation efficiency, but also utilizes the randomness of the wavefunction to ensure the diversity of connected terrain.

[0061] Based on the above embodiments, each of the map tiles corresponds to a difficulty parameter; the step of applying an improved wave function collapse algorithm based on the predefined adjacency and connectivity relationships between each map tile to gradually determine the target map tile to be filled in each grid cell of the terrain grid in order to generate connected terrain includes: determining the terrain difficulty level;

[0062] Based on the predefined adjacency and connectivity relationships between each tile, an improved wave function collapse algorithm is applied to progressively determine the target tile to be filled in each grid cell of the terrain grid to generate connected terrain, including:

[0063] Based on the terrain difficulty level and the difficulty parameter, the sampling probability of each of the map tiles is calculated, and based on the sampling probability of each of the map tiles, the determined state of the collapsed object in each generation step is selected.

[0064] Specifically, each map tile corresponds to a predefined difficulty parameter, which may include the mean and variance of a Gaussian distribution, used to precisely control the probability of each tile appearing at different terrain difficulty levels. It can be understood that each map tile corresponds to an optimal difficulty range, within which the probability of its appearance is highest; the further away from this difficulty range, the lower the probability of its appearance.

[0065] Before generating connected terrain, you can first determine the terrain difficulty level. This difficulty level can be either the default difficulty level or a user-defined difficulty level; there is no specific limitation here.

[0066] Furthermore, during the generation of connected terrain, the sampling probability of each tile can be calculated using the terrain difficulty level and difficulty parameters. For example, the original probability weight of each tile can be calculated by applying a Gaussian distribution using the terrain difficulty level and difficulty parameters. For instance, the original probability weight of the i-th tile can be calculated using the following formula:

[0067] ;

[0068] Where x represents the terrain difficulty level. Let represent the original probability weight of the i-th tile, and let represent the suitability of the i-th tile under terrain difficulty level x. Let be the mean of the difficulty parameters for the i-th tile. Let be the variance in the difficulty parameter of the i-th tile.

[0069] Since the original probability weights do not sum to 1 and do not belong to a probability distribution, it is necessary to normalize all the original probability weights to obtain the sampling probability of each patch. For example, the sampling probability of the i-th patch can be calculated using the following formula:

[0070] ;

[0071] in, Let be the sampling probability of the i-th patch. This refers to the original probability weight of the j-th tile, and its calculation formula is the same as... The calculation formula is the same.

[0072] Subsequently, by utilizing the sampling probability of each tile, a definite state of the collapsed object in each generation step can be selected. For example, the tile with the highest sampling probability among the possible states of the collapsed object can be selected as the target tile, i.e., as the definite state of the collapsed object.

[0073] like Figure 4 The diagram shown is a schematic representation of connected terrain with different difficulty levels obtained by the connected terrain generation method provided in this embodiment of the invention. Figure 4 The Chinese map consists of 6 rows and 4 columns. The terrain difficulty level of the 4 columns increases sequentially from left to right, and the terrain difficulty level of each connected terrain in the same column is the same, indicating that the difficulty is comparable. This shows that the connected terrain generated by this method has diversity.

[0074] In this embodiment of the invention, each terrain difficulty level is associated with the sampling probability of each tile. This ensures that adjusting the terrain difficulty level does not disrupt the global connectivity of connected terrain, achieving precise control over the difficulty of connected terrain. The resulting connected terrain is both challenging and feasible, making it suitable for various application scenarios. For example, it is particularly suitable for applications such as game level design and robot testing.

[0075] Based on the above embodiments, the grid parameters of the terrain grid and the terrain difficulty level are both input by the user.

[0076] Specifically, the terrain grid in this embodiment of the invention can be generated using grid parameters input by the user. Grid parameters may include the number of rows and columns in the terrain grid, as well as the size of each grid cell. Furthermore, the terrain difficulty level can also be input by the user, thus ensuring not only the customizability of connected terrain but also its diversity.

[0077] Based on the above embodiments, the step of applying an improved wave function collapse algorithm to progressively determine the target tile to fill each grid cell in the terrain grid to generate connected terrain, based on the predefined adjacency and connectivity relationships between each tile, further includes:

[0078] The connected regions are tracked in real time after each generation step.

[0079] By tracking connected regions in real time, connected regions can be maintained and updated in real time, thereby supporting efficient connectivity decisions.

[0080] Based on the above embodiments, the step of applying an improved wave function collapse algorithm to progressively determine the target tile to fill each grid cell in the terrain grid, based on the predefined adjacency and connectivity relationships between each tile, to generate connected terrain, includes:

[0081] Retrieve the user-specified target start and end points;

[0082] In the connected terrain, at least one connecting path is determined between the target starting point and the target ending point.

[0083] Specifically, in the connected terrain generated in this embodiment of the invention, during application, the user-specified target start point and target end point can be received first. Both the target start point and target end point can be obtained by the user selecting them on the connected terrain.

[0084] Subsequently, at least one connecting path between the target start point and the target end point can be determined in the connected terrain to meet the connectivity requirements of the application scenario.

[0085] like Figure 5 As shown, the complete process of the connected terrain generation method provided in this embodiment of the invention includes:

[0086] Receive user input, which may include terrain parameters and terrain difficulty level;

[0087] Determine the terrain grid based on terrain parameters;

[0088] Calculate the sampling probability of each map tile using the terrain difficulty level and the difficulty parameters of each tile;

[0089] By combining the adjacency and connectivity relationships between tiles in the dual-relation definition system, as well as the sampling probability of each tile, an improved wave function collapse algorithm is applied to gradually determine the target tile to be filled in each grid cell of the terrain grid, and to track the connected regions in the terrain grid in real time, thereby obtaining and outputting the connected terrain.

[0090] like Figure 6 As shown, the process of the improved wavefunction collapse algorithm used in this embodiment of the invention includes:

[0091] Set possible states for all grid cells in the terrain grid;

[0092] Place an initial seed in the terrain grid as the starting point for the connected regions;

[0093] Check if the termination condition is met; the termination condition includes the collapse of all grid cells in the terrain grid.

[0094] If the termination condition is met, then connected terrain is generated;

[0095] If the termination condition is not met, select the grid cell adjacent to the already connected region as the candidate grid cell;

[0096] Calculate the entropy value of the candidate grid cells and select the candidate grid cell with the smallest entropy value as the collapse object;

[0097] Based on the difficulty parameters and terrain difficulty level of each tile, calculate the sampling probability of each tile, select a reference tile that can be connected to at least one boundary tile in the connected area, and select the target tile with the highest sampling probability from the reference tiles according to the sampling probability of the reference tiles to perform collapse, that is, to determine its state as the collapse object.

[0098] Update the connected regions and select new collapse objects;

[0099] The adjacency and connectivity relationships with each boundary tile in the already connected region are propagated as constraints, and the termination condition is checked until it is met.

[0100] like Figure 7 As shown, based on the above embodiments, this embodiment of the invention provides a connected terrain generation device, comprising:

[0101] The grid determination module 71 is used to determine the terrain grid, which includes multiple grid cells;

[0102] The terrain generation module 72 is used to gradually determine the target tile to be filled in each grid cell of the terrain grid based on the predefined adjacency and connectivity relationships between each tile, and to generate connected terrain by applying an improved wave function collapse algorithm.

[0103] In each generation step of the improved wavefunction collapse algorithm, only the grid cell with the smallest entropy value that is adjacent to the connected region is selected as the collapse object, and only the target tile that is connected to at least one boundary tile in the connected region is selected as the determined state of the collapse object; the connected region is composed of the determined state of the collapsed object.

[0104] Specifically, the functions of each module in the connected terrain generation device provided in this embodiment of the invention correspond one-to-one with the operation flow of each step in the above method-like embodiments, and the achieved effects are also the same. For details, please refer to the above embodiments, and this will not be repeated in this embodiment of the invention.

[0105] Figure 8 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 8As shown, the electronic device may include a processor 810, a communications interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communications interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute the connected terrain generation method provided in the above embodiments.

[0106] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to related technologies, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0107] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the connected terrain generation method provided in the above embodiments.

[0108] In another aspect, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the connected terrain generation method provided in the above embodiments. This computer-readable storage medium can be either a non-transitory computer-readable storage medium or a transient computer-readable storage medium, and is not specifically limited herein.

[0109] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0110] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of software products. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for generating connected terrain, characterized in that, include: Define a terrain grid, wherein the terrain grid comprises multiple grid cells; Based on the predefined adjacency and connectivity relationships between each tile, an improved wave function collapse algorithm is applied to progressively determine the target tile to be filled in each grid cell of the terrain grid in order to generate connected terrain. In each generation step of the improved wave function collapse algorithm, only the grid cell adjacent to the connected region and with the smallest entropy value is selected as the collapse object, and only the target tile that is connected to at least one boundary tile in the connected region is selected as the determined state of the collapse object; the connected region is composed of the determined state of the collapsed object. Each of the aforementioned tiles corresponds to a difficulty parameter, which includes the mean and variance in a Gaussian distribution; based on the predefined adjacency and connectivity relationships between each tile, an improved wave function collapse algorithm is applied to progressively determine the target tile to be filled in each grid cell of the terrain grid to generate connected terrain, which includes determining the terrain difficulty level beforehand; Based on the predefined adjacency and connectivity relationships between each tile, an improved wave function collapse algorithm is applied to progressively determine the target tile to be filled in each grid cell of the terrain grid to generate connected terrain, including: Based on the terrain difficulty level and the difficulty parameter, the sampling probability of each of the map tiles is calculated, and based on the sampling probability of each of the map tiles, the determination state of the collapsed object in each generation step is selected. The step of calculating the sampling probability of each map tile based on the terrain difficulty level and the difficulty parameter includes: Based on the terrain difficulty level and the difficulty parameter, a Gaussian distribution is applied to calculate the original probability weight of each tile; the original probability weight of the i-th tile is calculated using the following formula: ; Where x represents the terrain difficulty level. Let represent the original probability weight of the i-th tile, and let represent the suitability of the i-th tile under terrain difficulty level x. Let be the mean of the difficulty parameters for the i-th tile. Let be the variance in the difficulty parameter of the i-th tile; The original probability weights of each of the aforementioned blocks are normalized to obtain the sampling probability of each of the aforementioned blocks.

2. The method for generating connected terrain according to claim 1, characterized in that, The grid parameters of the terrain grid and the terrain difficulty level are both input by the user.

3. The method for generating connected terrain according to claim 1 or 2, characterized in that, The method of applying an improved wave function collapse algorithm to progressively determine the target tile to fill each grid cell in the terrain grid, based on predefined adjacency and connectivity relationships between each tile, to generate connected terrain, also includes: The connected regions are tracked in real time after each generation step.

4. The method for generating connected terrain according to claim 1 or 2, characterized in that, Based on the predefined adjacency and connectivity relationships between each tile, an improved wave function collapse algorithm is applied to progressively determine the target tile to be filled in each grid cell of the terrain grid to generate connected terrain, which then includes: Retrieve the user-specified target start and end points; In the connected terrain, at least one connecting path is determined between the target starting point and the target ending point.

5. The method for generating connected terrain according to claim 1 or 2, characterized in that, Each of the aforementioned blocks includes at least flat ground, high ground, pit ground, lower slope, and upper slope.

6. A connected terrain generation device, characterized in that, include: A grid determination module is used to determine a terrain grid, wherein the terrain grid comprises multiple grid cells; The terrain generation module is used to gradually determine the target tile to be filled in each grid cell of the terrain grid based on the predefined adjacency and connectivity relationships between each tile, and to generate connected terrain by applying an improved wave function collapse algorithm. In each generation step of the improved wave function collapse algorithm, only the grid cell adjacent to the connected region and with the smallest entropy value is selected as the collapse object, and only the target tile that is connected to at least one boundary tile in the connected region is selected as the determined state of the collapse object; the connected region is composed of the determined state of the collapsed object. Each of the aforementioned tiles corresponds to a difficulty parameter, which includes the mean and variance in a Gaussian distribution; based on the predefined adjacency and connectivity relationships between each tile, an improved wave function collapse algorithm is applied to progressively determine the target tile to be filled in each grid cell of the terrain grid to generate connected terrain, which includes determining the terrain difficulty level beforehand; The terrain generation module is specifically used for: Based on the terrain difficulty level and the difficulty parameter, a Gaussian distribution is applied to calculate the original probability weight of each tile; the original probability weight of the i-th tile is calculated using the following formula: ; Where x represents the terrain difficulty level. Let represent the original probability weight of the i-th tile, and let represent the suitability of the i-th tile under terrain difficulty level x. Let be the mean of the difficulty parameters for the i-th tile. Let be the variance in the difficulty parameter of the i-th tile; The original probability weights of each of the aforementioned map patches are normalized to obtain the sampling probability of each of the aforementioned map patches; Based on the sampling probability of each of the aforementioned tiles, the determined state of the collapsed object in each generation step is selected.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the connected terrain generation method as described in any one of claims 1-5.

8. 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 connected terrain generation method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Chinese style garden programmed generation method and system

    CN120180552A