Selaa lähdekoodia

Lower precision when handling Description scores.

Reddo 5 vuotta sitten
vanhempi
sitoutus
341e8b6e52
1 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  1. 5 2
      app/World/Classes/ContentPicker/ContentDescription.ts

+ 5 - 2
app/World/Classes/ContentPicker/ContentDescription.ts

@@ -43,8 +43,11 @@ class ContentDescription {
         // After shuffling the list, descriptions with the highest scores go at the top, and between those the ones with the lowest saidCounts go first
         // If multiple descriptions have the same score/saidCount, they are picked randomly due to the previous shuffling.
         a.sort((a : ContentDescription, b : ContentDescription) => {
-            let scoreA = a.getScore() / (a.saidCount + 1);
-            let scoreB = b.getScore() / (b.saidCount + 1); // By dividing the score gby the amount of times it was said we increase rotation of descriptions
+            // Division by saidCount for now, to increase rotativity of descriptions
+            // Reduce precision on final number to decrease the likelihood of printing the same descriptions always in the same order
+            let precision = 5;
+            let scoreA = Math.floor(precision * a.getScore() / (a.saidCount + 1)) / precision;
+            let scoreB = Math.floor(precision * b.getScore() / (b.saidCount + 1)) / precision;
             if (scoreA != scoreB) return scoreB - scoreA;
             return 0;
         });