The content of the invention
In order to solve one or more defects set forth above, according to the first aspect of the invention, a kind of trip is provided
The area filling method of play map, comprises the following steps:A. the coordinate of the grid having been filled with and run trace grid is obtained;B. create
Build minimum enclosing region;C. in minimum enclosing region internal labeling closed area;D. closed area is filled, wherein, minimum surrounds area
The grid and the coordinate of run trace grid being had been filled with described in the covering of domain.
Further, step B further includes following sub-step:Create temporal coordinate topLeft and bottomRight;Traversal
The grid and the coordinate of run trace grid having been filled with, and the coordinate of wherein current grid is taken as grid, if grid.x<
TopLeft.x, then assignment topLeft.x=grid.x;If grid.y<TopLeft.y, then assignment topLeft.y=
grid.y;If grid.x>BottomRight.x, then assignment bottomRight.x=grid.x;If grid.y>
BottomRight.y, then assignment bottomRight.y=grid.y;When all grid having been filled with of traversal and run trace lattice
After the coordinate of son, minimum enclosing region is established based on coordinate topLeft to coordinate bottomRight.
Further, the grid is the grid with 8 unicom directions.
According to the second aspect of the invention, a kind of area filling device of map is provided, including:First mould
Block obtains the coordinate of the grid having been filled with and run trace grid;Second module creates minimum enclosing region;3rd mould
Block, in minimum enclosing region internal labeling closed area;4th module fills closed area, wherein, minimum enclosing region is covered
The grid and the coordinate of run trace grid being had been filled with described in lid.
Further, the second module includes following submodule:First submodule, create temporal coordinate topLeft and
bottomRight;The second submodule, travels through the coordinate of the grid having been filled with and run trace grid, and takes wherein current grid
Coordinate for grid, if grid.x<TopLeft.x, then assignment topLeft.x=grid.x;If grid.y<
TopLeft.y, then assignment topLeft.y=grid.y;If grid.x>BottomRight.x, then assignment
BottomRight.x=grid.x;If grid.y>BottomRight.y, then assignment bottomRight.y=grid.y;The
Three submodules, after the coordinate of all grid having been filled with and run trace grid is traveled through, based on coordinate topLeft to coordinate
BottomRight establishes minimum enclosing region.
Further, grid is the grid with 8 unicom directions.
According to the third aspect of the present invention, a kind of computer readable storage medium is provided, is stored thereon with computer
Program, the method that the first aspect of the present invention is realized when which is executed by processor.
The invention has the advantages that:Support the filling demand of enclosing the land of the map with multiple closed areas, so as to
Improve the accuracy and adaptability for filling of enclosing the land.It is filled by minimum enclosing region and mark, is effectively improved to enclose the land and fill out
The efficiency filled.
Specific embodiment
Those of ordinary skill in the art may realize that each exemplary lists described with reference to the embodiments described herein
Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually
It is performed with hardware or software mode, specific application and design constraint depending on technical solution.Professional technician
Described function can be realized using distinct methods to each specific application, but this realization is it is not considered that exceed
The scope of the present invention.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and unit may be referred to the corresponding process in preceding method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed systems, devices and methods, it can be with
It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the unit
Division is only a kind of division of logic function, can there is other dividing mode, such as multiple units or component in actual implementation
It may be combined or can be integrated into another system or some features can be ignored or does not perform.It is another, it is shown or
The mutual coupling that discusses or to be directly harmonious or communicate to connect can be indirect coupling by some interfaces, device or unit
It closes or communicates to connect, can be electrical, machinery or other forms.
The unit illustrated as separating component may or may not be physically separate, be shown as unit
The component shown may or may not be physical location, you can be located at a place or can also be distributed to multiple
In network element.Some or all of unit therein can be selected to realize the mesh of this embodiment scheme according to the actual needs
's.
In addition, each functional unit in each embodiment of the present invention can be integrated in two processing units, it can also
That unit is individually physically present, can also two or more units integrate in a unit.
If the function is realized in the form of SFU software functional unit and is independent production marketing or in use, can be with
It is stored in two computer read/write memory mediums.Based on such understanding, technical scheme is substantially in other words
The part contribute to the prior art or the part of the technical solution can be embodied in the form of software product, the meter
Calculation machine software product is stored in a storage medium, is used including some instructions so that a computer equipment (can be
People's computer, server or network equipment etc.) perform all or part of the steps of the method according to each embodiment of the present invention.
And foregoing storage medium includes:USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited
The various media that can store program code such as reservoir (RAM, Random Access Memory), magnetic disc or CD.
It will be appreciated by those skilled in the art that in the description of the present application, " first ", " secondly ", " first ", "
Two ", the terms such as " A ", " B ", are not offered as the limitation to sequencing unless otherwise stated.For example, " step 3 " can be in " step
Before rapid one ", " D " can also be carried out at the same time with " A ".
The present invention is directed to the defects of prior art, and the present situation and the reason for causing of system realization of generally enclosing the land are goed deep into
Analysis, analysis exploitation summarize a set of fill method of enclosing the land, multizone closing are supported to reach to the specific requirements for filling of enclosing the land
Filling demand of enclosing the land, by minimum enclosing region and mark filling come reach algorithm fill high efficiency.
First, the coordinate of the grid having been filled with and run trace grid is obtained.It is illustratively flat by two dimension in map
Areal coordinate system or three-dimensional system of coordinate represent, by taking two-dimensional plane coordinate system as an example, the grid of each map has abscissa x and vertical seat
Y is marked, i.e., each grid is represented by unique coordinate (x, y).In a manner of traversal, the grid having been filled with all on map is obtained
It with the coordinate (x, y) of run trace grid, and is stored in the form of two Dimension Numerical Value in storehouse, as manor list.
Secondly, minimum enclosing region is created.Create two dimension temporal coordinate topLeft (topLeft.x, topLeft.y) and
BottomRight (bottomRight.x, bottomRight.y) takes existing first grid assignment of manor list to coordinate
TopLeft and bottomRight, all existing manor grid lists and run trace grid list under traversal take wherein current
Grid is grid (grid.x, grid.y), if grid.x<TopLeft.x, then topLeft.x=grid.x;If grid.y
<TopLeft.y, then topLeft.y=grid.y;If grid.x>BottomRight.x, then bottomRight.x=
grid.x;If grid.y>BottomRight.y, then bottomRight.y=grid.y;Until having traveled through all grid.It sits
Mark topLeft to the coordinate bottomRight regions formed be exactly minimum enclosing region.All closed areas that can be filled
All inside minimum enclosing region.It can be not only the grid number for efficiently reducing traversal below by definite minimum enclosing region
So as to improve efficiency, while the bounds of filling is also drawn a circle to approve, i.e., once it is to include most (not including run trace) to have region
The border of small enclosing region, then the region is not closed area.It so below can be in this, as when seed filling
According to judging whether the region is closed area.In addition, after a minimum enclosing region is created, still have in the list of manor
When having the grid coordinate without traversal, optional one new grid coordinate creates the second minimum enclosing region, so repeatedly, high-ranking military officer
Ground list is divided into multiple minimum enclosing regions, until the possessive case in the list of manor is included into each minimum enclosing region
It is interior.
Again, to determine subsequently to fill the seed of traversal.Since the track of walking is ever-changing, and can be formed multiple
Closed area, while closed area also needs to be associated with run trace, causes the multiple envelopes having no idea directly to being shaped as
Seed in closed region.Any one grid in an i.e. given minimum enclosing region, has no idea whether to learn the grid
In the associated closed area in track.All closed areas are but had been known at this time all in minimum enclosing region, this
In only need the connection of upper and lower, left and right, upper left, lower-left, upper right, bottom right this eight corresponding to the track grid of each walking
Grid flag labeled as 1, as the seed that subsequently fill traversal.Thus obtain seed list, seed list
The flag of corresponding grid is 1.Although containing the seed in some non-close regions in seed list, it is possible to and rail
The seed of the associated closed area of mark also all in seed list, only needs to identify non-envelope during so follow-up filling-tag
The seed of closed region does not do filling-tag, and all does filling-tag to the seed in closed area.Each track grid
Corresponding 4 connection grid and 8 connection grid are as shown in Figure 2.
Fig. 2 is to represent one or more 4 unicom of embodiment according to the present invention and the schematic diagram of 8 unicom grid;Wherein
The A of Fig. 2 represents the grid of 4 unicom, and the B of Fig. 2 represents the grid of 8 unicom, and solid circles are denoted as the grid of basic point, open circles
Shape is denoted as the grid adjacent with basic point grid, the link relation of connecting line basic point grid and adjacent grid.Go out from basic point
Hair, if searching for the grid for reaching the arbitrary neighborhood in region simply by upper and lower, left and right four direction, in this way
The region of filling is known as four connected region, and this filling grid is known as " 4 unicom grid ".If from basic point, by it is upper,
Under, left and right, upper left, lower-left, all eight directions reach the grid of the arbitrary neighborhood in regions for upper right and bottom right, then this side
The region of method filling is known as eight connected region, and this filling grid is known as " 8 unicom grid ".In addition, the shape to grid in itself
Shape is not particularly limited, and grid can be circle, rectangle, regular hexagon, octagon etc..As shown in Figure 2, the lattice of 8 unicom
Son than 4 unicom grid have higher connection degree of freedom, when game role walking path intersect, form two closure
Section when using 4 unicom grid, can not connect two closed areas via the link relation that is not filled by between grid, when adopting
With then there is no this problems during 8 unicom grid.
Seed tag is done using 8 connection grid rather than using 4 connection grid in this example, is because there are track grid is oblique
The situation of direction Shang Yeyou closed areas, and use 4 connection grid that may then cause to miss the associated closed area in track
Seed, then follow-up filling-tag can miss the closed area.Referring for example to Fig. 3, Fig. 3 is to represent according to the present invention one
The schematic diagram of 4 unicom grid of a or multiple embodiments and 8 unicom grid filling multiple regions.The C of wherein Fig. 3 represents 4 unicom
The multiple regions of grid filling, the D of Fig. 1 represent the filling multiple regions of 8 unicom grid according to the present invention, and solid circles represent
The grid of basic point as starting point, the circular walking path for representing game role of hollow solid line, hollow dashed circle represent warp
Cross the region of four-way connection seed fill algorithm filling, it can be seen that fill out when carrying out region to connection seed fill algorithm using 4
When filling, 6 hollow dashed circle grid of lower-left enclosed region have been only filled with, and have missed out the enclosed region in upper right side, have been filled
Scope it is wrong.When the 8 of the method for embodiment using the present invention carries out area filling to connection method, it is filled with lower-left and closes
6 hollow dashed circle grid for closing 6 hollow dashed circle grid in region and the enclosed region in upper right side are obtained for just
True filling improves the accuracy rate of filling.
Next filling closed area, filling-tag flow are described below:
A. current markers variable CurrentSeedFlag settings being initially 2, (mark of grid is to have represented it is to need
The seed to be traveled through), newly-built one is stored mark closing list SeedColsedFlags (the i.e. marks of grid that can be filled
Number then represents that the grid can be filled in closed area in mark closes list), it is minimum from traversal left to bottom right
Grid in range areas, algorithm start;
B. next grid in minimum zone region is taken as current grid, if current grid (is kind labeled as 1
Son), it is possible to flow is marked to current grid recurrence, turns c.If there is no next grid, turn f;
C. mark flow starts:If the mark of grid is (showing to have stepped through labeled),
Directly return to true;If the mark of grid is 1 (showing it has been the labeled non-close region of identification), directly return
Failure;If grid is (to show on minimum enclosing region border or outside border in non-close region), grid is marked
For -1, and return to failure;Otherwise grid is labeled as CurrentSeedFlag;Obtain the lattice in four communication directions of current grid
Son, if there is grid neither having manor grid nor track grid, then then each grid is marked in recurrence
Flow.If there are some grid mark flows in recurrence to return to failure, by grid labeled as -1, and failure is returned to, so as to
Outermost mark flow is finally exited, turns d at this time;Failure is returned if there is no some grid mark flow, is shown initially
Current grid be in closed area, the grid in closed area has been collectively labeled as CurrentSeedFlag, finally exits
Outermost mark flow, turns e at this time;
D. current grid mark flow failure, adds 1 to current markers variable CurrentSeedFlag, then proceedes to turn b;
E. current markers variable CurrentSeedFlag is added in mark closing list SeedColsedFlags, and
1 is added to current markers variable CurrentSeedFlag, then proceedes to turn b;
So far, filling-tag flow is terminated.
The mark list SeedClosedFlags that can be filled is outputed after filling-tag flow.Last step
It is each grid in the minimum enclosing region of traversal, it is current grid to remove a grid, if mark list
Mark or current grid that SeedClosedFlags includes current grid belong to the grid of run trace, then then current lattice
Son just belongs to the grid in closed area, the grid of oneself is at this moment filled with into, until having traveled through all grid.Terminate stream
Associated all closed areas in run trace can be filled into the manor of oneself after journey.
Fig. 4 is the real machine effect filling effect figure for representing one or more embodiments according to the present invention.In the E of Fig. 4,
Dark belt-like zone represents the run trace of game role, and from figure, adjacent run trace section is by map partitioning
For two closed areas and a semiclosed region.The F of Fig. 4 is represented on the basis of the E of Fig. 4, uses the implementation of the present invention
The method of example, the result being filled to the region in map.Solid section is the manor of oneself of player's filling.
The embodiment of the disclosure has the advantages that:
1. support the filling demand of enclosing the land of the map with multiple closed areas;
General seed filling method and other fill methods are only to an area filling, using enclosing the land in the present embodiment
Fill method is filled in the case of can meeting to multizone closing, improves the accuracy for filling of enclosing the land.
2. the high efficiency that method is filled is reached by minimum enclosing region and mark filling;
Fill method of enclosing the land in the present embodiment determines the minimum enclosing region that needs fill to reduce traversal first
Scope in the filling process again does grid a little marks and avoids the judgement repeated processing, is effectively improved the effect for filling of enclosing the land
Rate.
According to the second embodiment of the present invention, a kind of area filling device of map is provided, including:First mould
Block obtains the coordinate of the grid having been filled with and run trace grid;Second module creates minimum enclosing region;3rd mould
Block, in minimum enclosing region internal labeling closed area;4th module fills closed area, wherein, minimum enclosing region is covered
The grid and the coordinate of run trace grid being had been filled with described in lid.
Further, the second module includes following submodule:First submodule, create temporal coordinate topLeft and
bottomRight;The second submodule, travels through the coordinate of the grid having been filled with and run trace grid, and takes wherein current grid
Coordinate for grid, if grid.x<TopLeft.x, then assignment topLeft.x=grid.x;If grid.y<
TopLeft.y, then assignment topLeft.y=grid.y;If grid.x>BottomRight.x, then assignment
BottomRight.x=grid.x;If grid.y>BottomRight.y, then assignment bottomRight.y=grid.y;The
Three submodules, after the coordinate of all grid having been filled with and run trace grid is traveled through, based on coordinate topLeft to coordinate
BottomRight establishes minimum enclosing region.
Further, grid is the grid with 8 unicom directions.
3rd embodiment according to the present invention, provides a kind of computer readable storage medium, is stored thereon with calculating
Machine program, the method that the first aspect of the present invention is realized when which is executed by processor.
The above description is merely a specific embodiment, but protection scope of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can readily occur in change or replacement, should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention described should be subject to the protection scope in claims.