def x_ray(puzzle: Puzzle) -> bool: for node in puzzle.mainline[1::2][1:]: if not util.is_capture(node): continue prev_op_node = node.parent assert isinstance(prev_op_node, ChildNode) if prev_op_node.move.to_square != node.move.to_square or util.moved_piece_type(prev_op_node) == KING: continue prev_pl_node = prev_op_node.parent assert isinstance(prev_pl_node, ChildNode) if prev_pl_node.move.to_square != prev_op_node.move.to_square: continue if prev_op_node.move.from_square in SquareSet.between(node.move.from_square, node.move.to_square): return True return False