CN111494958B - Method and device for randomly generating maze map - Google Patents

Method and device for randomly generating maze map Download PDF

Info

Publication number
CN111494958B
CN111494958B CN202010313093.9A CN202010313093A CN111494958B CN 111494958 B CN111494958 B CN 111494958B CN 202010313093 A CN202010313093 A CN 202010313093A CN 111494958 B CN111494958 B CN 111494958B
Authority
CN
China
Prior art keywords
road block
dimensional
dimensional road
grid
block
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.)
Active
Application number
CN202010313093.9A
Other languages
Chinese (zh)
Other versions
CN111494958A (en
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.)
Individual
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to CN202010313093.9A priority Critical patent/CN111494958B/en
Publication of CN111494958A publication Critical patent/CN111494958A/en
Application granted granted Critical
Publication of CN111494958B publication Critical patent/CN111494958B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The application discloses a method and a device for randomly generating a maze map. One embodiment of the method comprises the following steps: selecting a grid of the grid space as a starting point; randomly selecting a three-dimensional road block from a road block set, placing the three-dimensional road block at a starting point, wherein the area of the road block is an integer multiple of a grid, and corresponds to a artistic skin, selecting a three-dimensional road block from the set based on the direction of an unused outlet channel of the current road block, placing the three-dimensional road block in front of the outlet channel, updating the newly placed road block into the current road block, and continuously repeating the steps to expand the road until the new road block cannot be placed in front of all the outlet channels of the current road block; the previous three-dimensional road blocks are continuously traced in sequence, the unused outlet channel with the new road block placed in front of the outlet channel is updated to be the current road block, and the steps are repeated to expand the road. And when all the road blocks cannot expand the new road blocks, the maze map generation is completed. The method has low complexity and high efficiency.

Description

