Find the bug! Why is this grading scale broken?


#1

I’d really appreciate some help with a tricky bug in a grade-setting script. There are six classes in Monsters of New Haven High. Each class has its own variable that describes how well you’re doing in that class, aka your grade.

I have a scene that calculates a display letter grade based on your current grade score, then averages all of your grade scores to provide a GPA. Grade changes only occur in multiples of 5 (usually +/- 5, occasionally 10.) So the formula for (add six grades together)/(divide by six) should always produce an average that is a multiple of 5… right?

I asked my testers to report the grades and GPA they received. Everyone got grades, but in a lot of the cases, their GPA was unknown. Every character runs the same script to determine these things. Here are some that had errors:

Playing as the Wendigo with an academic point score of 35:
Your current GPA is: unknown
Your individual grades are:
English - A-
Math - C-
Gym - A
Humanities - C
Home ec - B
Science - C+

Playing as the Goblin version of Einstein, with academics 80 I got:
GPA: unknown
English: A+
Maths: A
Gym: B
Humanities: A
Shop: A
Science: A

Here’s one that worked:
Your current GPA is: 3.5
Your individual grades are: English - A+ Math - C+ Gym - B Humanities - A Art - A+ Science - B-

Here is the full code for setting and displaying GPA:

*comment 70 "A" (4.0), 55 B (3.0), 40 C (2.0), 25 D (1.0), <=15 F (0)
*if (english_grade<0)
   *set english_grade 0
*if (math_grade<0)
   *set math_grade 0
*if (gym_grade<0)
   *set gym_grade 0
*if (humanities_grade<0)
   *set humanities_grade 0
*if (elective_grade<0)
   *set elective_grade 0
*if (science_grade<0)
   *set science_grade 0
*if (english_grade>=75)
   *set display_english_grade "A+"
*if (english_grade=70)
   *set display_english_grade "A"
*if (english_grade=65)
   *set display_english_grade "A-"
*if (english_grade=60)
   *set display_english_grade "B+"
*if (english_grade=55)
   *set display_english_grade "B"
*if (english_grade=50)
   *set display_english_grade "B-"
*if (english_grade=45)
   *set display_english_grade "C+"
*if (english_grade=40)
   *set display_english_grade "C"
*if (english_grade=35)
   *set display_english_grade "C-"
*if (english_grade=30)
   *set display_english_grade "D+"
*if (english_grade=25)
   *set display_english_grade "D"
*if (english_grade=20)
   *set display_english_grade "D-"
*if (english_grade<20)
   *set display_english_grade "F"
*if (math_grade>=75)
   *set display_math_grade "A+"
*if (math_grade=70)
   *set display_math_grade "A"
*if (math_grade=65)
   *set display_math_grade "A-"
*if (math_grade=60)
   *set display_math_grade "B+"
*if (math_grade=55)
   *set display_math_grade "B"
*if (math_grade=50)
   *set display_math_grade "B-"
*if (math_grade=45)
   *set display_math_grade "C+"
*if (math_grade=40)
   *set display_math_grade "C"
*if (math_grade=35)
   *set display_math_grade "C-"
*if (math_grade=30)
   *set display_math_grade "D+"
*if (math_grade=25)
   *set display_math_grade "D"
*if (math_grade=20)
   *set display_math_grade "D-"
*if (math_grade<20)
   *set display_math_grade "F"
*if (gym_grade>=75)
   *set display_gym_grade "A+"
*if (gym_grade=70)
   *set display_gym_grade "A"
*if (gym_grade=65)
   *set display_gym_grade "A-"
*if (gym_grade=60)
   *set display_gym_grade "B+"
*if (gym_grade=55)
   *set display_gym_grade "B"
*if (gym_grade=50)
   *set display_gym_grade "B-"
*if (gym_grade=45)
   *set display_gym_grade "C+"
*if (gym_grade=40)
   *set display_gym_grade "C"
*if (gym_grade=35)
   *set display_gym_grade "C-"
*if (gym_grade=30)
   *set display_gym_grade "D+"
*if (gym_grade=25)
   *set display_gym_grade "D"
*if (gym_grade=20)
   *set display_gym_grade "D-"
*if (gym_grade<20)
   *set display_gym_grade "F"
*if (humanities_grade>=75)
   *set display_humanities_grade "A+"
*if (humanities_grade=70)
   *set display_humanities_grade "A"
*if (humanities_grade=65)
   *set display_humanities_grade "A-"
*if (humanities_grade=60)
   *set display_humanities_grade "B+"
*if (humanities_grade=55)
   *set display_humanities_grade "B"
*if (humanities_grade=50)
   *set display_humanities_grade "B-"
*if (humanities_grade=45)
   *set display_humanities_grade "C+"
*if (humanities_grade=40)
   *set display_humanities_grade "C"
*if (humanities_grade=35)
   *set display_humanities_grade "C-"
*if (humanities_grade=30)
   *set display_humanities_grade "D+"
*if (humanities_grade=25)
   *set display_humanities_grade "D"
*if (humanities_grade=20)
   *set display_humanities_grade "D-"
*if (humanities_grade<20)
   *set display_humanities_grade "F"
*if (elective_grade>=75)
   *set display_elective_grade "A+"
*if (elective_grade=70)
   *set display_elective_grade "A"
*if (elective_grade=65)
   *set display_elective_grade "A-"
*if (elective_grade=60)
   *set display_elective_grade "B+"
*if (elective_grade=55)
   *set display_elective_grade "B"
*if (elective_grade=50)
   *set display_elective_grade "B-"
*if (elective_grade=45)
   *set display_elective_grade "C+"
*if (elective_grade=40)
   *set display_elective_grade "C"
*if (elective_grade=35)
   *set display_elective_grade "C-"
*if (elective_grade=30)
   *set display_elective_grade "D+"
*if (elective_grade=25)
   *set display_elective_grade "D"
*if (elective_grade=20)
   *set display_elective_grade "D-"
*if (elective_grade<20)
   *set display_elective_grade "F"
*if (science_grade>=75)
   *set display_science_grade "A+"
*if (science_grade=70)
   *set display_science_grade "A"
*if (science_grade=65)
   *set display_science_grade "A-"
*if (science_grade=60)
   *set display_science_grade "B+"
*if (science_grade=55)
   *set display_science_grade "B"
*if (science_grade=50)
   *set display_science_grade "B-"
*if (science_grade=45)
   *set display_science_grade "C+"
*if (science_grade=40)
   *set display_science_grade "C"
*if (science_grade=35)
   *set display_science_grade "C-"
*if (science_grade=30)
   *set display_science_grade "D+"
*if (science_grade=25)
   *set display_science_grade "D"
*if (science_grade=20)
   *set display_science_grade "D-"
*if (science_grade<20)
   *set display_science_grade "F"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)>=75
   *set GPA "4.5 (this is as high as your GPA can go)"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=70
   *set GPA "4.0"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=65
   *set GPA "3.5"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=60
   *set GPA "3.5"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=55
   *set GPA "3.0"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=50
   *set GPA "2.5"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=45
   *set GPA "2.5"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=40
   *set GPA "2.0"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=35
   *set GPA "1.5"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=30
   *set GPA "1.5"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)=25
   *set GPA "1.0"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)<=20
   *set GPA "0 (your GPA couldn't possibly get any worse)"
*return

Thanks in advance for any help you can give. (Also, feel free to steal whatever parts of the grading code are working for your own purposes.)


#2

(A+) + A + B + A + A + A
75 + 70 + 55 + 70 + 70 + 70 = 410
410/6 = 68.3
That’s not on the chart, so no grade.

You likely want a range not an = Or are you rounding the stats up/down somewhere I’m not seeing?


#3

