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
15 changes: 12 additions & 3 deletions pauperformance_bot/service/pauperformance/silver/decklassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from scipy import spatial

from pauperformance_bot.constant.pauperformance.silver import (
BREW_CLASSIFICATION_THRESHOLD,
MAINBOARD_WEIGHT,
SIDEBOARD_WEIGHT,
)
Expand Down Expand Up @@ -317,21 +318,29 @@ def parse_dpl_deck(self, deck):
lines = [f"{pc['quantity']} {pc['name']}" for pc in deck["cards"]["mainboard"]]
lines += [""]
lines += [f"{pc['quantity']} {pc['name']}" for pc in deck["cards"]["sideboard"]]
lines += [""]
playable_deck = parse_playable_deck_from_lines(
lines, raise_error_if_invalid=False
)
return deck_id, playable_deck

def get_dpl_metagame(self, decks, name="DPL metagame"):
def get_dpl_metagame(
self,
decks,
name="DPL metagame",
brew_threshold=BREW_CLASSIFICATION_THRESHOLD,
learn_on_the_fly=True,
):
dpl_decks = []
for deck in decks:
deck_id, playable_deck = self.parse_dpl_deck(deck)
most_similar_archetype, highest_similarity = self.classify_deck(
playable_deck
)
logger.info(f"{deck} | {most_similar_archetype} {highest_similarity}")
if highest_similarity < 0.76:
if highest_similarity < brew_threshold:
most_similar_archetype = None
elif learn_on_the_fly:
self.known_decks.append((playable_deck, most_similar_archetype))
dpl_decks.append(
DPLDeck(
identifier=deck_id,
Expand Down