Method and device for randomly generating maze map
Technical Field
The present application relates to the field of information processing technologies, and in particular, to a maze game, and in particular, to a method and apparatus for randomly generating a maze map.
Background
The existing method for generating the maze map is generally an expanded road of a grid by a grid, defines the gate and the path of the grid, and defines corresponding artistic skin resources for each grid.
Disclosure of Invention
The present application aims to propose an improved method and device for randomly generating a maze map, which solve the technical problems mentioned in the background section.
In a first aspect, the present application provides a method of randomly generating a maze map, the method comprising: selecting a grid as a starting point in the grid space; randomly selecting a three-dimensional road block from the road block set, and placing the three-dimensional road block at a starting point grid, wherein each three-dimensional road block is provided with an inlet channel and at least one outlet channel, the size of the area of the three-dimensional road block is an integer multiple of that of a grid, and the area corresponds to a fine arts skin; selecting a three-dimensional road block from the road block set according to a preset rule based on the direction of an unused outlet channel of the current road block, placing the three-dimensional road block on an unoccupied grid in front of the outlet channel, communicating the outlet channel with an inlet channel of the newly placed three-dimensional road block to form a passage, updating the newly placed three-dimensional road block into the current road block, and continuously repeating the step until the new three-dimensional road block cannot be placed in front of all the unused outlet channels of the current road block; sequentially and continuously tracing and judging whether an unused outlet channel exists in the previously placed three-dimensional road block or not until a previous three-dimensional road block is found to exist the unused outlet channel and a grid in front of the unused outlet channel can place a new three-dimensional road block, updating the previous three-dimensional road block into a current road block, and jumping to execute the previous step; if any one of the three-dimensional road blocks in the road block set cannot be placed before the unused outlet channel in all the three-dimensional road blocks in the grid space, the three-dimensional maze map generation is completed.
In some embodiments, the method further comprises: and mapping the three-dimensional road blocks in the road block set into two-dimensional data in advance according to the mapping rule.
In some embodiments, the method further comprises: when the direction of the three-dimensional road block placed in the maze space is rotated, corresponding rotation operation is carried out on two-dimensional data corresponding to the three-dimensional road block, and the three-dimensional maze map is serialized into two-dimensional data, so that the position and the space motion state of the virtual ball in the three-dimensional maze map can be calculated according to the two-dimensional data conveniently.
In some embodiments, the method further comprises: the art effect skin corresponding to the three-dimensional road block includes but is not limited to: a complete organ skin, a complete obstacle skin, an ambient skin with multiple mesh areas.
In some embodiments, the method further comprises: grid space is generated in advance according to the level of the checkpoint.
In some embodiments, selecting a three-dimensional road block from the road block set according to a preset rule, and placing the three-dimensional road block on an unoccupied grid in front of the exit channel, where the method includes: and selecting a three-dimensional road block from the road block set at random without repeating, judging whether the three-dimensional road block can be placed on an unoccupied grid in front of the outlet channel of the current road block according to the size and the shape of the three-dimensional road block, and if not, continuously repeating the steps until the selected three-dimensional road block can be placed on the unoccupied grid in front of the outlet channel of the current road block.
In some embodiments, the inability to place a new three-dimensional road block before an unused exit channel of the current road block includes: there is no unoccupied grid before the exit channel of the current road block that is unused, i.e. the exit channel is opposite to the edge of the grid space or to the three-dimensional road blocks that have been placed in the grid space, and the unoccupied grid before the exit channel of the current road block that is unused cannot accommodate any one of the three-dimensional road blocks in the set of drop blocks.
In some embodiments, the method further comprises: and calculating the grid path distance from the starting point to the end point and the branch number of the maze map, and if the grid path distance from the starting point to the end point and the branch number are within the threshold range of corresponding data of the level of the checkpoint corresponding to the maze map, qualifying the maze map.
In a second aspect, the present application provides an apparatus for randomly generating a maze map, the apparatus comprising: a starting point selection unit configured to select a grid as a starting point in the grid space; the starting point road block selecting unit is configured to randomly select a three-dimensional road block from the road block set and place the three-dimensional road block at a starting point grid, wherein each three-dimensional road block is provided with an inlet channel and at least one outlet channel, the size of the three-dimensional road block is an integer multiple of one grid, and the three-dimensional road block corresponds to one artistic skin; the road extension unit of the current road block is configured to select a three-dimensional road block from the road block set according to a preset rule based on the direction of an unused outlet channel of the current road block, the three-dimensional road block is placed on an unoccupied grid in front of the outlet channel, and the outlet channel is communicated with an inlet channel of the newly placed three-dimensional road block to form a passage; the trace back support expansion branch unit is configured to continuously trace back and judge whether an unused outlet channel exists in the previously placed three-dimensional road blocks in sequence until a previous three-dimensional road block is found to have the unused outlet channel and a new three-dimensional road block can be placed on a grid in front of the unused outlet channel, then the previous three-dimensional road block is updated to be a current road block, and the current road block road expansion road unit is executed in a jumping mode; and a decision maze generation completion unit configured to complete generation of a three-dimensional maze map if any one of the set of road blocks cannot be placed before an unused exit channel among all three-dimensional road blocks in the mesh space.
In some embodiments, the apparatus further comprises: and the mapping unit is configured to map the three-dimensional road blocks in the road block set into two-dimensional data in advance according to a mapping rule.
In some embodiments, the apparatus further comprises: and the rotation operation unit is used for carrying out corresponding rotation operation on the two-dimensional data corresponding to the three-dimensional road blocks when the directions of the three-dimensional road blocks placed in the labyrinth space are rotated due to the directivity of the three-dimensional road blocks in the road block set, serializing the three-dimensional labyrinth map into two-dimensional data, and calculating the position and the space motion state of the virtual ball in the three-dimensional labyrinth map according to the two-dimensional data.
According to the method for randomly generating the labyrinth map, the inlet channel and the outlet channel of each three-dimensional road block are predefined, the road is continuously expanded in a grid space by adopting a mode of communicating the outlet channel of the previous three-dimensional road block with the inlet channel of the next three-dimensional road block, under the condition that the road cannot be expanded, each branch road is continuously and backwardly expanded, algorithm complexity is low, the size of the area of each three-dimensional road block is integral multiple of one grid, the object in the labyrinth map is combined with the uniform and inseparable artistic skin requirement, corresponding artistic skin is designed for each three-dimensional road block in advance, and when the three-dimensional road blocks are spliced into the labyrinth map, the corresponding artistic skin forms a visual labyrinth map picture, and the algorithm complexity is low and the efficiency is high.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings, in which:
FIG. 1 is a flow chart of one embodiment of a method of randomly generating a maze map of the present application;
2-1-2-24 are schematic diagrams of a process of generating a maze map in one embodiment of a method of randomly generating a maze map of the present application;
FIG. 3 is a schematic diagram of a three-dimensional ramp block and its two-dimensional data in one embodiment of a method of randomly generating a maze map of the present application;
FIG. 4 is a schematic diagram of a three-dimensional right turn block and its two-dimensional data in one embodiment of a method of randomly generating a maze map of the present application;
FIG. 5-1 is a schematic diagram of stitching three-dimensional right turn road blocks, three-dimensional ramp road blocks in one embodiment of a method of randomly generating a maze map of the present application;
FIG. 5-2 is a schematic diagram of two-dimensional data of a spliced three-dimensional right turn road block and a three-dimensional slope road block in one embodiment of a method for randomly generating a maze map of the present application;
FIG. 6 is a schematic structural diagram of one embodiment of an apparatus for randomly generating a maze map of the present application.
Detailed Description
The present application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
FIG. 1 illustrates a flow chart of one embodiment of a method of randomly generating a maze map of the present application. As shown, the method comprises the steps of:
step 101, selecting a grid as a starting point in the grid space.
In this embodiment, different levels of checkpoints in the maze game correspond to maze maps of different difficulty coefficients. Different levels of checkpoints sometimes correspond to different grid spaces and the same level of checkpoints supports a plurality of different grid spaces. The grid space is composed of grids of the same size, and it is also understood that the grid space is composed of square blocks of the same size. A maze map is then generated within the grid space.
In this embodiment, the grid requirement corresponding to each level of the gateway is specified, for example, the number of grids must be within a certain interval, and the distance between any two grids in the grid space cannot exceed a certain threshold. In this embodiment, therefore, it is necessary to previously select the level of the checkpoint, and generating a grid space meeting the grid requirements corresponding to the level of the gateway. The shape of the grid space includes, but is not limited to: triangular, quadrilateral, hexagonal, and irregular.
In other alternative implementations of the present embodiment, the developer may autonomously create grid space for designing a more complex maze. For example, there is a large grid space where the grids are all unselected, and the developer forms an effective grid space by clicking and/or delineating some grids, together with the clicked and/or delineating grids. Facilitating the design of labyrinths that are more personalized and/or subject-specific.
In this embodiment, a grid is randomly selected from the grid space as a starting point. Or selecting a grid as a starting point according to a preset rule, for example, uniformly selecting the grid at the bottom left as the starting point.
Step 102, randomly selecting a three-dimensional road block from the road block set and placing the three-dimensional road block at the starting point grid.
In this embodiment, a set of road blocks is designed in advance, where the road blocks in the set of road blocks are three-dimensional road blocks, each three-dimensional road block has an inlet channel and at least one outlet channel, and the orthographic projection size of the three-dimensional road block is an integer multiple of a grid. In addition, each three-dimensional road block corresponds to one artistic skin or each three-dimensional road block has one artistic skin. The art effect skin includes, but is not limited to: a complete office skin, a complete barrier skin, an environmental skin with multiple mesh areas, for example, a three-dimensional road block art effect skin may be an office conveyor, a complete house, a swimming pool, a rotating stair, etc. The artistic effect is designed in advance, and then, the three-dimensional road block is mapped into two-dimensional data according to a preset rule by combining the artistic effect and the occupied grid. According to the designed maze theme, a road block set of different themes can be selected. For example, a set of road blocks for urban topics, a set of road blocks for island topics, a set of road blocks for forest topics, a set of road blocks for indoor topics. The three-dimensional road blocks in the road block set have artistic effect skins of corresponding subjects.
In other optional implementations of this embodiment, the road blocks in the road block set are two-dimensional road blocks, where each two-dimensional road block has one entrance channel and at least one exit channel, and the size of the two-dimensional road block is an integer multiple of one grid. The method is also suitable for generating the two-dimensional maze map.
In this embodiment, a three-dimensional road block is randomly selected from the three-dimensional road block set and placed at the starting point grid. And then taking the three-dimensional road block placed at the starting point grid as the current road block.
Step 103, selecting a three-dimensional road block from the road block set based on the direction of the unused outlet channel of the current road block according to a preset rule, placing the three-dimensional road block on an unoccupied grid in front of the outlet channel, and enabling the outlet channel to be communicated with an inlet channel of the newly placed three-dimensional road block to form a passage so as to update the newly placed three-dimensional road block into the current road block.
In this embodiment, since each three-dimensional road block has at least one exit channel, a three-dimensional road block is randomly selected from a road block set based on the direction of an unused exit channel of the current road block or guided, and the shape and size of the three-dimensional road block are used to determine whether the unoccupied grid in front of the exit channel can accommodate the newly selected three-dimensional road block, if the unoccupied grid in front of the exit channel can accommodate the newly selected three-dimensional road block, the newly selected three-dimensional road block is placed in the unoccupied grid in front of the exit channel, the exit channel is communicated with the entrance channel of the newly placed three-dimensional road block to form a path, and the newly placed three-dimensional road block is updated to the current road block. Where the grid is occupied, it means that three-dimensional road blocks have been placed on the grid.
If the unoccupied mesh in front of the exit channel cannot accommodate the newly selected three-dimensional road block. For example, the current road block is located at the leftmost lower part of a square grid space, and the selected three-dimensional road block is a left-turning three-dimensional road block, and the left-turning three-dimensional road block is not accommodated by the grid which is not occupied in front of the current three-dimensional road block. And only randomly selecting an unselected three-dimensional road block from the road block set, judging whether the three-dimensional road block can be placed on the unoccupied grid in front of the outlet channel according to the shape and the size of the three-dimensional road block, and continuously and randomly selecting the unselected three-dimensional road block until the selected three-dimensional road block can be placed on the unoccupied grid in front of the current outlet channel. The outlet channel is communicated with the inlet channel of the newly placed three-dimensional road block to form a passage, and the newly placed three-dimensional road block is updated to be the current road block.
Step 104, a new three-dimensional road block can be placed before the unused outlet channel exists in all the unused outlet channels of the current road block.
In this embodiment, in some cases, a new three-dimensional road block cannot be placed before the exit channel where the current road block is not used. Including but not limited to the following: there is no unoccupied mesh in front of the exit channel that is not used by the current road block, i.e. the exit channel is against the edge of the mesh space or against the wall of the three-dimensional road block that has been placed in the mesh space; the unoccupied grid before the exit channel that is not used for the current road block cannot accommodate any three-dimensional road block in the set of road blocks.
In this embodiment, the current road block has at least one exit channel, if an unoccupied grid in front of an unused exit channel of the current three-dimensional road block can accommodate a new three-dimensional road block, the process goes to step 103, and the new three-dimensional road block is extended by splicing outwards based on the unused exit channel. In this way, on the basis of meeting the above conditions, steps 103 and 104 are continuously and circularly executed, so that the path of the road in the grid space is continuously expanded and lengthened, and until a new three-dimensional road block can be placed before all unused outlet channels of the current road block, the road is cut off, and a new branch needs to be opened, namely, step 105 is executed.
Step 105, continuously tracing and judging whether an unused outlet channel exists in the previous three-dimensional road block in sequence until finding that the unused outlet channel exists in the previous three-dimensional road block and a grid in front of the unused outlet channel can place a new three-dimensional road block, and updating the previous three-dimensional road block into the current road block.
In this embodiment, since it is determined in step 104 that a new three-dimensional road block can be placed in front of all the unused exit channels of the current road block, the new three-dimensional road block cannot be continuously spliced on the basis of the current road block, and if the road is cut off, the road is required to be reversely pushed backwards, and whether the previously spliced three-dimensional road block has the conditions of outward expansion and formation of a new branch is continuously traced. I.e. continuously tracing and judging whether an unused outlet channel exists in the previous three-dimensional road block, and updating the previous three-dimensional road block into the current road block if a new three-dimensional road block can be placed on a grid in front of the unused outlet channel. The jump is continuously and circularly executed in step 103 and step 104, and the current road block is taken as a branch to be continuously and outwards expanded to form a new branch. Until the branch does not support splicing of new three-dimensional road blocks and cannot be spliced and expanded outwards, step 105 is re-executed, the previous three-dimensional road blocks of the latest expandable new branch are continuously traced back in sequence, and then step 103 is executed in a jumping mode.
In this embodiment, it is found through continuous tracing: if a new three-dimensional road block cannot be placed before the unused exit channel in all three-dimensional road blocks in the grid space, step 106 is performed.
Step 106, if any one of the three-dimensional road blocks in the road block set cannot be placed before the unused outlet channel in all the three-dimensional road blocks in the grid space, the maze map generation is completed.
In this embodiment, a plurality of three-dimensional road blocks exist in the grid space, and these three-dimensional road blocks form a plurality of connected roads, which are limited by the small and scattered number of unoccupied grids in the grid space, each road cannot be extended and lengthened outwards, and all three-dimensional road blocks in these roads also do not support the extension of new branches outwards, which means that the grid space is saturated and the generation of the maze map is completed.
In this embodiment, the three-dimensional road block with the mesh path furthest from the start point is selected as the end point. And then, calculating the grid path distance from the starting point to the end point and the branch number of the maze map, and if the grid path distance from the starting point to the end point and the branch number are within the threshold range of the corresponding data of the checkpoint level, qualifying the maze map. Otherwise, the method is re-executed to generate a new maze map.
In other optional implementations of the present embodiment, the developer is supported to select an endpoint, and branches with grid distances smaller than a certain value in the maze map may be deleted to present a more compact maze map. Or by the developer decides which roads in the maze map to delete.
The method adopts a three-dimensional road block splicing mode, the length of a road is continuously expanded in a grid space, in addition, new branches are continuously expanded in a sequential tracing mode, and a complex maze map is finally generated. And each three-dimensional road block is provided with the skin with the artistic effect, after the three-dimensional road blocks are spliced together in a non-overlapping way, the corresponding skin with the artistic effect forms a visual maze map picture, and the algorithm is low in complexity and high in efficiency.
With continued reference to fig. 2-1 through 2-24, the above figures illustrate a schematic process for generating a maze map. For ease of understanding, the number of three-dimensional road blocks of the road block set of this embodiment is set to 2. As shown in fig. 2-1, the left side of the graph is the generated grid space of 8 times 8, the right side is a set of road blocks, the set of road blocks consists of two three-dimensional road blocks of a straight three-dimensional road block and a branch three-dimensional road block, the lower side of the straight three-dimensional road block is an inlet channel, the upper side is an outlet channel, and one grid is occupied. The lower side of the branch three-dimensional road block is an inlet channel, the left side and the right side of the upper side are two outlet channels, and two grids are occupied. As shown in fig. 2-2, the grid at the lower left of the grid space is selected as the starting grid, and then the straight three-dimensional road blocks randomly selected from the road block set are placed at the starting grid. Based on the exit channel of the straight three-dimensional road block, the branch three-dimensional road blocks randomly selected from the road block set are placed on unoccupied grids in front of the current road block, as shown in fig. 2-3. Because the outlet channel on the left side of the branch three-dimensional road block faces the boundary of the grid space, unoccupied grids do not exist in front of the outlet channel, and any three-dimensional road block cannot be placed, the outlet channel on the right side of the branch three-dimensional road block is expanded outwards. As shown in fig. 2-4, straight three-dimensional road blocks are randomly selected from the set of road blocks and placed on an unoccupied grid in front of the exit channel. Then, as shown in fig. 2-5, based on the exit channel of the straight three-dimensional road block, the branch three-dimensional road block selected randomly from the road block set is placed on the unoccupied grid before the exit channel. Then, as shown in fig. 2-6, based on the outlet channel below the branch three-dimensional road block, the straight three-dimensional road block selected from the road block set is placed on the unoccupied grid before the outlet channel. Then, as shown in fig. 2-7, based on the exit channel of the current straight three-dimensional road block, the branch three-dimensional road block is selected from the road block set, and because the branch three-dimensional road block needs to occupy two grids, but only one three-dimensional road block is in front of the exit channel of the current straight three-dimensional road block, the branch three-dimensional road block cannot be accommodated, so that other three-dimensional road blocks, namely, the selected straight three-dimensional road block, need to be selected from the road block set without repetition and are placed on the grids which are not occupied before the exit channel. Because any three-dimensional road block cannot be put down when the exit channel of the straight three-dimensional road block faces the boundary of the grid space, and in addition, because the straight three-dimensional road block does not have other unused exit channels for expanding the road outwards, the straight three-dimensional road block can only be traced back continuously until the branch three-dimensional road block is traced back, the branch three-dimensional road block is found to have an unused exit channel, and the straight three-dimensional road block is selected from the road block set to be placed on the grid which is unoccupied before the exit channel based on the direction of the unused exit channel of the branch three-dimensional road block, as shown in 2-8. And then, as shown in fig. 2-9, based on the outlet channel of the current straight three-dimensional road block, placing the branch three-dimensional road block selected from the road block set on an unoccupied grid in front of the outlet channel. The current branch three-dimensional road block is provided with two outlet channels, the outlet channel on the left of the branch three-dimensional road block is selected randomly, the straight three-dimensional road block is selected randomly from the road block set based on the outlet channel on the left, and the straight three-dimensional road block is placed on an unoccupied grid in front of the outlet channel, as shown in fig. 2-10. Then, as shown in fig. 2-11, based on the current straight three-dimensional road block outlet channel, the branch three-dimensional road blocks are randomly selected and placed on the unoccupied grid before the outlet channel. From the two outlet channels of the current branch three-dimensional road block, randomly selecting the lower outlet channel, placing a random selected straight three-dimensional road block on the unoccupied grid in front of the outlet channel, then placing another straight three-dimensional road block in front of the outlet channel of the straight three-dimensional road block, as shown in fig. 2-12, the outlet channel of the newly placed straight three-dimensional road block is close to the wall of one placed three-dimensional road block, cannot accommodate any one of the three-dimensional road blocks, tracing back the previous three-dimensional road block, tracing back to the last placed branch three-dimensional road block and further having an unused outlet channel, and placing the randomly selected straight three-dimensional road block on the unoccupied grid in front of the outlet channel, as shown in fig. 2-13. Continuing to base the exit channel of the straight three-dimensional road block, an attempt was made to place the straight three-dimensional road block only in front of the exit channel, as shown in fig. 2-14. Since the exit channel of the current straight three-dimensional road block faces the boundary of the grid space, no new three-dimensional road block can be placed, and no other unused exit channel exists in the straight three-dimensional road block, the straight three-dimensional road block needs to be traced back until a branch three-dimensional road block is found to have an unused exit channel, and as shown in fig. 2-15, a straight three-dimensional road block is expanded based on the unused exit channel of the branch three-dimensional road block. Then, as shown in fig. 2-16, a branched three-dimensional road block is expanded based on the exit channel of the straight three-dimensional road block. Then, as shown in fig. 2-17, a straight three-dimensional road block is spliced and expanded outwards based on the randomly selected upward outlet channel. Then, based on the outlet channel of the straight three-dimensional road block, a straight three-dimensional road block is expanded outwards, as shown in fig. 2-18, because the only outlet channel of the current straight three-dimensional road block faces the boundary of the grid space and cannot be expanded outwards, the three-dimensional road block which is placed before tracing is required to trace back to the branch three-dimensional road block, as shown in fig. 2-19, based on the unused outlet channel of the branch three-dimensional road block, a straight three-dimensional road block is expanded outwards and spliced, and then, based on the outlet channel of the straight three-dimensional road block, a branch three-dimensional road block is expanded outwards, as shown in fig. 2-20. Then, as shown in fig. 2-21, a straight three-dimensional road block is expanded based on the outlet channel on the left side of the branched three-dimensional road block. Then, as shown in fig. 2-22, another straight three-dimensional road block is expanded over the exit channel of the straight three-dimensional road block. The exit channels of the newly placed straight three-dimensional road blocks are opposite to the walls of the placed three-dimensional road blocks and cannot be spliced outwards. And if the previous three-dimensional road block is followed, 2-23 is shown, and a straight three-dimensional road block is expanded and spliced based on an unused outlet channel of the traced branch three-dimensional road block. The exit channel of the straight three-dimensional road block faces the boundary of the grid space, and any three-dimensional road block cannot be placed. Tracing the previous three-dimensional road blocks, finding that any three-dimensional road block in the lower road block set cannot be placed before the unused outlet channel of all the previous three-dimensional road blocks, and indicating that the generation of the maze map is completed. The one grid furthest from the grid of the starting grid is selected as the end point, and in fig. 2-24, the grid with dots in the middle of the grid represents the end point grid. The grid distance from the start point to the end point is 16, and the number of branches of the maze map is 6.
The method for randomly generating the maze map can be used for generating the two-dimensional maze map. Whether a two-dimensional maze map or a three-dimensional maze map is generated, it is necessary to map three-dimensional road blocks in a road block set into two-dimensional data. Therefore, on the screen of the intelligent terminal, a maze map picture formed by splicing the artistic effect skins of the three-dimensional road blocks is displayed to a user, and when the space motion state of the small ball in the maze is calculated, two-dimensional data calculation of the maze map is adopted. The algorithm is simple, occupies fewer resources, is more efficient, and has short time and better instantaneity. The space motion state of the small ball comprises: strike, roll, stop. In this embodiment, the three-dimensional road block is mapped into two-dimensional data according to a mapping rule. Small three-dimensional road blocks of flat, uphill, downhill, and stepped are denoted by different numbers.
Referring to fig. 3, a three-dimensional ramp block and its two-dimensional data are shown. The three-dimensional slope road block is provided with a slope, a small ball can accelerate to slide down on the slope, and the acceleration direction of the small ball is required to be determined by the slope direction, so that four directions of the slope need to be distinguished in a two-dimensional data space. If defined in two dimensions: the longitudinal direction is north in the positive y-axis direction, the downward direction is south in the negative y-axis direction, the transverse direction is east in the positive x-axis direction, and the left direction is west in the negative x-axis direction. Further, it is assumed that the slope is 2 in north, 3 in west, 4 in south, and 5 in east. Therefore, the direction of the slope can be represented in the two-dimensional data space, and the space motion state of the ball in the maze can be calculated conveniently. Other three-dimensional road blocks with directional properties are processed using this method.
In this embodiment, to reduce the amount of computation, coordinates of the inlet channels of all three-dimensional road blocks are uniformly set to be in the (0, 0) direction, that is, north in the positive direction of the Y axis. The data of the three-dimensional road block of the upper graph is normalized, and the two-dimensional data of the three-dimensional road block is: (0, 0) =1, (0, 1) =2, (0, 2) =1, and the exit data is (0, 3), north.
With continued reference to fig. 4, this figure is a three-dimensional right turn block and its two-dimensional data. According to the mapping rule, the two-dimensional data of the three-dimensional right turn road block are as follows: (0, 0) =1, (0, 1) =1, (1, 1) =1, the exit data is: (2, 1), east. The direction of the outlet channel and the direction of the inlet channel of the three-dimensional right-turning road block are different, so that the three-dimensional road block connected with the three-dimensional right-turning road block next can be rotated.
With continued reference to fig. 5-1 and 5-2, there are spliced three-dimensional road blocks and their two-dimensional data, respectively. As shown, the three-dimensional ramp road block is spliced behind the three-dimensional right turn road block. The outlet channel of the three-dimensional right turn road block is connected with the inlet channel of the three-dimensional slope road block. The exit data of the three-dimensional right turn block in the figure are: (2, 1), east, so the starting point of the three-dimensional slope road block is translated from the (0, 0) point to the (2, 1), and the inlet direction of the three-dimensional slope road block is changed from north to east, so that the position of the three-dimensional slope road block and the content of the two-dimensional data are determined. A key problem exists in the process of splicing the two three-dimensional road blocks: how to rotate the three-dimensional road block and the rotation operation.
Defining the direction a rotated by direction B as the direction a left-hand direction B corresponds to the multiplication of the quaternion. For example: from east to north, both: north = (0, 1) = (0,0.7071068,0,0.7071068) = (0,0.7071068,0,0.7071068) = east. In order to reduce the amount of computation when generating the maze randomly, values are defined for four directions: north=0, west=1, south=2, east=3, which allows the rotation of the direction to be the sum of the values. For example: from east to north, both: east+north= (3+1)%4=3%4=3=east. The default slope north corresponding value in the upper graph is 2 and the slope forward value to be rotated is 5. The bifurcated three-dimensional road blocks can be spliced in the same way.
The three-dimensional road blocks in the road block set are mapped into two-dimensional data in advance, the directions of the three-dimensional road blocks are set, and when the directions of the three-dimensional road blocks placed in the maze grid are rotated, corresponding rotation operation is carried out on the two-dimensional data of the three-dimensional road blocks. The three-dimensional maze map is generated randomly, each three-dimensional road block corresponds to one two-dimensional data, so that the three-dimensional maze map can be serialized into a two-dimensional array, and the data storage amount and the calculation amount in the process of calculating the positions and the postures of the virtual balls in the virtual maze are reduced.
With further reference to FIG. 6, as an implementation of the method illustrated in the above figures, the present application provides one embodiment of an apparatus for randomly generating a maze map. As shown in the figure, the apparatus for randomly generating a maze map according to the present embodiment includes: a starting point selection unit 601, a starting point road block selection unit 602, a current road block expansion road unit 603, a trace back support expansion branch unit 604, and a decision maze generation completion unit 605. The starting point selecting unit 601 is configured to select a grid as a starting point in the grid space; a starting point road block selecting unit 602 configured to randomly select a three-dimensional road block from the road block set and place the three-dimensional road block at the starting point grid, wherein each three-dimensional road block has an inlet channel and at least one outlet channel, and the size of the three-dimensional road block is an integer multiple of one grid; the current road block road expansion unit 603 is configured to select a three-dimensional road block from the road block set according to a preset rule based on the direction of an unused outlet channel of the current road block, and place the three-dimensional road block in front of the outlet channel, where the outlet channel is communicated with an inlet channel of the selected three-dimensional road block to form a channel; a trace back support expansion branch unit 604, configured to sequentially and continuously trace back and determine whether an unused exit channel exists in a previous three-dimensional road block, until a previous three-dimensional road block is found to have an unused exit channel and any three-dimensional road block in the road block set can be placed by a grid in front of the unused exit channel, update the previous three-dimensional road block as a current road block, and jump to execute the current road block expansion road unit 603; the maze generation completion unit 605 is configured to complete maze map generation if a new three-dimensional road block cannot be placed before an unused exit channel of all three-dimensional road blocks in the mesh space.
In this embodiment, the current road block is updated continuously, and the three-dimensional road block newly placed in the grid space is called a current road block, and the current road block road expansion unit 603 is configured to select a three-dimensional road block from the road block set based on the direction of the unused exit channel of the current road block, and place the three-dimensional road block in the unoccupied grid in front of the exit channel. That is, the current road block road expansion unit 603 is continuously executed, and three-dimensional road blocks are continuously spliced in the range of the grid space based on the newly placed three-dimensional road blocks, so that roads are expanded.
In this embodiment, if any three-dimensional road block in the set of lower road blocks cannot be placed before all the unused exit channels of the current road block, it is indicated that the road no longer supports expansion, then the traceback support expansion branch unit 604 is executed, and the traceback support expansion branch unit 604 is configured to trace back the previous three-dimensional road block, determine that the previous three-dimensional road block support does not support expansion of a branch road, that is, whether there is an unused exit channel in the previous three-dimensional road block, and the grid in front of the unused exit channel can place a certain three-dimensional road block in the set of lower road blocks. If expansion of one branch road is supported, the jump execution current road block expansion road unit 603 expands the branch road.
In this embodiment, if the trace back support extension branching unit 604 traces back all the three-dimensional road blocks already placed in the grid space, and determines that no new three-dimensional road block can be placed before the unused exit channel in all the three-dimensional road blocks, that is, so that none of the three-dimensional road blocks support continuing to extend and splice the new three-dimensional road blocks, the decision maze generation completion unit 605 is executed, and the decision maze map generation is determined to be completed.
In this embodiment, the road blocks in the road block set are three-dimensional road blocks, and are divided according to the directions of the inlet channel and the outlet channel of the three-dimensional road blocks, and the three-dimensional road block packet blocks are not limited to: a straight three-dimensional road block, a left-turning three-dimensional road block, a right-turning three-dimensional road block, a three-branch three-dimensional road block and a cross three-dimensional road block, wherein each three-dimensional road block comprises, but is not limited to, the following small three-dimensional road blocks: flat small three-dimensional road blocks, ascending small three-dimensional road blocks, descending small three-dimensional road blocks and step small three-dimensional road blocks.
In another optional implementation manner of this embodiment, the apparatus for randomly generating a maze map further includes: the system comprises a mapping unit and a rotation operation unit, wherein the mapping unit is configured to map three-dimensional road blocks in a road block set into two-dimensional data in advance according to a mapping rule. And the rotation operation unit is configured to be used for carrying out corresponding rotation operation on the two-dimensional data of the three-dimensional road blocks when the directions of the three-dimensional road blocks placed in the maze grid are rotated. The three-dimensional road block is described in a two-dimensional data form, so that the calculation and the storage of the generated maze map are facilitated.
The foregoing description is only of the preferred embodiments of the present application and is presented as a description of the principles of the technology being utilized. It will be appreciated by persons skilled in the art that the scope of the invention referred to in this application is not limited to the specific combinations of features described above, but it is intended to cover other embodiments in which any combination of features described above or equivalents thereof is possible without departing from the spirit of the invention. Such as the above-described features and technical features having similar functions (but not limited to) disclosed in the present application are replaced with each other.

