Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/checkers/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from dataclasses import dataclass
from typing import (
TYPE_CHECKING,
Final,
NamedTuple,
TypeAlias,
TypeVar,
Expand Down Expand Up @@ -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."""

Expand Down Expand Up @@ -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):
Expand Down