本文整理匯總了Python中region.Region.on_border方法的典型用法代碼示例。如果您正苦於以下問題:Python Region.on_border方法的具體用法?Python Region.on_border怎麽用?Python Region.on_border使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類region.Region
的用法示例。
在下文中一共展示了Region.on_border方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: open
# 需要導入模塊: from region import Region [as 別名]
# 或者: from region.Region import on_border [as 別名]
def open(self, region=None, exemptions=None, open_border=True):
'''
Method: open
Description: Opens (visits all cells and destroys all walls within) the given region, avoiding the given exempt regions.
Parameters: region=None, exemptions=None
region: Region - A region for maze opening to span
exemptions: Regions - A collection of regions for maze opening to avoid
Return: None
'''
# Ensure that valid boundaries are set.
if region is None:
region = Region((0, 0), (self.get_width(), self.get_height()))
# Construct a set of valid cells.
valid_cells = self.valid_cell_set(region, exemptions)
# Visit all valid cells and open the walls as necessary (region borders only open if open_border is True).
for cell in valid_cells:
cell.visit()
border_directions = region.on_border(cell.m_position)
for direction in list(Direction):
# Ensure that the border is allowed to be destroyed.
if (self.get_neighbor_cell(cell, direction) is not None) and (open_border) or (direction not in border_directions):
self.set_wall(cell, direction, False)