Claims (11)

1. A method of randomly generating a maze map, the method comprising:
selecting a grid as a starting point in the grid space;
randomly selecting a three-dimensional road block from the road block set, and placing the three-dimensional road block at a starting point grid, wherein each three-dimensional road block is provided with an inlet channel and at least one outlet channel, the size of the area of the three-dimensional road block is an integer multiple of that of a grid, and the area corresponds to a fine arts skin;
selecting a three-dimensional road block from the road block set according to a preset rule based on the direction of an unused outlet channel of the current road block, placing the three-dimensional road block on an unoccupied grid in front of the outlet channel, communicating the outlet channel with an inlet channel of the newly placed three-dimensional road block to form a passage, updating the newly placed three-dimensional road block into the current road block, and continuously repeating the step until the new three-dimensional road block cannot be placed in front of all the unused outlet channels of the current road block;
sequentially and continuously tracing and judging whether an unused outlet channel exists in the previously placed three-dimensional road block or not until a previous three-dimensional road block is found to exist the unused outlet channel and a grid in front of the unused outlet channel can place a new three-dimensional road block, updating the previous three-dimensional road block into a current road block, and jumping to execute the previous step;
if any one of the three-dimensional road blocks in the road block set cannot be placed before the unused outlet channel in all the three-dimensional road blocks in the grid space, the three-dimensional maze map generation is completed.
2. The method of randomly generating a maze map of claim 1, further comprising:
and mapping the three-dimensional road blocks in the road block set into two-dimensional data in advance according to the mapping rule.
3. The method of randomly generating a maze map of claim 2, further comprising:
when the direction of the three-dimensional road block placed in the grid space is rotated, corresponding rotation operation is carried out on two-dimensional data corresponding to the three-dimensional road block, and the three-dimensional maze map is serialized into two-dimensional data, so that the position and the space motion state of the virtual small ball in the three-dimensional maze map can be calculated according to the two-dimensional data conveniently.
4. A method of randomly generating a maze map as in any one of claims 1-3 further comprising:
the art effect skin corresponding to the three-dimensional road block includes but is not limited to: a complete organ skin, a complete obstacle skin, an ambient skin with multiple mesh areas.
5. The method of randomly generating a maze map of claim 1, further comprising:
grid space is generated in advance according to the level of the checkpoint.
6. The method for randomly generating a maze map according to claim 1, wherein the selecting a three-dimensional road block from the road block set based on the direction of the unused outlet channel of the current road block according to a preset rule, and placing the three-dimensional road block on the unoccupied grid in front of the outlet channel comprises:
and selecting a three-dimensional road block from the road block set at random without repeating, judging whether the three-dimensional road block can be placed on an unoccupied grid in front of the outlet channel of the current road block according to the size and the shape of the three-dimensional road block, and if not, continuously repeating the steps until the selected three-dimensional road block can be placed on the unoccupied grid in front of the outlet channel of the current road block.
7. The method of randomly generating a maze map of claim 6, wherein a new three-dimensional road block cannot be placed before an exit channel where the current road block is not used, comprising:
there is no unoccupied mesh before the exit channel that is not used for the current road block, i.e. the exit channel is against the edge of the mesh space or against a three-dimensional road block that has been placed in the mesh space,
the unoccupied grid before the exit channel that is not used for the current road block cannot accommodate any three-dimensional road block in the set of road blocks.
8. The method of randomly generating a maze map of claim 7, further comprising:
and calculating the grid path distance from the starting point to the end point and the branch number of the maze map, and if the grid path distance from the starting point to the end point and the branch number are within the threshold range of corresponding data of the level of the checkpoint corresponding to the maze map, qualifying the maze map.
9. An apparatus for randomly generating a maze map, the apparatus comprising:
a starting point selection unit configured to select a grid as a starting point in the grid space;
the starting point road block selecting unit is configured to randomly select a three-dimensional road block from the road block set and place the three-dimensional road block at a starting point grid, wherein each three-dimensional road block is provided with an inlet channel and at least one outlet channel, the size of the three-dimensional road block is an integer multiple of one grid, and the three-dimensional road block corresponds to one artistic skin;
the road extension unit of the current road block is configured to select a three-dimensional road block from the road block set according to a preset rule based on the direction of an unused outlet channel of the current road block, the three-dimensional road block is placed on an unoccupied grid in front of the outlet channel, and the outlet channel is communicated with an inlet channel of the newly placed three-dimensional road block to form a passage;
the trace back support expansion branch unit is configured to continuously trace back and judge whether an unused outlet channel exists in the previously placed three-dimensional road blocks in sequence until a previous three-dimensional road block is found to have the unused outlet channel and a new three-dimensional road block can be placed on a grid in front of the unused outlet channel, then the previous three-dimensional road block is updated to be a current road block, and the current road block road expansion road unit is executed in a jumping mode;
and a decision maze generation completion unit configured to complete generation of a three-dimensional maze map if any one of the set of road blocks cannot be placed before an unused exit channel among all three-dimensional road blocks in the mesh space.
10. The apparatus for randomly generating a maze map of claim 9, further comprising:
and the mapping unit is configured to map the three-dimensional road blocks in the road block set into two-dimensional data in advance according to a mapping rule.
11. The apparatus for randomly generating a maze map according to claim 9 or 10, wherein the apparatus further comprises:
and the rotation operation unit is used for carrying out corresponding rotation operation on the two-dimensional data corresponding to the three-dimensional road blocks when the directions of the three-dimensional road blocks placed in the grid space are rotated due to the directivity of the three-dimensional road blocks in the road block set, serializing the three-dimensional labyrinth map into two-dimensional data, and calculating the position and the space motion state of the virtual ball in the three-dimensional labyrinth map according to the two-dimensional data.
CN202010313093.9A 2020-04-20 2020-04-20 Method and device for randomly generating maze map Active CN111494958B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010313093.9A CN111494958B (en) 2020-04-20 2020-04-20 Method and device for randomly generating maze map

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010313093.9A CN111494958B (en) 2020-04-20 2020-04-20 Method and device for randomly generating maze map

