CN113827976A - Random map generation method and device, storage medium and computing equipment - Google Patents

Random map generation method and device, storage medium and computing equipment Download PDF

Info

Publication number
CN113827976A
CN113827976A CN202111146365.1A CN202111146365A CN113827976A CN 113827976 A CN113827976 A CN 113827976A CN 202111146365 A CN202111146365 A CN 202111146365A CN 113827976 A CN113827976 A CN 113827976A
Authority
CN
China
Prior art keywords
map
random
blocks
block
traversal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111146365.1A
Other languages
Chinese (zh)
Inventor
李沁铭
祝中华
张纯新
杨宗翰
张驰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Perfect World Chongqing Software Technology Co ltd
Original Assignee
Perfect World Chongqing Software Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Perfect World Chongqing Software Technology Co ltd filed Critical Perfect World Chongqing Software Technology Co ltd
Priority to CN202111146365.1A priority Critical patent/CN113827976A/en
Publication of CN113827976A publication Critical patent/CN113827976A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/60Generating or modifying game content before or while executing the game program, e.g. authoring tools specially adapted for game development or game-integrated level editor
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/60Generating or modifying game content before or while executing the game program, e.g. authoring tools specially adapted for game development or game-integrated level editor
    • A63F13/69Generating or modifying game content before or while executing the game program, e.g. authoring tools specially adapted for game development or game-integrated level editor by enabling or updating specific game elements, e.g. unlocking hidden features, items, levels or versions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/20Drawing from basic elements, e.g. lines or circles
    • G06T11/203Drawing of straight lines or curves

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention provides a random map generation method, a random map generation device, a storage medium and computing equipment, wherein the method comprises the following steps: dividing an area of a random map to be generated into a plurality of map blocks and designating an initial map block; acquiring a preset random map complexity condition parameter, traversing the map blocks from the initial map block according to a preset traversal strategy, and generating a path meeting the complexity condition parameter on a traversal track; analyzing the connectivity of the map blocks corresponding to the generated paths; and selecting art resources which accord with the connectivity of each map block, and filling the corresponding map block with the selected art resources to obtain the random map. The embodiment of the invention can conveniently and effectively control the difficulty coefficient of the map, effectively saves the step of recalling the connectivity of the map blocks, and improves the generation efficiency of the random map. The random map provided by the embodiment of the invention has strong expandability, and new map experience can be easily realized only by expanding the contents of the map blocks.

Description

