diff --git a/src/checkers/state.py b/src/checkers/state.py index a888aae..4cbe145 100644 --- a/src/checkers/state.py +++ b/src/checkers/state.py @@ -28,6 +28,7 @@ from dataclasses import dataclass from typing import ( TYPE_CHECKING, + Final, NamedTuple, TypeAlias, TypeVar, @@ -57,6 +58,14 @@ Pos: TypeAlias = tuple[u8, u8] +DIRECTIONS: Final = ( + (-1, -1), + (1, -1), + (-1, 1), + (1, 1), +) + + class Action(NamedTuple): """Represents an action.""" @@ -312,7 +321,8 @@ def get_jumps( continue # Get the tile beyond the jumped piece - side_side = get_sides(side)[direction] + dx, dy = DIRECTIONS[direction] + side_side = (side[0] + dx, side[1] + dy) # Validate beyond tile if not self.valid_location(side_side):