This commit is contained in:
cutsweettea
2025-10-29 10:36:33 -04:00
parent 45d60d1657
commit bbd55f48a0
10 changed files with 147 additions and 32 deletions

View File

@@ -68,14 +68,38 @@ def valid_range(max: int) -> list[int]:
# class for static move sets
class StaticMoveSet(MoveSets):
def is_valid_move(self, move: Move) -> bool:
# get the difference between the to and from row / column
from_to_row_diff = move.to_row - move.from_row
from_to_col_diff = move.to_col - move.from_col
# iterate over each move set, checking if it follows any of the move sets passed to the method
for ms in self.move_sets:
if from_to_row_diff == ms[0] and from_to_col_diff == ms[1]:
# checks if the difference in y and x is equal to any available options
if from_to_col_diff == ms[0] and from_to_row_diff == ms[1]:
return True
return False
# in these lists, the move sets are static, so the y and x are a set of combo's of ways to move
"""
pawn move sets are mostly static, but there will be an override for the is_valid_move method,
checking to see if the pawn can move 1 up 1 left / right to take another enemy piece
these values simulate these move sets, with x being the pawn, m being a possible static move,
and p being possible moves (such as the case i explained)
##########
# x #
# pmp #
# m #
# #
# #
# m #
# pmp #
# x #
##########
"""
pawn_valid_move_sets = [(1, 0), (2, 0)]
# in these lists, the move sets are dynamic, so the y and x are a range of times they can move on the x and y
rook_valid_move_sets = [(0, 8), (8, 0), (0, -8), (-8, 0)]
@@ -116,6 +140,6 @@ class DynamicMoveSet(MoveSets):
# create move sets
# static move sets
pawn_move_sets = StaticMoveSet((0, 1), (0, 2))
pawn_move_sets = StaticMoveSet(*pawn_valid_move_sets)
# dynamic move sets