Random map generation method and device, storage medium and computing equipment
Technical Field
The invention relates to the technical field of map generation, in particular to a random map generation method, a random map generation device, a random map generation storage medium and a random map generation computing device.
Background
In the prior art, in the process of generating a random map, basic units forming the map are defined as rectangular squares with the same size, for example, the size of the basic unit grid is 32 × 32, which may also be referred to as "area". Then, the size of the whole map is set to be composed of how many regions, for example, the whole map is 8 × 8, and the map is composed of 64 regions. Then, traversing the whole map, and randomly distributing the communication directions to the four edges of each area. And then all the non-communicated areas are communicated through a routing algorithm, and finally any two areas in all the effective areas are communicated. Finally, checking the map validity, if the map validity is confirmed, searching scene modules which accord with regional connectivity from the resources according to the foundation for splicing, and finally generating a map; if not, the map is regenerated according to the previous rules.
However, the map tiles selected in the process of generating the map traverse all the area data in the whole map, which may cause the generated map to have a messy panorama and to be not beautiful enough. In addition, in the process of generating the map, only the random opening direction is used, so that the map generation process is easily uncontrollable and does not support parameter adjustment. Furthermore, because all map blocks in the whole map need to be traversed and finally the connectivity of all effective map blocks is realized according to the algorithm, the overall efficiency of the map generation process is low, and the map generation process is not suitable for the generation of the large map.
Disclosure of Invention
In view of the above problems, the present invention is provided to provide a random map generation method, apparatus, storage medium and computing device for overcoming the above problems or at least partially solving the above problems, which can conveniently and effectively control the difficulty coefficient of a map, effectively eliminate the step of recalling the connectivity of map blocks, and improve the generation efficiency of a random map. The random map generated by the embodiment of the invention has stronger expandability, and if the richness of the map is increased, new map experience can be easily realized only by expanding the contents of map blocks.
According to an aspect of the embodiments of the present invention, there is provided a random map generation method, including:
dividing an area of a random map to be generated into a plurality of map blocks and designating an initial map block;
acquiring a preset random map complexity condition parameter, traversing the map blocks from the initial map block according to a preset traversal strategy, and generating a path meeting the complexity condition parameter on a traversal track;
analyzing the connectivity of the map blocks corresponding to the generated paths;
and selecting art resources which accord with the connectivity of each map block, and filling the corresponding map block with the selected art resources to obtain the random map.
Optionally, the preconfigured random map complexity condition parameter includes:
at least one of a maximum consecutive number of consecutive tiles, a maximum number of branches of any level, and a maximum length of branches of any level.
Optionally, if the path includes a map backbone, traversing the map segment from the initial map segment according to a preset traversal strategy, and generating a path satisfying the complexity condition parameter on a traversal trajectory, where the path includes:
setting a map edge opposite to the initial map block position as a destination edge;
selecting a random direction as a direction for traversing the map blocks, and traversing the map blocks in the selected direction by taking the initial map blocks as main starting points of the map, wherein the random direction is not opposite to the direction of the destination edge;
if the traversed continuous map blocks reach the preset continuous number and/or meet the condition of stopping traversal, reselecting the direction perpendicular to the last selected direction, continuously traversing the map blocks in the reselected direction by taking the current traversed map block as a starting point, and stopping traversing the map blocks until a new direction cannot be reselected; wherein the preset continuous number is not more than the maximum continuous number of the continuous map blocks;
and if the map block is traversed to the destination edge when the traversal of the map block is stopped, selecting one map block as a map main trunk terminal at the destination edge.
Optionally, if the destination edge is traversed when the map tile stops traversing, selecting a map tile as the map main trunk end point at the destination edge, including:
if the map block is traversed to the destination edge when the traversal of the map block is stopped, taking the finally traversed map block as a map main terminal point; or
And if the destination edge is traversed when the traversal of the map blocks is stopped, continuously traversing the map blocks of the specified number along the destination edge and taking the finally traversed map blocks as map main destination points.
Optionally, if the path includes at least one stage of branches, traversing the map block from the initial map block according to a preset traversal strategy, and generating a path that satisfies the complexity condition parameter on a traversal trajectory, including:
selecting any map block except the starting point and the end point of the previous branch as the starting point of the current branch on the previous branch; wherein, the upper branch of the first-level branch is a map trunk;
selecting a random direction as the direction for traversing the map block, and traversing the map block from the starting point of the current branch to the selected direction;
if the traversed continuous map blocks reach the preset continuous number and/or meet the traversal stopping condition, reselecting the direction perpendicular to the last selected direction, continuously traversing the map blocks in the reselected direction by taking the current traversed map blocks as a starting point until a new direction cannot be reselected or the current branch reaches the preset length, and stopping traversing the map blocks until the preset length is not more than the maximum length of the level to which the current branch belongs;
and taking the last traversal map block when the traversal of the map block is stopped as the end point of the current branch.
Optionally, the stop traversal condition includes: the map block traversed currently is a map block positioned at the edge of the map; and/or the map traversed in the selected direction forms a closed loop with other traversed maps.
Optionally, the preconfigured random map complexity condition parameter further includes whether a secret room parameter needs to be generated, and after generating a map trunk meeting the complexity condition parameter on a traversal trajectory, the method further includes:
if the secret room parameters needing to be generated are obtained, randomly generating a secret room with a preset specification size at any edge of the map;
calculating the shortest path between the map trunk and the secret room, and generating a connecting path for connecting the map trunk and the secret room on the shortest path;
wherein, the distance between the map trunk and the secret room is not less than one map block.
Optionally, before acquiring the preconfigured random map complexity condition parameter, the method further includes:
configuring a random map complexity condition parameter through a complexity editor;
generating a random map example based on the random map complexity condition parameter;
displaying the generated random map example on an editing interface of the complexity editor.
Optionally, analyzing connectivity of the map tile corresponding to the generated path includes:
analyzing whether each map block corresponding to the generated path is connected with an adjacent map block or not;
if any map block is connected with an adjacent map block, the map blocks are marked to be communicated in the direction of connecting the adjacent map blocks and not communicated in the direction of not connecting the adjacent map blocks.
Optionally, selecting an art resource that meets connectivity of each map block, and filling the map block with the selected art resource to obtain the random map, including:
selecting art resource blocks which accord with the connectivity of each map block;
and filling the corresponding map blocks with the selected art resource blocks to obtain the random map, wherein one art resource block fills one corresponding map block.
According to another aspect of the embodiments of the present invention, there is also provided a random map generation apparatus, including:
the dividing module is suitable for dividing an area of the random map to be generated into a plurality of map blocks and appointing an initial map block;
the generating module is suitable for acquiring a preconfigured random map complexity condition parameter, traversing the map blocks from the initial map block according to a preset traversal strategy, and generating a path meeting the complexity condition parameter on a traversal track;
the analysis module is suitable for analyzing the connectivity of the map blocks corresponding to the generated paths;
and the filling module is suitable for selecting the art resources which accord with the connectivity of the map blocks, and filling the map blocks corresponding to the selected art resources to obtain the random map.
According to another aspect of embodiments of the present invention, there is also provided a computer storage medium having stored thereon computer program code which, when run on a computing device, causes the computing device to perform the random map generation method of any of the above embodiments.
According to another aspect of the embodiments of the present invention, there is also provided a computing device, including: a processor; a memory storing computer program code; the computer program code, when executed by the processor, causes the computing device to perform the random map generation method of any of the embodiments above.
In the embodiment of the invention, the area of the random map to be generated is divided into a plurality of map blocks, an initial map block is designated, then a preset random map complexity condition parameter is obtained, the map blocks are traversed from the initial map block according to a preset traversal strategy, and a path meeting the complexity condition parameter is generated on a traversal track. And after the path is generated, analyzing the connectivity of the map blocks corresponding to the path, finally selecting the art resources meeting the connectivity of each map block, and filling the corresponding map blocks with the selected art resources to obtain the random map. Therefore, the embodiment of the invention can support the adjustment of the random map complexity condition parameters, can conveniently and effectively control the difficulty coefficient of the map, and can freely and conveniently adjust a reasonable user experience difficulty curve, such as linear difficulty change from easy to difficult or step-type difficulty change. Because the map blocks are communicated all the time in the generation process of the random map, the step of making the connectivity of the map blocks again is effectively omitted, and the generation efficiency of the random map is improved. The random map generated by the embodiment of the invention has stronger expandability, and if the richness of the map is increased, new map experience can be easily realized only by expanding the contents of map blocks.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments thereof, taken in conjunction with the accompanying drawings.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 shows a flow diagram of a random map generation method according to an embodiment of the invention;
FIG. 2 illustrates a flow diagram for generating a map backbone, according to an embodiment of the invention;
FIG. 3 is a flow diagram illustrating generation of a first level branch according to an embodiment of the invention
FIG. 4 illustrates a display interface diagram of a complexity editor, in accordance with an embodiment of the invention;
FIG. 5 is a diagram of an art resource according to an embodiment of the invention; and
fig. 6 is a schematic structural diagram of a random map generation apparatus according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
In order to solve the above technical problem, an embodiment of the present invention provides a random map generation method, and the random map generation method of the embodiment is applicable to a Unity game engine. Fig. 1 shows a flow chart of a random map generation method according to an embodiment of the present invention, and referring to fig. 1, the random map generation method at least includes steps S102 to S108.
Step S102, dividing an area of the random map to be generated into a plurality of map blocks and appointing an initial map block.
The map blocks of the embodiment of the invention can also be understood as small grids with consistent sizes. For example, the area in which the random map is to be generated is divided into rectangular checkerboards of n × m size, each of which is the same size and is also simply referred to as a "cell" as the minimum unit of the generation path and the subsequent filling of the art resource.
When the initial map block is designated, the embodiment of the invention can also designate by configuring the parameters of the map block, and the initial map block can be arranged at the edge of the map generally.
And step S104, acquiring a preset random map complexity condition parameter, traversing the map blocks from the initial map block according to a preset traversal strategy, and generating a path meeting the complexity condition parameter on a traversal track.
The path of the embodiment of the invention can comprise a map trunk, a branch path, a path connecting the trunk and a secret room and the like.
And step S106, analyzing the connectivity of the map block corresponding to the generated path.
And S108, selecting art resources which accord with the connectivity of each map block, and filling the corresponding map block with the selected art resources to obtain a random map.
According to the embodiment of the invention, map blocks are not randomly selected to be communicated, but the map is generated from the pre-specified fixed initial blocks, so that the generation process of the random map can be effectively controlled. The embodiment of the invention can also support the adjustment of the complexity condition parameters of the random map, can conveniently and effectively control the difficulty coefficient of the map, and can freely and conveniently adjust a reasonable user experience difficulty curve, such as linear difficulty change from easy to difficult or step-type difficulty change. Because the map blocks are communicated all the time in the generation process of the random map, the embodiment of the invention effectively omits the step of communicating the map block connectivity again, and improves the generation efficiency of the random map. The random map generated by the embodiment of the invention has stronger expandability, and if the richness of the map is increased, new map experience can be easily realized only by expanding the contents of map blocks.
The random map of the embodiment of the invention can select art resources according to the connectivity of the map blocks in the generation process, can effectively ensure that the map blocks are communicated in the generation process of the map, and does not need to traverse all the map blocks in the whole map again to determine the connectivity of the map blocks, so that the overall efficiency of the generation process of the random map is greatly improved, and the random map generation method and the random map generation device can be effectively applied to the generation process of a large map with a complex scene, and the generation efficiency of the large map is improved. For a large map with higher complexity, map paths meeting corresponding complexity conditions can be generated in order by configuring the complexity condition parameters of the large map, so that the generated panoramic view of the large map is ordered and controllable and more attractive, and the use experience of a user is improved.
In an embodiment of the present invention, the preconfigured random map complexity condition parameter may include at least one of a maximum consecutive number of consecutive map tiles, a maximum number of any level branches, a maximum length of any level branches, and the like. Assuming a map block is a unit length, the maximum length of any level branch can be understood as the number of map blocks contained in any level branch.
The branch level of the embodiment of the present invention may include a primary branch, a secondary branch, and the like, and the maximum number and the maximum length of any level of branches in the corresponding complexity condition parameters may include the maximum number of the primary branch (i.e., the number of the primary branches generated from the trunk), the maximum length of the primary branch, the maximum number of the secondary branch (i.e., the number of the secondary branches generated from the primary branch), the maximum length of the secondary branch, and the like. The complexity of the random map, that is, the difficulty of the random map, can be adjusted by these complexity condition parameters, and the more tortuous and diverged the roads in the random map, the more difficult the random map, otherwise, the simpler the random map. The relative customization of the random map can be realized by setting the complexity condition parameter of the random map.
Referring to the step S102, in an embodiment of the present invention, if the path includes a map backbone, the map block is traversed from the initial map block according to a preset traversal strategy, and a process of generating the map backbone satisfying the complexity condition parameter on the traversal trajectory is as follows.
First, a map edge opposite to the initial map block position is set as a destination edge. For example, the initial map block is at the bottom of the map, and the top of the map is the edge of the random map destination.
Then, a random direction is selected as the direction for traversing the map block, and the map block is traversed towards the selected direction by taking the initial map block as a main starting point of the map.
In this embodiment, the random direction is not the inverse of the direction of the destination edge, i.e. the direction of the destination edge cannot be selected to be inverse, and if the destination edge is the top edge, the downward direction cannot be selected all the time.
And if the traversed continuous map blocks reach the preset continuous number and/or meet the condition of stopping traversal, reselecting the direction perpendicular to the last selected direction, continuously traversing the map blocks in the reselected direction by taking the current traversed map block as a starting point, and stopping traversing the map blocks until a new direction cannot be reselected, wherein the preset continuous number is not more than the maximum continuous number of the continuous map blocks in the complexity condition parameter.
In the embodiment of the present invention, if the direction traversed last time is horizontal (e.g., left and right directions), then this time should be random in the vertical direction (e.g., up and down directions), and vice versa. The stop traversal condition of the embodiment includes at least one of the currently traversed map tile being a map tile located at an edge of the map, the map tile traversed in the selected direction forming a closed loop with other traversed map tiles, and the like.
And finally, if the map block is traversed to the destination edge when the traversal of the map block is stopped, selecting one map block as a map main trunk terminal point at the destination edge.
In an alternative embodiment, the manner of selecting the map stem end point may include two manners.
First, if the map block is stopped from traversing to the destination edge, the last traversed map block is used as the map main destination.
And secondly, if the destination edge is traversed when the map blocks stop traversing, continuously traversing a specified number of map blocks along the destination edge and taking the finally traversed map blocks as map main destination points. For example, after the destination edge is traversed, 5 map tiles will be traversed continuously along the destination edge, and the 5 th map tile after being traversed continuously is used as the map main trunk end point.
In order to more clearly embody the scheme of the embodiment of the present invention, the embodiment of the present invention may understand the process of traversing the map block as a process of continuously advancing a "greedy snake". At this time, the initial map block may be defined as an entry, a "greedy snake" is sent out from the entry as a tail, a target edge of the "greedy snake" is opposite to the entry (for example, the entry is at the bottom edge of the map, and the top edge of the map is the target edge), and the "greedy snake" will continue to advance according to the preset traversal strategy before reaching the target edge. Since the map tiles are traversed one at a time, the "greedy snake" advances one cell per step. Referring to fig. 2, the process of generating a map backbone may include the following steps.
And 2.1, advancing from the main map entrance to the selected random direction.
The random direction of this step is not the inverse of the direction in which the destination edge is located.
And 2.2, judging whether the number of the forward steps in the selected direction reaches n steps. If not, executing the step 2.3; if yes, go to step 2.4.
N of this embodiment represents a preset consecutive number of consecutive map tiles, n being not greater than the complexity condition parameter "maximum consecutive number of consecutive map tiles", which refers to the maximum consecutive number of consecutive maps traversed in one direction. The embodiment of the invention can add one to the number of the previous steps after each previous step, thereby facilitating the statistics of the number of the previous steps.
Step 2.3, judging whether the traversal stopping condition is met, if not, executing step 2.31, continuing to go one step, and executing step 2.61; if yes, go to step 2.4.
The condition of stopping traversal means that the greedy snake cannot exceed the map when advancing, and the greedy snake cannot bite the body of the user when advancing so as to avoid forming a loop; the sequence of step 2.2 and step 2.3 is not limited in the embodiments of the present invention.
And 2.4, judging whether the selectable direction exists or not. If yes, go to step 2.5, reselect the direction perpendicular to the last selected direction, and go to step 2.31 (this step is to continue to go one step towards the reselected direction); if not, go to step 2.62.
The direction of reselection is perpendicular to the last selected direction, and if the direction of previous progress was horizontal (left, right), then this time should be random in the vertical direction (up, down), and vice versa.
Step 2.61, judging whether the target edge is reached, if so, executing step 2.7; if not, step 2.2 is executed.
And 2.62, judging whether the target edge is reached. If yes, executing step 2.7; if not, step 2.8 is executed.
And 2.7, determining the position reached when the map is advanced to the destination edge as a map main trunk outlet.
And 2.8, determining that the map backbone fails to be exported, and failing to generate the map backbone.
If no direction can be selected, no way is considered to be available, and if the greedy snake does not reach the destination edge at the moment, failure is considered and an exception can be thrown. If the greedy snake reaches the target edge, the advance can be stopped immediately, and the arrival position is marked as an exit. Of course, the greedy snake may also continue to advance in parallel with the destination edge for a number of steps no greater than the "maximum consecutive number" until no way is available, and the last point reached is marked as the exit. Thus, all the paths taken by the greedy snake to proceed from the entrance to the exit form the map backbone.
In an embodiment of the present invention, if the path includes at least one level of branches, the process of traversing the map block from the initial map block according to the preset traversal strategy and generating any level of branches satisfying the complexity condition parameter on the traversal trajectory is as follows.
Firstly, any map block except the starting point and the end point of the previous branch is selected as the starting point of the current branch on the previous branch.
Here, the first-level branch of the first-level branch may be a map main trunk that has been generated in the above embodiment, the first-level branch of the second-level branch is a first-level branch, the first-level branch of the third-level branch is a second-level branch, and so on.
Then, a random direction is selected as a direction for traversing the map block, and the map block is traversed in the selected direction from the starting point of the current branch. In this embodiment, if the direction traversed last time is horizontal (e.g., left and right), then this time should be random in the vertical direction (e.g., up and down), and vice versa.
And if the traversed continuous map blocks reach the preset continuous number and/or meet the condition of stopping traversal, reselecting the direction perpendicular to the last selected direction, and continuously traversing the map blocks in the reselected direction by taking the current traversed map block as a starting point until a new direction cannot be reselected or the current branch reaches the preset length, and stopping traversing the map blocks. The preset continuous number is not more than the maximum continuous number of the continuous map blocks, and the preset length is not more than the maximum length of the level to which the current branch belongs;
and finally, taking the last traversal map block when the traversal of the map block is stopped as the end point of the current branch.
In an embodiment of the present invention, the stop traversal condition may include: the map block traversed currently is at least one of a map block located at an edge of the map, a map block traversed in the selected direction, and other traversed map blocks forming a closed loop.
In the following examples, the process of generation of the first branch is described by taking the continuous progression of "greedy snake" as an example. In the embodiment of the invention, a point except for an inlet and an outlet of a main trunk on the map main trunk is selected, and a new greedy snake starts from the tail, wherein the greedy snake continuously advances, advances by a small grid every step, and has a flow similar to that of main trunk generation, but the advancing strategy is different. Referring to fig. 3, the specific generation process of the primary branch includes the following steps.
And 3.1, selecting the starting point of the current primary branch from the trunk (namely, a primary branch inlet), and advancing from the starting point of the current primary branch to the selected random direction.
In this embodiment, the start point of the current-stage branch is not overlapped with the trunk entrance and exit, and if other branches have been generated before the current-stage branch is generated, the start point and the end point of the other branches are also not overlapped. The selected random direction is perpendicular to the last selected direction.
And 3.2, judging whether the number of the forward steps in the selected direction reaches m steps. If not, executing the step 3.3; if yes, go to step 3.4.
M of this embodiment represents another preset consecutive number of consecutive ground patches set, and m is not greater than the complexity condition parameter "maximum consecutive number of consecutive ground patches".
Step 3.3, judging whether the traversal stopping condition is met, if so, executing step 3.4; if not, executing the step 3.31, continuing to go forward, and executing the step 3.61;
and 3.4, judging whether the selectable direction exists or not. If yes, go to step 3.5, reselect the direction perpendicular to the last selected direction, and go to step 3.31 (this step is to continue to go one step towards the reselected direction); if not, go to step 3.62.
Step 3.61, judging whether the number of forward steps reaches the step x of the primary branch plan, if so, executing step 3.7; if not, go to step 3.2.
Step 3.62, judging whether the number of forward steps reaches the step x of the primary branch plan, if so, executing step 3.7; if not, step 3.8 is executed, and the primary branch end point is determined to fail. Of course, the total length of the "greedy snake" needs to be greater than 1 map block. In this embodiment, if the step is one unit length, then x is not greater than the primary branch maximum length.
And 3.7, determining the current arriving position as the terminal point of the current primary branch (namely the primary branch outlet), and generating the primary branch.
Thus, a primary branch is generated on the map trunk, and then steps 3.1 to 3.7 are continuously and repeatedly executed until the number of generated primary branches reaches the maximum number of primary branches in the parameter. If the maximum number of the primary branches can not be reached in the specified number of cycles, the random map can be generated by using the currently generated primary branches. The sequence of step 3.2 and step 3.3 is not limited in the embodiments of the present invention.
The embodiment of the invention can also continue to generate the secondary branch on the basis of the primary branch already generated in the above embodiment. For example, a point except for a starting point and an end point is arbitrarily taken from any one primary branch, a new greedy snake starts from the tail of the point, the greedy snake continuously advances, the advance strategy advances by one cell every step, and the advance strategy is similar to that of the primary branch generation, but the configured condition parameters are different. For example, if the step is one unit length, the number of planning steps for generating the secondary branch is not greater than the maximum length of the secondary branch. The generation process of the secondary branch is not described in detail in the embodiment of the present invention.
In a real-time example of the present invention, the preconfigured random map complexity condition parameters further include whether a secret chamber parameter needs to be generated, and after a map trunk meeting the complexity condition parameter is generated on the traversal trajectory, if the secret chamber parameter needs to be generated is obtained, a secret chamber with a preset specification size can be randomly generated at any edge of the map. And calculating the shortest path between the map backbone and the secret room, and generating a connecting path for connecting the map backbone and the secret room on the shortest path.
For example, a 2 × 2 standard size is randomly generated on any edge of the map, such as the top, bottom, left, and right edges, and occupies 4 cells of a closed room. The distance between the map trunk and the secret room is not less than 1 map block, namely the secret room is not attached to the map trunk. The connection path may form a loop with the map trunk, and at this time, a point on the map trunk that can form a loop with the connection path needs to be deleted to avoid forming a loop.
The random map complexity condition parameter may be configured by the complexity editor before the pre-configured random map complexity condition parameter is acquired at step S102. And generating a random map example based on the random map complexity condition parameter, and displaying the generated random map example on an editing interface of the complexity editor.
The embodiment of the invention is provided with the Unity engine-based random map complexity editor, and can configure the complexity condition parameters of the random map. The complexity editor of the embodiment also provides an example preview function, and can generate a random map example according to the parameters to intuitively embody the complexity of the current parameter configuration. If the configured complexity condition parameters are modified, the displayed random map example can be adjusted in real time based on the modified random map complexity condition parameters in response to a modification instruction of the random map complexity condition parameters.
Referring to fig. 4, the random map difficulty list on the right side of the editing interface of the complex editor shows the configured complexity condition parameters. For example, the parameter values for the maximum consecutive number of consecutive tiles, the maximum number and length of primary branches, and the maximum number and length of secondary branches are all configured to be 4. The user can adjust the size of the parameter value by dragging the slide button at the corresponding parameter position, and of course, the parameter value can be directly and manually input in the frame where the parameter is displayed. The random map example generated according to the random map complexity condition parameter is displayed on the left side of the editing interface, and a user can more intuitively see the complexity of the current parameter configuration.
The embodiment of the invention can also store the configured random map complexity condition parameters, wherein the random map complexity condition parameters stored after the game is started are called. The complexity editor of the embodiment of the invention simultaneously provides an automatic saving function, and the corresponding complexity condition parameters can be saved in the Excel table, so that the complexity condition parameters can be called from the corresponding Excel table after the subsequent game is started.
In an embodiment of the present invention, in the process of analyzing connectivity of the map blocks corresponding to the generated path, whether each map block corresponding to the generated path is connected with an adjacent map block is analyzed, and if any map block is connected with an adjacent map block, any map block is marked as being connected in a direction connecting the adjacent map blocks and not connected in a direction not connecting the adjacent map blocks.
In the embodiment of the invention, the connectivity of the map block refers to which directions of the map block can be communicated with the adjacent map block and which directions can not be communicated with the adjacent map block in the four directions of up, down, left and right. For example, if there is an adjacent map block on a map block, then the connectivity of the map block is marked as "connected up", otherwise, the connectivity of the map block is "not connected up". The connectivity analysis mode of the map blocks in other directions is the same.
Since there are 4 directions for a map block, i.e. up, down, left, and right, and there are 2 cases where each direction is "connected" or "disconnected", there are 16 possibilities for a total of 2x 2x 2x 2. However, the possibility that the upper, lower, left and right are not connected is also excluded, because a map block whose periphery has no adjacent map blocks is not generated. There are 16-1 to 15 possibilities for connectivity of a map block. In addition, the embodiment of the invention can mark the connectivity of the map blocks which are not used in the map as the upper part, the lower part, the left part and the right part which are not communicated.
In an embodiment of the invention, in the process of selecting the art resources meeting the connectivity of each map block and filling the corresponding map block with the selected art resources to obtain the random map, firstly, the art resource blocks meeting the connectivity of each map block are selected. And then, filling the corresponding map blocks with the selected art resource blocks to obtain the random map. In this embodiment, one art resource block fills a corresponding one of the map blocks.
The parts which can be communicated in the art resources are 'roads', and the parts which can not be communicated are 'walls'. As shown in fig. 5, a small piece of art resource with connectivity of "left and right are connected and not connected up and down", the left and right are roads, and the upper and lower are walls.
The embodiment of the invention can select the art resources meeting the connectivity according to the connectivity of each map block, and special art resources can be used for a backroom, an entrance and an exit. And after all map blocks are filled with art resources, a complete random mosaic map can be obtained. Therefore, when the richness of the map is increased, new experience can be realized only by expanding the content of the map blocks, and the method and the device for generating the random map have the advantages of high efficiency of generating the random map and strong expandability of the generated random map.
Based on the same inventive concept, the embodiment of the invention also provides a random map generation device. Fig. 6 is a schematic structural diagram of a random map generation apparatus according to an embodiment of the present invention. Referring to fig. 6, the random map generating apparatus includes a dividing module 610, a generating module 620, an analyzing module 630, and a filling module 640.
A dividing module 610, adapted to divide an area of a random map to be generated into a plurality of map tiles, and specify an initial map tile;
the generating module 620 is adapted to obtain a preconfigured random map complexity condition parameter, traverse the map blocks from the initial map block according to a preset traversal strategy, and generate a path meeting the complexity condition parameter on a traversal track;
an analysis module 630 adapted to analyze connectivity of the map tiles corresponding to the generated paths;
and the filling module 640 is suitable for selecting the art resources meeting the connectivity of the map blocks, and filling the map blocks corresponding to the selected art resources to obtain the random map.
In an embodiment of the present invention, the preconfigured random map complexity condition parameter includes: at least one of a maximum consecutive number of consecutive tiles, a maximum number of branches of any level, and a maximum length of branches of any level.
In an embodiment of the present invention, if the path includes a map trunk, the generating module 620 is further adapted to set a map edge corresponding to the position of the initial map block as a destination edge; selecting a random direction as a direction for traversing the map blocks, and traversing the map blocks in the selected direction by taking the initial map blocks as main starting points of the map, wherein the random direction is not the reverse of the direction of the destination edge; if the traversed continuous map blocks reach the preset continuous number and/or meet the condition of stopping traversal, reselecting the direction perpendicular to the last selected direction, continuously traversing the map blocks in the reselected direction by taking the current traversed map block as a starting point, and stopping traversing the map blocks until a new direction cannot be reselected; wherein the preset continuous number is not more than the maximum continuous number of the continuous map blocks; and if the map block is traversed to the destination edge when the traversal of the map block is stopped, selecting one map block at the destination edge as a map main trunk end point.
In an embodiment of the present invention, the generating module 620 is further adapted to, if the map block is stopped to be traversed to the destination edge, take the last traversed map block as the map main end point; or if the map block is traversed to the destination edge when the traversal of the map block is stopped, continuously traversing the map blocks of the specified number along the destination edge and taking the finally traversed map block as a map main trunk end point.
In an embodiment of the present invention, if the path includes at least one level of branch, the generating module 620 is further adapted to select any map block on the previous level of branch except the starting point and the ending point of the previous level of branch as the starting point of the current branch; wherein, the upper branch of the first-level branch is a map trunk; selecting a random direction as the direction for traversing the map block, and traversing the map block from the starting point of the current branch to the selected direction; if the traversed continuous map blocks reach the preset continuous number and/or meet the condition of stopping traversal, reselecting the direction perpendicular to the last selected direction, continuously traversing the map blocks in the reselected direction by taking the current traversed map blocks as a starting point until a new direction cannot be reselected or the current branch reaches the preset length, and stopping traversing the map blocks, wherein the preset continuous number is not more than the maximum continuous number of the continuous map blocks, and the preset length is not more than the maximum length of the level to which the current branch belongs; and taking the last traversal map block when the traversal of the map block is stopped as the end point of the current branch.
In an embodiment of the present invention, the stop traversal condition includes: the map block traversed currently is a map block positioned at the edge of the map; and/or the map traversed in the selected direction forms a closed loop with other traversed maps.
In an embodiment of the present invention, the preconfigured random map complexity condition parameters further include whether a secret room parameter needs to be generated, and the method further includes connecting a secret room module, adapted to generate a map trunk meeting the complexity condition parameter on a traversal trajectory of the generating module 620, and if a secret room parameter needs to be generated, randomly generating a secret room with a preset specification size at any edge of the map; calculating the shortest path between the map trunk and the secret room, and generating a connecting path for connecting the map trunk and the secret room on the shortest path; the distance between the map trunk and the secret room is not less than one map block.
In an embodiment of the present invention, the system further includes an example module, adapted to configure the random map complexity condition parameter through the complexity editor before the generation module 620 obtains the preconfigured random map complexity condition parameter; generating a random map example based on the random map complexity condition parameter; the generated random map example is shown on an editing interface of a complexity editor.
In an embodiment of the present invention, the analysis module 630 is further adapted to analyze whether each map block corresponding to the generated path is connected with an adjacent map block; if any map block is connected with an adjacent map block, any map block is marked to be communicated in the direction of connecting the adjacent map block and not communicated in the direction of not connecting the adjacent map block.
In an embodiment of the present invention, the filling module 640 is further adapted to select an art resource block that conforms to connectivity of each map block; and filling the corresponding map blocks with the selected art resource blocks to obtain the random map, wherein one art resource block fills one corresponding map block.
According to another aspect of embodiments of the present invention, there is also provided a computer storage medium having computer program code stored thereon, which, when run on a computing device, causes the computing device to perform the random map generation method of any of the above embodiments.
According to another aspect of the embodiments of the present invention, there is also provided a computing device, including: a processor; a memory storing computer program code; the computer program code, when executed by a processor, causes a computing device to perform the random map generation method of any of the embodiments above.
It is clear to those skilled in the art that the specific working processes of the above-described systems, devices, modules and units may refer to the corresponding processes in the foregoing method embodiments, and for the sake of brevity, further description is omitted here.
In addition, the functional units in the embodiments of the present invention may be physically independent of each other, two or more functional units may be integrated together, or all the functional units may be integrated in one processing unit. The integrated functional units may be implemented in the form of hardware, or in the form of software or firmware.
Those of ordinary skill in the art will understand that: the integrated functional units, if implemented in software and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computing device (e.g., a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention when the instructions are executed. And the aforementioned storage medium includes: u disk, removable hard disk, Read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disk, and other various media capable of storing program code.
Alternatively, all or part of the steps of implementing the foregoing method embodiments may be implemented by hardware (such as a computing device, e.g., a personal computer, a server, or a network device) associated with program instructions, which may be stored in a computer-readable storage medium, and when the program instructions are executed by a processor of the computing device, the computing device executes all or part of the steps of the method according to the embodiments of the present invention.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments can be modified or some or all of the technical features can be equivalently replaced within the spirit and principle of the present invention; such modifications or substitutions do not depart from the scope of the present invention.

Claims (13)

1. A random map generation method, comprising:
dividing an area of a random map to be generated into a plurality of map blocks and designating an initial map block;
acquiring a preset random map complexity condition parameter, traversing the map blocks from the initial map block according to a preset traversal strategy, and generating a path meeting the complexity condition parameter on a traversal track;
analyzing the connectivity of the map blocks corresponding to the generated paths;
and selecting art resources which accord with the connectivity of each map block, and filling the corresponding map block with the selected art resources to obtain the random map.
2. The method of claim 1, wherein the preconfigured random map complexity condition parameter comprises:
at least one of a maximum consecutive number of consecutive tiles, a maximum number of branches of any level, and a maximum length of branches of any level.
3. The method of claim 2, wherein if the path includes a map backbone, traversing a map tile from the initial map tile according to a predetermined traversal strategy, and generating a path on a traversal trajectory that satisfies the complexity condition parameter, comprises:
setting a map edge opposite to the initial map block position as a destination edge;
selecting a random direction as a direction for traversing the map blocks, and traversing the map blocks in the selected direction by taking the initial map blocks as main starting points of the map, wherein the random direction is not opposite to the direction of the destination edge;
if the traversed continuous map blocks reach the preset continuous number and/or meet the condition of stopping traversal, reselecting the direction perpendicular to the last selected direction, continuously traversing the map blocks in the reselected direction by taking the current traversed map block as a starting point, and stopping traversing the map blocks until a new direction cannot be reselected; wherein the preset continuous number is not more than the maximum continuous number of the continuous map blocks;
and if the map block is traversed to the destination edge when the traversal of the map block is stopped, selecting one map block as a map main trunk terminal at the destination edge.
4. The method of claim 3, wherein if the destination edge is reached after stopping traversing the map tiles, selecting a map tile at the destination edge as a map stem end point comprises:
if the map block is traversed to the destination edge when the traversal of the map block is stopped, taking the finally traversed map block as a map main terminal point; or
And if the destination edge is traversed when the traversal of the map blocks is stopped, continuously traversing the map blocks of the specified number along the destination edge and taking the finally traversed map blocks as map main destination points.
5. The method of claim 3, wherein if the path includes at least one level of branches, traversing the map tile from the initial map tile according to a predetermined traversal strategy, and generating a path on the traversal trajectory that satisfies the complexity condition parameter, comprises:
selecting any map block except the starting point and the end point of the previous branch as the starting point of the current branch on the previous branch; wherein, the upper branch of the first-level branch is a map trunk;
selecting a random direction as the direction for traversing the map block, and traversing the map block from the starting point of the current branch to the selected direction;
if the traversed continuous map blocks reach the preset continuous number and/or meet the traversal stopping condition, reselecting the direction perpendicular to the last selected direction, continuously traversing the map blocks in the reselected direction by taking the current traversed map block as a starting point, and stopping traversing the map blocks until a new direction cannot be reselected or the current branch reaches the preset length; the preset continuous number is not more than the maximum continuous number of the continuous map blocks, and the preset length is not more than the maximum length of the level to which the current branch belongs;
and taking the last traversal map block when the traversal of the map block is stopped as the end point of the current branch.
6. The method of claim 5, wherein the stop traversal condition comprises:
the map block traversed currently is a map block positioned at the edge of the map; and/or
The map block traversed in the selected direction forms a closed loop with other traversed map blocks.
7. The method of claim 3, wherein the preconfigured random map complexity condition parameters further include whether a secret room parameter needs to be generated, and after generating a map trunk satisfying the complexity condition parameter on the traversal trajectory, further comprising:
if the secret room parameters needing to be generated are obtained, randomly generating a secret room with a preset specification size at any edge of the map;
calculating the shortest path between the map trunk and the secret room, and generating a connecting path for connecting the map trunk and the secret room on the shortest path;
wherein, the distance between the map trunk and the secret room is not less than one map block.
8. The method according to any one of claims 1-7, wherein before obtaining the pre-configured random map complexity condition parameter, further comprising:
configuring a random map complexity condition parameter through a complexity editor;
generating a random map example based on the random map complexity condition parameter;
displaying the generated random map example on an editing interface of the complexity editor.
9. The method of any one of claims 1-7, wherein analyzing connectivity of map tiles corresponding to the generated paths comprises:
analyzing whether each map block corresponding to the generated path is connected with an adjacent map block or not;
if any map block is connected with an adjacent map block, the map blocks are marked to be communicated in the direction of connecting the adjacent map blocks and not communicated in the direction of not connecting the adjacent map blocks.
10. The method as claimed in any one of claims 1 to 7, wherein selecting art resources corresponding to the connectivity of each map block, and populating the corresponding map block with the selected art resources to obtain the random map comprises:
selecting art resource blocks which accord with the connectivity of each map block;
and filling the corresponding map blocks with the selected art resource blocks to obtain the random map, wherein one art resource block fills one corresponding map block.
11. A random map generation apparatus, comprising:
the dividing module is suitable for dividing an area of the random map to be generated into a plurality of map blocks and appointing an initial map block;
the generating module is suitable for acquiring a preconfigured random map complexity condition parameter, traversing the map blocks from the initial map block according to a preset traversal strategy, and generating a path meeting the complexity condition parameter on a traversal track;
the analysis module is suitable for analyzing the connectivity of the map blocks corresponding to the generated paths;
and the filling module is suitable for selecting the art resources which accord with the connectivity of the map blocks, and filling the map blocks corresponding to the selected art resources to obtain the random map.
12. A computer storage medium storing computer program code which, when run on a computing device, causes the computing device to perform the random map generation method of any of claims 1-10.
13. A computing device, comprising: a processor; a memory storing computer program code; the computer program code, when executed by the processor, causes the computing device to perform the random map generation method of any of claims 1-10.
CN202111146365.1A 2021-09-28 2021-09-28 Random map generation method and device, storage medium and computing equipment Pending CN113827976A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111146365.1A CN113827976A (en) 2021-09-28 2021-09-28 Random map generation method and device, storage medium and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111146365.1A CN113827976A (en) 2021-09-28 2021-09-28 Random map generation method and device, storage medium and computing equipment

Publications (1)

Publication Number Publication Date
CN113827976A true CN113827976A (en) 2021-12-24

Family

ID=78967242

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111146365.1A Pending CN113827976A (en) 2021-09-28 2021-09-28 Random map generation method and device, storage medium and computing equipment

Country Status (1)

Country Link
CN (1) CN113827976A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6347995B1 (en) * 1999-09-30 2002-02-19 Konami Corporation Method, computer-readable storage medium and video game device for automatically generating a maze map with at least one correct path
CN105597318A (en) * 2015-12-25 2016-05-25 珠海金山网络游戏科技有限公司 Method, system and device for automatically generating random game scenes
CN107126702A (en) * 2017-04-20 2017-09-05 杭州游聚信息技术有限公司 A kind of generation method of 3D game Random map
CN108108410A (en) * 2017-12-12 2018-06-01 苏州蜗牛数字科技股份有限公司 A kind of online game labyrinth ground drawing generating method
US10037324B1 (en) * 2012-11-02 2018-07-31 Electronic Arts Inc. Stochastic chunk-based map generation
CN109675313A (en) * 2018-12-24 2019-04-26 网易(杭州)网络有限公司 The generation method and device of random game map, electronic equipment, storage medium
CN111185009A (en) * 2020-01-02 2020-05-22 腾讯科技(深圳)有限公司 Map generation method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6347995B1 (en) * 1999-09-30 2002-02-19 Konami Corporation Method, computer-readable storage medium and video game device for automatically generating a maze map with at least one correct path
US10037324B1 (en) * 2012-11-02 2018-07-31 Electronic Arts Inc. Stochastic chunk-based map generation
CN105597318A (en) * 2015-12-25 2016-05-25 珠海金山网络游戏科技有限公司 Method, system and device for automatically generating random game scenes
CN107126702A (en) * 2017-04-20 2017-09-05 杭州游聚信息技术有限公司 A kind of generation method of 3D game Random map
CN108108410A (en) * 2017-12-12 2018-06-01 苏州蜗牛数字科技股份有限公司 A kind of online game labyrinth ground drawing generating method
CN109675313A (en) * 2018-12-24 2019-04-26 网易(杭州)网络有限公司 The generation method and device of random game map, electronic equipment, storage medium
CN111185009A (en) * 2020-01-02 2020-05-22 腾讯科技(深圳)有限公司 Map generation method and device

Similar Documents

Publication Publication Date Title
CN110772791B (en) Route generation method, device and storage medium of three-dimensional game scene
CN108694266A (en) intelligent decoration design method and system based on machine learning
CN109163722B (en) Humanoid robot path planning method and device
CN110322694A (en) A kind of method and device of urban traffic control piece Division
CN110288688B (en) Virtual vegetation rendering method and device, storage medium and electronic equipment
CN112486202A (en) Air route editing method and device and control equipment
CN112884256B (en) Path planning method and device, computer equipment and storage medium
CN110505452B (en) Capital construction power transmission project progress monitoring method and monitoring system
CN109506654A (en) Low latitude Route planner and device, aircraft
CN111135574A (en) Game scene generation method and device, computer readable medium and electronic equipment
CN103034267B (en) Apparatus and a method for controlling facility devices
CN109155846A (en) Three-dimensional reconstruction method and device of scene, electronic equipment and storage medium
CN114935942A (en) Method for determining inspection route of distributed photovoltaic power station and electronic equipment
CN107798182A (en) A kind of quick calculating of base station radiation scope and update method
CN104408662B (en) Power network drawing methods based on circuit orthogonal packing algorithm
CN113827976A (en) Random map generation method and device, storage medium and computing equipment
CN106991714A (en) Outdoor scene threedimensional model and three-dimensional simulation model mix-loaded method
CN113223141B (en) Circular ring type inclined shooting method and system
KR20050078670A (en) Method for auto-detecting edges of building by using lidar data
CN117762591A (en) Task control method, task control device, computer device, and storage medium
CN115830207B (en) Three-dimensional scene roaming method, device, equipment and medium
CN109568959A (en) A kind of method for supporting a large amount of units pathfinding simultaneously in game
CN108564637A (en) Geometrical model arrangement method and device
CN109190861B (en) Nuclear power station maintenance path planning method and device
CN114419239A (en) Automatic cutting method and device for power transmission line channel oblique photography tower model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination