Refactor value calculation in MusicGameOrder to improve scoring logic

Fix #13
Close #12
This commit is contained in:
Edgar P. Burkhart 2025-06-16 16:16:03 +02:00
parent c639307cfb
commit 84c432c325
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -121,13 +121,10 @@ class MusicGameOrder(models.Model):
value = models.PositiveIntegerField(default=0) value = models.PositiveIntegerField(default=0)
def update_value(self): def update_value(self):
n_right = self.musicgameanswer_set.filter(game__player=F("answer")).count() x = self.musicgameanswer_set.filter(game__player=F("answer")).count()
if n_right == 0: n = self.game.players.count()
self.value = 1000 n = max(3, n)
else: self.value = 1000 * 2 ** (-(x - 2) / (n - 2))
self.value = 1000 / (
1 + ((n_right - 1) / (self.game.players.count() - 1)) ** 0.5
)
self.save() self.save()
class Meta: class Meta: