Discuss Scratch

PizzaAddict4Life
Scratcher
1000+ posts

Relative score calculator.

Basically… I want a little bit of a score system, in which you can compare other scores.

Ok… let me explain that better.

I want to calculate the average score first. I know how to do that… I need the total number of scores, and the sum of all the scores, and then I divide the sum by the count.

I want that to be equal to 1, which is pretty easy.

But the more complicated part is… when it is not 1.

Lets say that the average score was, 4. 4 would then equal, 1.

However, if someone scored 0, they would get a zero, so zero equals zero.

If they get a 2, they are 50% of the way to the average, so they would get 0.5, because 0.5 = 50%

And if they got a 6, it would just be 50% more than average, right? So it would be a 1.5

Now this might seem like a dumb question, but I just can't think of an answer.

How could I get an efficient script to do that? Calculate that second number, (the 1.5 or 1 or whatever) relative to the score (the 6, or 4, or whatever) easily?
Cutie_Pooge
Scratcher
500+ posts

Relative score calculator.

I am confused, don't you just mean
((1) / (num))
PizzaAddict4Life
Scratcher
1000+ posts

Relative score calculator.

Cutie_Pooge wrote:

I am confused, don't you just mean
((1) / (num))

I am confused too… let me try a few things. I think I was just not thinking straight when I made this post… If I can't figure it out then I will come back to it.

Thanks for starting to try to help though.
Madcatofdoom
Scratcher
500+ posts

Relative score calculator.

ahhh can you word this better? I wasn't confused at first and got more confused when I started reading the whole thing.
What do you mean “equal to 1”? What do you mean by 4.4 then equal to 1?
Byron_Inc
Scratcher
1000+ posts

Relative score calculator.

Do you mean:
((score) / (average))
Oumuamua
Scratcher
1000+ posts

Relative score calculator.

"Lets say that the average score was, 4. 4 would then equal, 1.

However, if someone scored 0, they would get a zero, so zero equals zero.

If they get a 2, they are 50% of the way to the average, so they would get 0.5, because 0.5 = 50%

And if they got a 6, it would just be 50% more than average, right? So it would be a 1.5"

set [result v] to ((score) / (round (average)))

//or may be

set [result v] to ((score) / ([floor v] of (average))) //floor or ceiling

Last edited by Oumuamua (July 10, 2020 08:33:57)

deck26
Scratcher
1000+ posts

Relative score calculator.

Do you want to show the new score compared to the average so far (excluding the new score) or a new average? In the latter case your examples are wrong except for the zero assuming the score cant' go below zero.

Whichever average you want to use score/average is all you need unless the average so far is 0 and you're using that as your divisor.
PizzaAddict4Life
Scratcher
1000+ posts

Relative score calculator.

Oumuamua wrote:

set [result v] to ((score) / (round (average)))

//or may be

set [result v] to ((score) / ([floor v] of (average))) //floor or ceiling

Yeah… that is exactly what I need. I don't know how I didn't think of that. Thank you!

Since this is resolved, I will request this to be closed
deck26
Scratcher
1000+ posts

Relative score calculator.

PizzaAddict4Life wrote:

Oumuamua wrote:

set [result v] to ((score) / (round (average)))

//or may be

set [result v] to ((score) / ([floor v] of (average))) //floor or ceiling

Yeah… that is exactly what I need. I don't know how I didn't think of that. Thank you!

Since this is resolved, I will request this to be closed
Why do you want floor or ceiling in the calculation?
PizzaAddict4Life
Scratcher
1000+ posts

Relative score calculator.

deck26 wrote:

PizzaAddict4Life wrote:

Oumuamua wrote:

set [result v] to ((score) / (round (average)))

//or may be

set [result v] to ((score) / ([floor v] of (average))) //floor or ceiling

Yeah… that is exactly what I need. I don't know how I didn't think of that. Thank you!

Since this is resolved, I will request this to be closed
Why do you want floor or ceiling in the calculation?

I am not going to use the floor or ceiling… just the round.
deck26
Scratcher
1000+ posts

Relative score calculator.

PizzaAddict4Life wrote:

deck26 wrote:

PizzaAddict4Life wrote:

Oumuamua wrote:

set [result v] to ((score) / (round (average)))

//or may be

set [result v] to ((score) / ([floor v] of (average))) //floor or ceiling

Yeah… that is exactly what I need. I don't know how I didn't think of that. Thank you!

Since this is resolved, I will request this to be closed
Why do you want floor or ceiling in the calculation?

I am not going to use the floor or ceiling… just the round.
But why round the average before you divide the score by it? If the average is 3.6 and someone scores 4 they've done better than average but you'd be saying they were only getting the average score.
PizzaAddict4Life
Scratcher
1000+ posts

Relative score calculator.

deck26 wrote:

PizzaAddict4Life wrote:

deck26 wrote:

PizzaAddict4Life wrote:

Oumuamua wrote:

set [result v] to ((score) / (round (average)))

//or may be

set [result v] to ((score) / ([floor v] of (average))) //floor or ceiling

Yeah… that is exactly what I need. I don't know how I didn't think of that. Thank you!

Since this is resolved, I will request this to be closed
Why do you want floor or ceiling in the calculation?

I am not going to use the floor or ceiling… just the round.
But why round the average before you divide the score by it? If the average is 3.6 and someone scores 4 they've done better than average but you'd be saying they were only getting the average score.

Hmm… you do make a good point.

I guess I will just allow it to 2 decimal places (using some other code I could probably figure out) and then round the third one.
deck26
Scratcher
1000+ posts

Relative score calculator.

Rounding the result of the division is fine but don't round either number before the division. To get 2 significant digits multiply by 100, round and divide by 100.

Powered by DjangoBB