def quiet_move(puzzle: Puzzle) -> bool: for node in puzzle.mainline: # on player move, not the last move of the puzzle if node.turn() != puzzle.pov and not node.is_end(): # no check given or escaped if not node.board().checkers() and not node.parent.board( ).checkers(): # no capture made or threatened if not util.is_capture(node): return not util.attacked_opponent_pieces( node.board(), node.move.to_square, puzzle.pov) return False
def defensive_move(puzzle: Puzzle) -> bool: # like quiet_move, but on last move # at least 3 legal moves if puzzle.mainline[-2].board().legal_moves.count() < 3: return False node = puzzle.mainline[-1] # no check given, no piece taken if node.board().is_check() or util.is_capture(node): return False # no piece attacked if util.attacked_opponent_pieces(node.board(), node.move.to_square, puzzle.pov): return False # no advanced pawn push return not util.is_advanced_pawn_move(node)
def quiet_move(puzzle: Puzzle) -> bool: for node in puzzle.mainline: if ( # on player move, not the last move of the puzzle node.turn() != puzzle.pov and not node.is_end() and # no check given or escaped not node.board().is_check() and not node.parent.board().is_check() and # no capture made or threatened not util.is_capture(node) and not util.attacked_opponent_pieces( node.board(), node.move.to_square, puzzle.pov) and # no advanced pawn push not util.is_advanced_pawn_move(node) and util.moved_piece_type(node) != KING): return True return False