Detailed Description
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct combination or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated into two processing units, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in two computer readable storage media. 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 computer device (which may be 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. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It will be understood by those within the specification of the present application that terms such as "first," "second," "A," "B," and the like, if not specifically stated, do not denote a limitation of order. For example, "step three" may precede "step one," and "D" may also be performed simultaneously with "a".
Aiming at the defects of the prior art, the current situation and the caused reasons of the realization of a common circle ground system are deeply analyzed, the specific requirements of circle ground filling are analyzed and developed, a set of circle ground filling method is summarized to meet the circle ground filling requirement for supporting multi-region sealing, and the high efficiency of algorithm filling is achieved through minimum surrounding regions and mark filling.
First, the coordinates of the filled grid and the walking trajectory grid are acquired. The game map is illustratively represented by a two-dimensional planar coordinate system or a three-dimensional coordinate system, and in the case of a two-dimensional planar coordinate system, the grid of each map has an abscissa x and an ordinate y, i.e., each grid is represented by a unique coordinate (x, y). And acquiring coordinates (x, y) of all filled grids and walking track grids on the map in a traversal mode, and storing the coordinates in a stack in a two-dimensional numerical value form to be used as a territory list.
Second, a minimum bounding region is created. Creating two-dimensional temporary coordinates topLeft (topleft.x, topleft.y) and bottomRight (bottomright.x, bottomright.y), assigning the first grid of the existing territory list to the coordinates topLeft and bottomRight, traversing all the existing territory grid lists and the walking track grid list, taking the current grid as grid.x, grid.y, and if grid.x < topleft.x, topleft.x is grid.x; if grid.y < topleft.y, topleft.y is grid.y; if grid.x > bottomright.x, bottomright.x is grid.x; if grid.y > bottomright.y, bottomright.y is grid.y; until all the grids are traversed. The area formed by the coordinates topLeft to bottomRight is the minimum bounding area. All enclosed areas that can be filled are inside the minimum enclosed area. By determining the minimum enclosing area, the number of traversals for the next area can be effectively reduced, so that the efficiency is improved, and meanwhile, the filled boundary range is defined, namely, once an area (not including the walking track) is the boundary containing the minimum enclosing area, the area is not a closed area. So that later on the seed filling it can be used as a basis to determine whether the area is a closed area. In addition, when the leader list still has the lattice coordinates which are not traversed after one minimum enclosing area is created, a new lattice coordinate is selected, a second minimum enclosing area is created, and the process is repeated, the leader list is divided into a plurality of minimum enclosing areas until all lattices in the leader list are contained in the respective minimum enclosing areas.
Again, the seed to be subsequently filled in the traversal is determined. Since the walking track varies widely and a plurality of closed areas can be formed, and meanwhile, the closed areas need to be associated with the walking track, the seeds in the formed closed areas cannot be directly given. That is, given any one cell in a minimum bounding area, there is no way to know whether the cell is in the enclosed area associated with the track. However, it is known that all the closed regions are in the minimum enclosing region, and here, only eight connected grids flag, namely, upper, lower, left, right, upper left, lower left, upper right, and lower right corresponding to each walking track grid, need to be marked as 1, and used as seeds to be filled and traversed subsequently. Thus, a seed list is obtained, and the flag of the corresponding grid of the seed list is 1. Although the seed list contains some seeds of the non-closed area, all seeds of the closed area which may be associated with the track are also in the seed list, so that in the subsequent filling and marking process, only the seeds of the non-closed area need to be identified and not be filled and marked, and all the seeds in the closed area need to be filled and marked. The 4 connected lattices and 8 connected lattices corresponding to each track lattice are shown in fig. 2.
FIG. 2 is a schematic diagram illustrating a 4-way and 8-way grid according to one or more embodiments of the present invention; wherein a of fig. 2 represents a 4-way lattice, B of fig. 2 represents an 8-way lattice, a solid circle represents a lattice as a base point, an open circle represents a lattice adjacent to the base point lattice, and a connection line connects the base point lattice and the adjacent lattice in a communicating relationship. From the basic point, if any adjacent grids in the arrival area are searched only in the four directions of up, down, left and right, the area filled by the method is called a four-connected domain, and the filled grid is called a 4-connected grid. If starting from the base point, all eight directions reach any adjacent grids in the area through up, down, left, right, left upper, left lower, right upper and right lower, the area filled by the method is called eight-connected domain, and the filled grid is called 8-connected grid. The shape of the lattice itself is not particularly limited, and the lattice may be circular, rectangular, regular hexagonal, regular octagonal, or the like. As can be seen from fig. 2, the 8-way grid has a higher degree of freedom of communication than the 4-way grid, when the walking paths of the game characters intersect to form two closed sections, when the 4-way grid is adopted, two closed areas cannot be connected via the communication relationship between unfilled grids, and when the 8-way grid is adopted, this problem does not exist.
In this example, the 8-connected grids are adopted instead of the 4-connected grids for seed marking because there is a case that there is a closed region in the oblique direction of the trace grid, and the adoption of the 4-connected grids may result in missing seeds of the closed region associated with the trace, so that the subsequent filling mark may miss the closed region. For example, referring to fig. 3, fig. 3 is a schematic diagram illustrating a 4-way grid and an 8-way grid filling multiple zones in accordance with one or more embodiments of the present invention. Where C of fig. 3 represents a plurality of areas filled with 4-way lattices, D of fig. 3 represents a plurality of areas filled with 8-way lattices according to the present invention, solid circles represent lattices serving as base points of a starting point, open solid line circles represent a walking path of a game character, and open dotted line circles represent areas filled with a four-way connected seed filling algorithm, it can be seen that when the area filling is performed with the 4-way connected seed filling algorithm, only 6 open dotted line circular lattices of a lower left closed area are filled, and an upper right closed area is omitted, and the filling range is erroneous. When the 8-direction communication method of the embodiment of the invention is adopted for region filling, the 6 hollow dotted line circular lattices filled in the lower left closed region and the 6 hollow dotted line circular lattices filled in the upper right closed region are all correctly filled, and the filling accuracy is improved.
Next, the closed area is filled, and the filling and marking process is described as follows:
a. setting a current mark variable CurrentSeedFlag to be 2 initially (the mark of the grid is 1, which indicates that the seed needs to be traversed), creating a mark closed list SeedColsedFlags for storing the marks which can be filled (namely the mark number of the grid in the mark closed list indicates that the grid can be filled in the closed area), traversing the grid in the minimum range area from the top left to the bottom right, and starting the algorithm;
b. and taking the next grid in the minimum range area as the current grid, if the current grid is marked as 1 (namely, a seed), performing a marking process on the current grid in a recursion mode, and turning to c. If no next lattice exists, turning f;
c. the marking process begins: if the mark of the grid is CurrentSeedFlag (indicating that the mark is traversed), directly returning to true; if the label of the grid is-1 (indicating that the non-closed area marked by the identification label is already), directly returning failure; if the lattice is on the minimum bounding region boundary or outside the boundary (indicating in the non-enclosed region), label the lattice as-1 and return a failure; otherwise, the grid is marked as CurrentSeedFlag; and acquiring the grids in the four-connection direction of the current grid, and if the existing grid is neither the existing territory grid nor the track grid, recursively marking each grid. If a certain grid marking process in the recursion fails to return, marking the grid as-1 and returning to fail, thereby finally exiting the marking process of the outermost layer, and turning to d; if no lattice marking process returns failure, indicating that the initial current lattice is in the closed area, marking all lattices in the closed area as CurrentSeedFlag, finally exiting the outermost marking process, and turning to e;
d. when the current grid marking process fails, adding 1 to the current marking variable CurrentSeedFlag, and then continuing to switch to b;
e. adding a current marking variable CurrentSeedFlag into a marked closed list SeedColsedFlags, adding 1 to the current marking variable CurrentSeedFlag, and continuing to switch to b;
f. at this point, the filling mark process is ended.
After the completion of the padding flag flow, the flag list seedclosdflags that can be padded is output. The last step is to traverse each grid in the minimum enclosing area, take down the grid as the current grid, if the mark list SeedClosedFlags contains the mark of the current grid or the current grid belongs to the grid of the walking track, the current grid belongs to the grid in the closed area, and then fill the grid into the grid of the current grid until all the grids are traversed. After the flow is finished, all the related closed areas in the walking track can be filled into the territory of the user.
FIG. 4 is a graph illustrating an actual machine effect fill effect in accordance with one or more embodiments of the invention. In fig. 4E, the dark band-shaped area indicates the travel track of the game character, and as can be seen from the figure, the map is divided into two closed areas and one semi-closed area by the adjacent travel track section. F of fig. 4 shows the result of filling in the area in the game map using the method of the embodiment of the present invention on the basis of E of fig. 4. The solid portion is the player's own territory that is filled.
The disclosed embodiment has the following beneficial effects:
1. supporting a circle fill requirement for a map having a plurality of enclosed areas;
the general seed filling method and other filling methods only fill one area, and the land circle filling method in the embodiment can meet the requirement of filling under the condition of sealing multiple areas, so that the accuracy of land circle filling is improved.
2. High efficiency of method fill is achieved by minimum bounding area and marker fill;
the circle filling method in the embodiment firstly determines the minimum enclosing area to be filled to reduce the traversal range, and marks the lattices in the filling process to avoid repeated judgment processing, so that the circle filling efficiency is effectively improved.
According to a second embodiment of the present invention, there is provided an area filling apparatus of a game map, including: a first module that acquires coordinates of the filled lattices and the walking trajectory lattices; a second module that creates a minimal bounding region; a third module that marks an enclosed area within the minimum enclosing area; a fourth module that fills an enclosed area, wherein a minimum bounding area covers coordinates of the filled grid and a walking trajectory grid.
Further, the second module includes the following sub-modules: a first sub-module creating temporary coordinates topLeft and bottomRight; the second submodule traverses the coordinates of the filled grids and the walking track grids, takes the coordinate of the current grid as grid, and assigns a value topleft.x to grid.x if grid.x is less than topleft.x; if grid.y is less than topleft.y, assigning topleft.y to grid.y; if grid.x > bottomright.x, assigning bottomright.x to grid.x; if grid.y > bottomright.y, assigning bottomright.y to grid.y; and the third sub-module establishes a minimum enclosing area based on the coordinates topLeft to the coordinates bottomRight after traversing all the filled grids and the coordinates of the walking track grids.
Further, the grid is a grid with 8 communication directions.
According to a third embodiment of the invention, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method of the first aspect of the invention.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.