當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。