Skip to content
Permalink
Browse files

tag decks as unknown if deviation is too high

  • Loading branch information...
Manuel-777 committed May 28, 2019
1 parent 2a2530c commit 3129a1c51a30462e16440eeebb135b61c71bb10b
Showing with 7 additions and 2 deletions.
  1. +7 −2 window_background/background.js
@@ -1666,17 +1666,18 @@ function getBestArchetype(deck) {
let lowestDeviation = Math.sqrt(
mainDeviations.reduce((a, b) => a + b) / (mainDeviations.length - 1)
);
let highest = lowestDeviation;//err..

// Test for each archertype
deck_archetypes.forEach(arch => {
//console.log(arch.name);
mainDeviations = [];
deck.mainDeck.forEach(card => {
let q = card.quantity;
//let q = card.quantity;
let name = db.card(card.id).name;
let archMain = arch.average.mainDeck;

let deviation = q - (archMain[name] ? 1 : 0); // archMain[name] ? archMain[name] : 0 // for full data
let deviation = 1 - (archMain[name] ? 1 : 0); // archMain[name] ? archMain[name] : 0 // for full data
mainDeviations.push(deviation * deviation);
//console.log(name, deviation, q, archMain[name]);
});
@@ -1691,6 +1692,10 @@ function getBestArchetype(deck) {
//console.log(">>", averageDeviation, Math.sqrt(averageDeviation));
});

if (lowestDeviation > highest * 0.5) {
return "Unknown";
}

return bestMatch.name;
}

0 comments on commit 3129a1c

Please sign in to comment.
You can’t perform that action at this time.