Publications (2)

Publication Number Publication Date
CN111494958A CN111494958A (en) 2020-08-07
CN111494958B true CN111494958B (en) 2023-06-16

Family

ID=71874388

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010313093.9A Active CN111494958B (en) 2020-04-20 2020-04-20 Method and device for randomly generating maze map

Country Status (1)

Country Link
CN (1) CN111494958B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112473136B (en) * 2020-11-27 2022-01-11 完美世界(北京)软件科技发展有限公司 Map generation method and device, computer equipment and computer readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1088574A2 (en) * 1999-09-30 2001-04-04 Konami Corporation Method, computer-readable storage medium and video game device for automatically generating a maze map with at least one correct path
CN108108410A (en) * 2017-12-12 2018-06-01 苏州蜗牛数字科技股份有限公司 A kind of online game labyrinth ground drawing generating method
CN109954275A (en) * 2019-02-27 2019-07-02 黄冈师范学院 A kind of three-dimensional labyrinth Random Generation

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1088574A2 (en) * 1999-09-30 2001-04-04 Konami Corporation Method, computer-readable storage medium and video game device for automatically generating a maze map with at least one correct path
CN108108410A (en) * 2017-12-12 2018-06-01 苏州蜗牛数字科技股份有限公司 A kind of online game labyrinth ground drawing generating method
CN109954275A (en) * 2019-02-27 2019-07-02 黄冈师范学院 A kind of three-dimensional labyrinth Random Generation

