当前位置: 首页>>代码示例>>Python>>正文


Python Region.on_border方法代码示例

本文整理汇总了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)
开发者ID:DFrye333,项目名称:DynamicMaze,代码行数:28,代码来源:maze.py


注:本文中的region.Region.on_border方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。