As FairyGodfeather says if you’re taking an average then you’re going to often get results that aren’t multiples of 5, so you should either be rounding that result or changing your conditions to >= and putting them in reverse order (so the lows don’t override the highs).


#4

So yeah, this bug was entirely caused by my poor math skills. Thank you both!


#5

Dividing by 6 is not going to create a multiple of five. Basically, what’s happening, is that when you’re running the diagnostic to get an average, you’re not coming up with a number that is on the 5 point scale, so it’s not showing up as a known grade.

To fix this, turn your *if statements into this:

*if (math_grade>=75)
*if ((math_grade<75) and (math_grade>=70)

and so on. It should fix the problem…


#6

Ah … pardon, I didn’t even look to see that someone else had figured it out. >.< My bad, sorry.


#7

New version, which should fix the issue:

*comment 70 A (4.0), 55 B (3.0), 40 C (2.0), 25 D (1.0), <=15 F (0)
*if (english_grade<0)
   *set english_grade 0
*if (math_grade<0)
   *set math_grade 0
*if (gym_grade<0)
   *set gym_grade 0
*if (humanities_grade<0)
   *set humanities_grade 0
*if (elective_grade<0)
   *set elective_grade 0
*if (science_grade<0)
   *set science_grade 0
*if (english_grade>100)
   *set english_grade 100
*if (math_grade>100)
   *set math_grade 100
*if (gym_grade>100)
   *set gym_grade 100
*if (humanities_grade>100)
   *set humanities_grade 100
*if (elective_grade>100)
   *set elective_grade 100
*if (science_grade>100)
   *set science_grade 100
*if (english_grade>=75)
   *set display_english_grade "A+"
*if (english_grade=70)
   *set display_english_grade "A"
*if (english_grade=65)
   *set display_english_grade "A-"
*if (english_grade=60)
   *set display_english_grade "B+"
*if (english_grade=55)
   *set display_english_grade "B"
*if (english_grade=50)
   *set display_english_grade "B-"
*if (english_grade=45)
   *set display_english_grade "C+"
*if (english_grade=40)
   *set display_english_grade "C"
*if (english_grade=35)
   *set display_english_grade "C-"
*if (english_grade=30)
   *set display_english_grade "D+"
*if (english_grade=25)
   *set display_english_grade "D"
*if (english_grade=20)
   *set display_english_grade "D-"
*if (english_grade<20)
   *set display_english_grade "F"
*if (math_grade>=75)
   *set display_math_grade "A+"
*if (math_grade=70)
   *set display_math_grade "A"
*if (math_grade=65)
   *set display_math_grade "A-"
*if (math_grade=60)
   *set display_math_grade "B+"
*if (math_grade=55)
   *set display_math_grade "B"
*if (math_grade=50)
   *set display_math_grade "B-"
*if (math_grade=45)
   *set display_math_grade "C+"
*if (math_grade=40)
   *set display_math_grade "C"
*if (math_grade=35)
   *set display_math_grade "C-"
*if (math_grade=30)
   *set display_math_grade "D+"
*if (math_grade=25)
   *set display_math_grade "D"
*if (math_grade=20)
   *set display_math_grade "D-"
*if (math_grade<20)
   *set display_math_grade "F"
*if (gym_grade>=75)
   *set display_gym_grade "A+"
*if (gym_grade=70)
   *set display_gym_grade "A"
*if (gym_grade=65)
   *set display_gym_grade "A-"
*if (gym_grade=60)
   *set display_gym_grade "B+"
*if (gym_grade=55)
   *set display_gym_grade "B"
*if (gym_grade=50)
   *set display_gym_grade "B-"
*if (gym_grade=45)
   *set display_gym_grade "C+"
*if (gym_grade=40)
   *set display_gym_grade "C"
*if (gym_grade=35)
   *set display_gym_grade "C-"
*if (gym_grade=30)
   *set display_gym_grade "D+"
*if (gym_grade=25)
   *set display_gym_grade "D"
*if (gym_grade=20)
   *set display_gym_grade "D-"
*if (gym_grade<20)
   *set display_gym_grade "F"
*if (humanities_grade>=75)
   *set display_humanities_grade "A+"
*if (humanities_grade=70)
   *set display_humanities_grade "A"
*if (humanities_grade=65)
   *set display_humanities_grade "A-"
*if (humanities_grade=60)
   *set display_humanities_grade "B+"
*if (humanities_grade=55)
   *set display_humanities_grade "B"
*if (humanities_grade=50)
   *set display_humanities_grade "B-"
*if (humanities_grade=45)
   *set display_humanities_grade "C+"
*if (humanities_grade=40)
   *set display_humanities_grade "C"
*if (humanities_grade=35)
   *set display_humanities_grade "C-"
*if (humanities_grade=30)
   *set display_humanities_grade "D+"
*if (humanities_grade=25)
   *set display_humanities_grade "D"
*if (humanities_grade=20)
   *set display_humanities_grade "D-"
*if (humanities_grade<20)
   *set display_humanities_grade "F"
*if (elective_grade>=75)
   *set display_elective_grade "A+"
*if (elective_grade=70)
   *set display_elective_grade "A"
*if (elective_grade=65)
   *set display_elective_grade "A-"
*if (elective_grade=60)
   *set display_elective_grade "B+"
*if (elective_grade=55)
   *set display_elective_grade "B"
*if (elective_grade=50)
   *set display_elective_grade "B-"
*if (elective_grade=45)
   *set display_elective_grade "C+"
*if (elective_grade=40)
   *set display_elective_grade "C"
*if (elective_grade=35)
   *set display_elective_grade "C-"
*if (elective_grade=30)
   *set display_elective_grade "D+"
*if (elective_grade=25)
   *set display_elective_grade "D"
*if (elective_grade=20)
   *set display_elective_grade "D-"
*if (elective_grade<20)
   *set display_elective_grade "F"
*if (science_grade>=75)
   *set display_science_grade "A+"
*if (science_grade=70)
   *set display_science_grade "A"
*if (science_grade=65)
   *set display_science_grade "A-"
*if (science_grade=60)
   *set display_science_grade "B+"
*if (science_grade=55)
   *set display_science_grade "B"
*if (science_grade=50)
   *set display_science_grade "B-"
*if (science_grade=45)
   *set display_science_grade "C+"
*if (science_grade=40)
   *set display_science_grade "C"
*if (science_grade=35)
   *set display_science_grade "C-"
*if (science_grade=30)
   *set display_science_grade "D+"
*if (science_grade=25)
   *set display_science_grade "D"
*if (science_grade=20)
   *set display_science_grade "D-"
*if (science_grade<20)
   *set display_science_grade "F"
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)<=20
   *set GPA "0 (your GPA couldn't possibly get any worse)"
   *goto GPA_set
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)<30
   *set GPA "1.0"
   *goto GPA_set
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)<40
   *set GPA "1.5"
   *goto GPA_set
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)<45
   *set GPA "2.0"
   *goto GPA_set
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)<55
   *set GPA "2.5"
   *goto GPA_set
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)<60
   *set GPA "3.0"
   *goto GPA_set
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)<70
   *set GPA "3.5"
   *goto GPA_set
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)<75
   *set GPA "4.0"
   *goto GPA_set
*if (((((english_grade) + (math_grade)) + ((gym_grade) + (humanities_grade))) + ((elective_grade) + (science_grade)))/6)>=75
   *set GPA "4.5 (this is as high as your GPA can go)"
   *goto GPA_set
*label GPA_set
*return

Thanks, all. (And yes, I did fudge the grading scale to keep display grades vs. grade value in fives while trying to keep the right feel of effort for grades earned.) I also threw on an upper limit for grades, so in case I accidentally give someone too many chances to raise a certain grade, that extra credit can’t skew the others too far until I can re-balance it. (I might change the limit later, as I test it out.)