Also Published As

Publication number Publication date
CN111494958A (en) 2020-08-07

Similar Documents

Publication Publication Date Title
US10922882B2 (en) Terrain generation system
EP3882865A1 (en) Object loading method, device, storage medium, and electronic device
US9262853B2 (en) Virtual scene generation based on imagery
CN107220372B (en) A kind of automatic laying method of three-dimensional map line feature annotation
CN106251391A (en) Divided method
KR102216749B1 (en) Method, apparatus and computer program for coloring of a target image
US9324032B2 (en) Method of creating a computer model of the physical world
CN114177613B (en) Navigation grid updating method, device, equipment and computer readable storage medium
US8970622B2 (en) System and method for placing objects across a surface of a graphics object
CN111494958B (en) Method and device for randomly generating maze map
CN113750516A (en) Method, system and equipment for realizing three-dimensional GIS data loading in game engine
CN109985386B (en) Method and device for generating map
CN111524231A (en) Virtual terrain processing method and device, electronic equipment and storage medium
Fisher et al. Designing intentional impossible spaces in virtual reality narratives: A case study
CN114404984A (en) Data processing method and device for game scene, computer equipment and medium
Kim et al. Bema: A multimodal interface for expert experiential analysis of political assemblies at the Pnyx in ancient Greece
CN115888081A (en) Virtual road network generation method and device, storage medium and electronic equipment
CN105894560B (en) A kind of method of image procossing, user equipment and system
CN114528305A (en) Vector data updating range determining method and device, electronic equipment and storage medium
KR100916219B1 (en) Method of setting a grid for making 3-d video
CN113181655B (en) Terrain construction method, terrain construction device, electronic equipment and storage medium
WO2023216771A1 (en) Virtual weather interaction method and apparatus, and electronic device, computer-readable storage medium and computer program product
CN117808949B (en) Scene rendering method
Osipov et al. Algorithms of automation of 3D modeling of urban environment objects using attributive information from a digital map
Ho et al. Fame, soft flock formation control for collective behavior studies and rapid games development

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
GR01 Patent grant
GR01 Patent grant