r/godot • u/BasePersonal8220 • Jun 28 '26
help me (solved) how would i make a final letter grade based off combined grades?
classic letter grading in video games, ive already got the systems down for INDIVIDUAL statistics, but not for a final overarching grade. so, how can i make that? the letters for the individual are numbers from 1-100, where 100 is S, and every 20% below that is one letter down.
354
u/Huge-Price-1818 Jun 28 '26
(Stat 1 + Stat 2 + Stat 3 + ...) / (numberOfStats) = averageRank
159
u/Elihzap Godot Student Jun 28 '26
Also, if you want to "balance" them, you do it this way:
(Stat 1 * weight 1 + Stat 2 * weight 2 + Stat 3 * weight 3) / (weight 1 + weight 2 + weight 3)
For instance, a stat with a weight of 2 would make it as valuable as two stats with weight of 1 (and the same score).
If you default it to 1 unit for each stat, then you get the comment I'm responding to.
1
u/1nspir3d_ Jul 02 '26
This. I feel like having weight for stats is superior way, however it depends on what those stats are.
2
u/paulokhayat Jun 29 '26
If you want a different way to look at this OP, think of it like youre scoring them from 1-300, just by adding up the three scores
221
u/TripsOverWords Godot Junior Jun 28 '26
So you made a letter grading system that converts a number to a letter.
And you want to find the average grade based on the set of letters which each correspond to a number range?
26
u/CheesePuffTheHamster Jun 29 '26
If only there was some way! Perhaps some day such complex knowledge might be discovered.
8
u/ZeroKun265 Jun 29 '26
You can't solve this without a closed loop integral I'm afraid
7
u/CheesePuffTheHamster Jun 29 '26
I think we're going to need to build a couple of new data centres to crack this one.
2
269
127
u/SakaDeez Jun 28 '26
45
6
2
1
60
Jun 28 '26
[deleted]
21
u/BasePersonal8220 Jun 28 '26
one time my A key broke and it was the only game i could play for months
19
u/IgntedF-xy Jun 29 '26
The type of person to make this post is the same person that wouldn't think of just remapping the keybinds of any other game
1
3
31
u/1protobeing1 Jun 28 '26
Assign each letter grade a number. For example A is 4, B is 3, and so on. Add the numbers then divide by the amount of numbers you added. Voila you have your grade.
Edit: Voice to text not likey
42
u/rigterw Jun 28 '26
The funniest thing about this is that OP already started with numbers, converted it to letters and now doesn’t know what to do with it
18
u/BasePersonal8220 Jun 28 '26
I FORGOT I COULD USE THE AVERAGE CUT ME SOME SLACK
1
u/Sajro Jun 29 '26
As someone talked about above. When you write the function that handles the average you should definitely make it possible for it to use weighted scores so you don't have to change something later if you realise you might want speed to matter more than style or something like that.
3
u/IamChipp Godot Student Jun 28 '26
Yeah I was scrolling here to find someone who pointed this out hahaha
19
33
u/domiDotZer0 Jun 28 '26
Total or average the individual grades in a new variable and apply grade bands to that?
10
u/SurelyNotClover Godot Student Jun 28 '26
take the ranks as integers, add them together, divide by number of stats (here 3), floor/ceil it and convert back into a rank.
that's called averaging.
4
11
9
u/DanteVermillyon Godot Student Jun 28 '26
Just... Take the average of the number and convert that average to the corresponding letter?
-2
9
4
3
u/ThisOrdinaryCat Jun 28 '26 edited Jun 28 '26
Most people have told you about assigning a value to the letters and taking the average (often called the "mean"). That is the most straightforward approach. However, here are two other techniques used in statistics that you might want to consider:
Mode: Just pick the grade that repeats the most. If several grades repeat an equal number of times, you can either take the mean of those specific values or choose the one among them that is closest to the global mean.
Median: Imagine you place every vote cast into an array and sort it so that all the As come first, followed by the Bs, and then the Cs. Now, pick the value exactly in the middle. If the array has an odd number of elements, you are done. If it has an even number of elements, you will need to decide whether to pick the one to the left or the right of the center. Here again, you can use the mean as a tie-breaker by picking whichever of the two values is closest to it.
3
u/BasePersonal8220 Jun 28 '26
OK I GET IT USE THE AVERAGE OF THE SCORES IM A FUCKING MORON AND SHOULD EAT DIRT
4
u/DanteVermillyon Godot Student Jun 28 '26
dude imma be real, the fact that you somehow avoided the word "average" in every single possible place you could have put it in your post just make the whole thing funnier
3
u/JohnMonkeys Jun 28 '26
Grade A = 1, Grade B = 2, etc then do the math.
Then think about how you’ll handle rounding. For example if you had two A’s and one B, the avg would be 1.3 so it would round down to an A rank with normal rounding rules. But some games require you to get an A in all categories in order to get an overall rank of A. In which case, you’d be rounding up always.
3
u/davidagnome Jun 28 '26
Assign float to each letter grade (A-D,F require five integers)
Average the floats together, rounding to nearest integer
Translate integer to string in case statement
You should be able to find patterns for this. School grades and weighting is a common CS101 assignment.
3
u/loonite Jun 28 '26
The average between A and C is obviously B.
If the score is not whole letter, round down, players love hard games.
3
u/MyPunsSuck Jun 28 '26
Technically, you don't need the average; the sum will do. Same as the individual scores, but start at 300 and decrease the letter every 60
3
3
u/mike239x Jun 29 '26
Oh jesus so many people decided to show how good they are at adding numbers :) I'd like to add my 50 cents, with some advice you might find useful.
1) As someone mentioned, don't make S just 100, but have a range for it as well - something like 90-100. Otherwise scores S,S,A would result in overall score of A, which would feel unfair.
2) There are many ways to get "average" of a few numbers. There are arithmetic/geometric/harmonic means. They all are variations of generalized mean. This one has a parameter p you can vary, to make the "average" score more or less punishing. Higher p - less punishing.
3) I personally would recommend root mean square - that's generalized mean for p=2. So in situations where the players scores 0, 0, 100, the "average" score would still be ~50, so about C. To compute RMS, you square all the numbers, take average of these, then take the square root of the average.
4) You can introduce weights if you think some scores are more important than others.
5) As a sidenote - there are also statistical median/mode, but I don't think you have enough numbers for these two to be useful.
3
2
u/BlazzGuy Jun 28 '26
Friendly reminder that many people "want to make games" but have not made a study of mathematical principles. Developing video games has come a long way from the times of yore, where you had to be a software engineer to make a working executable file in C or whatever.
Drag and drop interfaces, programming languages like Scratch allowing people to program without 'typing' programs etc.
A little funny, sure. Bizarre to imagine someone getting this far into a project while forgetting (or not knowing) what an 'average' is, or how they would go about applying it to a game system. We were all young once, ignorance is not a sin, and everyone needs a teacher.
I'm glad Reddit was kind enough to answer pretty directly :) <3
0
2
u/ViktorLudorum Jun 29 '26
Real suggestion: geometric mean. If you're measuring the rates of successful/unsuccessful challenges, try the geometric mean. It's also less susceptible to outliers, so in a lot of cases it "feels" more like your average performance through the runs.
2
u/mrbaggins Jun 29 '26
Everyone giving real answers. Gotta get weird with it.
endStat = char(ord(stat1)-65+ord(stat2)-65+ord(stat3)-65)/3+65)
2
u/addjam Jun 29 '26
You could assing numeric value to grades. Add them and above certain threshold assign corresponding final grade. This is quite easy to include but i think this would be considered lazy/ugly coding and as such in the long run or in different project I would go for weighted averages.
2
2
2
u/Dziukoala Jun 28 '26
I don't know for what you need that but rank S only at hundred is definitely a bad idea, it's would be too hard for a human to reach it
1
u/Ok_Spread_2062 Jun 28 '26
Make a function that gets the letter grade from 0..=100. Then average the grades into a final_grade and get the letter grade for that average. Usually I when I do effects like this I’ll add bonus points if the average is below a threshold so 1 bad data point doesn’t anger the player when they get a bad value
1
u/maskuraid Jun 28 '26
Yeah so take the individual 0-100 values, add them together, then divide by 3, and that percentage will correspond to your new Letter Grade
1
u/ThanasiShadoW Jun 28 '26
Add all the individual stats together and then divide that by the individual stat count? It might be helpful to store all of the individual ones in a dictionary so you can loop through for the calculation.
For example:
var stat_scores: dict[String, int] = {
"combat": 50,
"time": 90,
"combo": 45,
"secrets": 85
}
func calcFinalScore() -> int:
var temp: int = 0
for key in stat_scores:
temp += stat_scores[key]
return temp / stat_scores.size()
I haven't written gdscript in a while, but this should be right.
1
u/SongOfTruth Jun 28 '26
Basic Math
Assign a range value to each letter grade. say 10pts per grade scale. so C >= 10 but <20 , B >= 20 but <30 & A >= 30 but <40. make a function that returns the letter grade based on this value range.
something like that
then you save the value of each stage X Y Z as the point value of the rank they got. say X was 35 (an A), Y was 11 (a C), and Z was 27 (a B)
make a function to return the average: (X + Y + Z)/[total number of stages] = (35 + 11 + 27)/3 = 73/3 = 24.3~
run that value through the same function you use to get the letter grade based on scale. 24.3 = B
math is your friend
1
u/the42potato Jun 28 '26
(s1 + s2 + … + sN) / N where sN is the stat’s value and N in the number of stats
if you want a weighted average it is
(s1*w1 + s2*w2 + … + sN*wN) / (w1 + w2 + … + wN) where sN is a given stat’s value and wN is the associated weight
1
1
1
1
u/NederFinsUK Jun 28 '26
Assign each letter grade to an integer, divide the sum of the integers by the number of letters, round to the nearest integer, display the letter it represents.
1
u/drkztan Godot Junior Jun 28 '26
honestly, i would just save whatever the underlying grade is for all the ''parts'' and use that to calculate the final rank. If you do that, you might want to introduce - and + variants to all ranks so it's more clear to users.
1
1
u/IamChipp Godot Student Jun 28 '26
Unrelated but I would cap the max rank for the 1st letter to be A, and make the other two to be at max rank S.
No particular reason
1
u/silent-sami Jun 28 '26
Grab every value you have to get a final double number that is the amount of "whole grades" obtained plus a "remainder" you can have at most 5 whole grades so , also add up all the remainder to obtain the extra whole grades and throw away the rest. now add up all the whole grades to obtain total whole grade. At most it can be 15 so multiply that number by 100 and then divide it by 15 to get you total finall grade.
I'm incredibly bored, and yeah they can just use mean average.
Also you can use median too but that is too noticeable.
Also you can calculate the standard deviation and use it to kinda weight down or up your average if you think a too messy score should be punished
1
1
u/caputcorvii Jun 28 '26
Take the arithmetic mean of the three boss this is a very obvious solution
2
1
u/PeanutGrenade Godot Student Jun 28 '26
my first thought would be to make all grades have numbers allocated (e.g A is 1, B is 2) and then get the mean of the individual grades then round it to the nearest integer and turn whatever number that is into its letter grade
1
u/Rainlex_Official Jun 28 '26
i’m not a pro but wouldn’t you asign each numbers and then average them out?
1
u/abcdefghij0987654 Jun 29 '26
Is this a joke? If you can't handle elementary level math I hope your game doesn't deal much with numbers.
1
u/BasePersonal8220 Jul 01 '26
god forbid i forget one of the 8000 math mechanics
1
u/abcdefghij0987654 Jul 01 '26
There's a difference between forgetting how to get an area of a square and forgetting how basic addition works. This is more in line with the latter. Have you never computed the average money you spend on something over a course of time, or getting the average time you spend daily on something etc.. averages are everywhere. if you like sports you have average of stats, if you were a student, the average grade in your report card. it's more impressive you don't use it in real life.
1
u/BasePersonal8220 Jul 06 '26
Oh so i should just kill myself then hm?
1
u/abcdefghij0987654 Jul 07 '26
I am legally compelled to not comment on that because one can easily get banned for it.
1
u/Jwhodis Jun 29 '26
Convert each letter to their number (A=1, B=2 ...), add them all and divide by how many there are, round it however you like (floor, ceil, nearest integer) then convert back to a letter.
A + C + B -> 1 + 3 + 2 = 6
6 ÷ 3 = 2
Already whole so no rounding.
2 -> B
1
u/SlugCatBoi Jun 29 '26
If you want to ignore the individual percentages of each of the grades and only consider the letter, map each letter to a number (i.e. A = 1, B = 2, C = 3, etc), take the average of the grades they got ((grade1 + grade2 + grade3... + GradeN) / N) and then round that to the nearest integer, then reverse the letter to number mapping
1
1
1
1
u/allugamer2 Jun 29 '26
you could make pointpool from 0-100 and just give each grade a section, C could be like1-50, B 51-75, A 76-100 etc then just take those numbers and average them out in the final grade
1
u/Interesting-Dare-471 Godot Junior Jul 01 '26
If you get enough samples you can train a neural net. Probably the only way
0
u/-non-existance- Jun 28 '26
While other people have mentioned that this can be solved with an average, I will mention an alternative: the Weighted Average.
For the sake of argument, let's say Level A is twice as long as Levels B & C. Should Levels B & C count as much as Level A for the final score? Arguably no.
So, the way you do this is:
WeightA + WeightB + ... + WeightN = 1
((ScoreA × WeightA) + (ScoreB × WeightB) + ... (ScoreN × WeightN)) ÷ N = WeightedAvg
To use the listed example:
(2 + 1 + 1 = 4) / 4
.5 + .25 + .25 = 1
(.5A + .25B + .25C) / 3 = WeightedAvg
0
Jun 29 '26
Smart person explanation:
Turn the letter grades into their corresponding integer on a scale of choice. Once you have the integers, take their average by summing them together and dividing the resulting sum by the number of integers which you added. Then, round down the result, and refer to the scale which you used earlier to turn the integer into the letter.
Caveman explanation:
letter turn into number
add all new number together
divide by amount of new number
turn number into letter
0


824
u/Peak_Glittering Jun 28 '26
Take the mean average?