Move constant to global

parent 5aaf7799
Pipeline #20065845 passed with stages
in 10 minutes and 44 seconds
......@@ -121,6 +121,12 @@ _PIECE_PATHS = { # type: Dict[Type, Set[_DirectionPath]]
_PIECE_PATHS[_QUEEN] = _PIECE_PATHS[_BISHOP].union(_PIECE_PATHS[_ROOK])
_PIECE_PATHS[_KING] = _PIECE_PATHS[_QUEEN]
TO_CHECK = { # type: Dict[Type, Set[Type]]
_KNIGHT: {_KNIGHT},
_BISHOP: {_BISHOP, _QUEEN, _KING},
_ROOK: {_ROOK, _QUEEN, _KING},
}
def attacked(position: Position, side: Side, square: Square) -> bool:
""" Is *square* in check by *side*?
......@@ -171,12 +177,7 @@ def attacked(position: Position, side: Side, square: Square) -> bool:
# Pretend our square is a knight, a bishop or a rook. If an identical
# piece (or a queen or a king) is in our path, then our square is in check.
to_check = { # type: Dict[Type, Set[Type]]
_KNIGHT: {_KNIGHT},
_BISHOP: {_BISHOP, _QUEEN, _KING},
_ROOK: {_ROOK, _QUEEN, _KING},
}
for type_, targets in to_check.items():
for type_, targets in TO_CHECK.items():
for path in _PIECE_PATHS[type_]:
first_traverse = True
current = square
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment