equally weight artists

This commit is contained in:
marsteralex 2022-09-11 15:05:51 +02:00
parent 9046b2ad43
commit 8c18c7a475

View File

@ -55,11 +55,14 @@ function putIntoMapAndFetch(data) {
total = newArtistData[1] total = newArtistData[1]
} }
for (const [key, value] of Object.entries(allData)) { for (const [key, value] of Object.entries(allData)) {
for (let j = 0; j < value.length; j++) { if (whichGuesser == 'artist') {
weightedCards.push(key) weightedCards.push(key)
} else {
for (let j = 0; j < value.length; j++) {
weightedCards.push(key)
}
} }
} }
shuffleArray(weightedCards)
window.console.log(allData) window.console.log(allData)
window.console.log(total) window.console.log(total)
if (whichGuesser === 'counterspell') { if (whichGuesser === 'counterspell') {
@ -84,9 +87,13 @@ function getKSamples() {
let samples = {} let samples = {}
let i = 0 let i = 0
let allCards = [] let allCards = []
for (const [key, value] of Object.entries(allData)) { if (whichGuesser == 'artist') {
for (let j = 0; j < value.length; j++) { allCards = weightedCards
allCards.push(key) } else {
for (const [key, value] of Object.entries(allData)) {
for (let j = 0; j < value.length; j++) {
allCards.push(key)
}
} }
} }
shuffleArray(allCards) shuffleArray(allCards)
@ -112,20 +119,23 @@ function getKSamples() {
delete allData[key] delete allData[key]
} }
} }
let count = 0 if (whichGuesser == 'artist') {
let ind = 0 usedCounters = new Set(weightedCards)
shuffleArray(weightedCards) } else {
for (let j = 0; j < weightedCards.length; j++) { let count = 0
key = weightedCards[j] shuffleArray(weightedCards)
value = weightedCards[key] for (let j = 0; j < weightedCards.length; j++) {
if (usedCounters.has(key)) { key = weightedCards[j]
continue value = weightedCards[key]
} else { if (usedCounters.has(key)) {
window.console.log(key) continue
usedCounters.add(key) } else {
count++ window.console.log(key)
if (count >= extra) { usedCounters.add(key)
break count++
if (count >= extra) {
break
}
} }
} }
} }