feat: puzzle solver algorithm

This commit is contained in:
Krzysztof kuhy Rudnicki 2026-03-16 19:49:52 +01:00
parent 4527879c9f
commit 83f21a9ca2
2 changed files with 16 additions and 6 deletions

View File

@ -91,6 +91,8 @@ PROTECTED_APP_IDS = {
1493710, # Proton Experimental 1493710, # Proton Experimental
1161040, # Proton BattlEye Runtime 1161040, # Proton BattlEye Runtime
1007020, # Proton EasyAntiCheat Runtime 1007020, # Proton EasyAntiCheat Runtime
# Games allowed to be installed anytime
3949040, # RV There Yet?
} }
STEAMAPPS_PATH = Path("~/.local/share/Steam/steamapps").expanduser() STEAMAPPS_PATH = Path("~/.local/share/Steam/steamapps").expanduser()
@ -1088,10 +1090,15 @@ def _try_reassign_shorter_game(
candidates.sort(key=lambda g: g.completionist_hours) candidates.sort(key=lambda g: g.completionist_hours)
if not candidates or candidates[0].app_id == app_id: if not candidates or candidates[0].app_id == app_id:
return False return False
shortest = candidates[0] # Filter out Linux-incompatible games before deciding to reassign.
playable = _pick_playable_candidate(
[c for c in candidates if c.app_id != app_id],
)
if playable is None or playable.completionist_hours >= hours:
return False
_echo( _echo(
f"\n Reassigning: {shortest.name} is shorter" f"\n Reassigning: {playable.name} is shorter"
f" (~{shortest.completionist_hours:.1f}h vs ~{hours:.1f}h)" f" (~{playable.completionist_hours:.1f}h vs ~{hours:.1f}h)"
) )
pick_next_game(all_games, state, config) pick_next_game(all_games, state, config)
return True return True

View File

@ -62,8 +62,8 @@ class ProtonDBRating:
- Its tier is gold but trending to silver or worse. - Its tier is gold but trending to silver or worse.
- No data exists (unknown compatibility). - No data exists (unknown compatibility).
""" """
if not self.tier: if not self.tier or self.tier == "pending":
return True # No data → don't block; user can skip manually. return True # No data / pending → don't block; user can skip manually.
tier_rank = TIER_ORDER.get(self.tier, 99) tier_rank = TIER_ORDER.get(self.tier, 99)
min_rank = TIER_ORDER[MIN_PLAYABLE_TIER] min_rank = TIER_ORDER[MIN_PLAYABLE_TIER]
@ -83,7 +83,10 @@ class ProtonDBRating:
def _load_cache() -> dict[str, Any]: def _load_cache() -> dict[str, Any]:
"""Load the on-disk ProtonDB cache.""" """Load the on-disk ProtonDB cache."""
if PROTONDB_CACHE_FILE.exists(): if PROTONDB_CACHE_FILE.exists():
return json.loads(PROTONDB_CACHE_FILE.read_text(encoding="utf-8")) # type: ignore[no-any-return] data: dict[str, Any] = json.loads(
PROTONDB_CACHE_FILE.read_text(encoding="utf-8"),
)
return data
return {} return {}