1

I have a question and answer trivia game app which randomly picks questions from a database and prompts the user to answer the question correctly. The total number of correct answers, the total number of questions attempted, and the elapsed time for the entire quiz session are recorded.

What I need is a formula that would rank a user's scores not simply on "percentage correct", but also takes into consideration the amount of time the user spent. What I don't want is a user who answered only 1 question correctly (out of only 1 question attempted, which would be a correct percentage value of 100%) over someone who answered 95 questions correctly out of 100 attempted (95%). Moreover, a session where the user answered 95 out of 100 correctly within 30 minutes should be considered/ranked as a better performance than 95 correct out of 100 that took 5 hours to complete.

I need to create a leaderboard of the user's results, but am not sure how to best accomplish all of the above.

Suggestions?

1
  • This might fit better on one of the math/stats SE sites as it's not specific to software engineering, but you may look at those trivia games that play at bars / sports restaurants (like BWW). The number of points awarded for a correct question goes down as time elapses
    – mmathis
    Nov 5, 2021 at 16:43

1 Answer 1

2

I agree with mmathis that this might be a better question for Math/Stats or even GameDev SE. However, here's a suggestion:

Points per question

Answering questions gets you points and you get more points the quicker you answer. If you are worried about people quessing a bunch of questions in a short time for more points, you could possibly penalize wrong answers (and perhaps provide a "skip question" button). Points awarded could follow this formula:

  • P = points awarded
  • M = maximum point value
  • t = time taken to answer
  • F = point-time factor
  • T = "half-life" of the points
P = M * F^(t/T)

In other words, every "T" seconds, the points awarded are adjusted by "F". Both T and M could be set for each question (so harder question can be worth more and/or along the player to take longer).

I think this fits all the criteria you are looking for, and shouldn't be too difficult to record everything you need. Easiest way to do it would be keep a running total of awarded points along with your other stats.

3
  • It is unclear what the "half-life of the points" and "point-time factor" are. "M" is arbitrary, I understand. "t" is likewise clear, whether it be seconds or minutes. But the "F" and "T" are unclear in this example. Nov 5, 2021 at 18:55
  • @user1527614 Say T=30seconds and F=(1/2), every 30 seconds the awarded points would be cut in half. So if M=100, at t=0 P=100, at t=30 P=50, at t=60 P=25, at t=90 P=12.5, ... and so on. F would also be fairly arbitrary (between 0 and 1, lower means the quicker the score drops off) and T would be set per question. You can think of T as the "average" time it should take to answer the question and F as how much of the score an "average" time gets.
    – JMekker
    Nov 5, 2021 at 19:42
  • suggestion : make the halflife of questions based on the average completion time, so to score highly you have to be the fastest
    – Ewan
    Nov 6, 2021 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.