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)
def update_value(self):
n_right = self.musicgameanswer_set.filter(game__player=F("answer")).count()
if n_right == 0:
self.value = 1000
else:
self.value = 1000 / (
1 + ((n_right - 1) / (self.game.players.count() - 1)) ** 0.5
)
x = self.musicgameanswer_set.filter(game__player=F("answer")).count()
n = self.game.players.count()
n = max(3, n)
self.value = 1000 * 2 ** (-(x - 2) / (n - 2))
self.save()
class Meta: