本文整理汇总了Python中board.Board.gen_neighbors方法的典型用法代码示例。如果您正苦于以下问题:Python Board.gen_neighbors方法的具体用法?Python Board.gen_neighbors怎么用?Python Board.gen_neighbors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board.Board
的用法示例。
在下文中一共展示了Board.gen_neighbors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edge_one_one
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import gen_neighbors [as 别名]
def edge_one_one(self, board: Board, pt, neighbors=None) -> None:
if not neighbors:
neighbors = board.gen_neighbors(pt)
has_edge = self._is_on_edge(board, pt, neighbors)
if not has_edge:
return False
示例2: basic_patterns
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import gen_neighbors [as 别名]
def basic_patterns(self, board: Board, pt) -> None:
if pt in board.numbers:
bombs = board.numbers[pt]
neighbors = board.gen_neighbors(pt)
open_neighbors = neighbors & board.unclicked_squares
if len(open_neighbors) == bombs:
for neighbor in neighbors:
board.select_sq(neighbor)
self.basic_patterns(neighbor)
示例3: _is_on_edge
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import gen_neighbors [as 别名]
def _is_on_edge(self, board: Board, pt: tuple, neighbors=None, edges=None) -> bool:
if not neighbors:
neighbors = board.gen_neighbors(pt)
if len(neighbors) <= 5:
return True
if not edges:
edges = self._get_edges(board, pt, neighbors)
return self._is_on_soft_edge(board, pt, neighbors, edges)
示例4: _is_on_soft_edge
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import gen_neighbors [as 别名]
def _is_on_soft_edge(self, board: Board, pt: tuple, neighbors=None, edges=None) -> bool:
if not neighbors:
neighbors = board.gen_neighbors(pt)
if not edges:
edges = self._get_edges(board, pt, neighbors)
#intersection of visible zeros and neighbors
zero_sqs = self._get_zero_sqs(board)
zero_neighbors = zero_sqs & neighbors
# check if 3-consec pts are subsets of zero_neighbors, bools
return any(edge < zero_neighbors for edge in edges)
示例5: _get_mapped_neighbors
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import gen_neighbors [as 别名]
def _get_mapped_neighbors(self, board: Board, pt: tuple) -> set:
neighbors = board.gen_neighbors(pt)
mapped_neighbors = {neighbor: pt for neighbor in neighbors}
pass