add blacklisting

This commit is contained in:
2024-08-24 18:11:59 +03:00
parent f012c0536f
commit 473adc64b8
4 changed files with 106 additions and 44 deletions

View File

@ -8,6 +8,7 @@ from dataclasses import dataclass
class FingerTrick:
name: str
move: str
grip_pre_blacklist: Dict[str, List[str]]
grip_pre: Dict[str, str]
grip_post: Dict[str, str]
score: float
@ -66,7 +67,9 @@ def calculate_finger_trick_regrips(
for finger in finger_trick.grip_pre.keys():
current_location = grip[finger]
desired_location = finger_trick.grip_pre.get(finger)
blacklisted_locations = finger_trick.grip_pre_blacklist.get(finger, [])
if current_location != desired_location:
# TODO: check the minimal regrip?
regrip = next(
(
regrip
@ -74,6 +77,7 @@ def calculate_finger_trick_regrips(
if regrip.finger == finger
and regrip.pre == current_location
and regrip.post == desired_location
and regrip.pre not in blacklisted_locations
),
None,
)
@ -86,7 +90,7 @@ def generate_finger_tricks(
config: Config, moves: List[str]
) -> List[FingerTrickWithRegrip]:
grip = home_grip()
alg = []
alg: List[FingerTrickWithRegrip] = []
for move in moves:
# print("current grip:", grip)
# prit("current move:", move)
@ -113,6 +117,10 @@ def generate_finger_tricks(
# apply move
grip.update(best_finger_trick.finger_trick.grip_post)
alg.append(best_finger_trick)
# TODO: think about this
# don't count the first regrip
alg[0].finger_trick.score = 0
return alg