Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count perfect lines instead of line perfection score #903

Closed
wants to merge 1 commit into from

Conversation

DeinAlptraum
Copy link
Contributor

This should reduce floating point arithmetic errors.
Fixes #844

This should reduce floating point arithmetic errors.
Fixes UltraStar-Deluxe#844
@DeinAlptraum
Copy link
Contributor Author

This should resolve the issue. I've tested it on two songs that had the issue, and both of them got resolved. I am not entirely sure the issue can't occur in other ways as well though. Here is a minimal example for a file where it occurs:

#TITLE:Test Song
#ARTIST:Test Band
#LANGUAGE:English
#YEAR:2003
#MP3:whatever.mp3
#BPM:988.32
#GAP:0
#END:1000
: 0 1 0 A
- 5
: 10 1 0 B
- 15
* 20 1 0 C
- 25
: 30 1 0 D
- 35
: 40 1 0 E
- 45
: 50 1 0 F
- 55
E

Apparently the floating point inaccuracy leads to rounding errors for the "line perfection" part of the score. Here are the line-by-line scores for the above txt on a perfect playthrough, which I've printed out after every single line (beat) of the file

# Score after Line 1
 1.2857142857142858E+003
 0.0000000000000000E+000
 1.6666666666666666E+002
# Score after Line 2
 2.5714285714285716E+003
 0.0000000000000000E+000
 3.3333333333333331E+002
# Score after Line 3
 2.5714285714285716E+003
 2.5714285714285716E+003
 5.0000000000000000E+002
# Score after Line 4
 3.8571428571428573E+003
 2.5714285714285716E+003
 6.6666666666666663E+002
# Score after Line 5
 5.1428571428571431E+003
 2.5714285714285716E+003
 8.3333333333333326E+002
# Score after Line 6
 6.4285714285714294E+003
 2.5714285714285716E+003
 9.9999999999999989E+002

These are the values of Score, ScoreGolden, ScoreLine respectively. After every line, the total line bonus score at that point is computed as CurrentPlayer.ScoreLineInt := Floor(CurrentPlayer.ScoreLine / 10) * 10; which turns the 999.999... linebonus score into 990, for a total score of 9990 score.

@basisbit
Copy link
Member

basisbit commented Oct 5, 2024

Sorry, but I don't think we should change the score calculation if avoidable in order to not make it easy to replace older highscores with what effectively was not a better result than before.
If you want to stop people from reporting the issue of it not being possible to reach 10000, just check if the final score is 9990, and if yes, set it to 10000 instead. I can message those who I know who run online highscore pages to have them execute a SQL command to do the same for already existing online high scores.

@basisbit
Copy link
Member

basisbit commented Oct 5, 2024

Alternatively, check if the line bonus is above or equal to 995 but below 1000 before the /10*10 and if yes, add 10 at the end

@barbeque-squared
Copy link
Member

barbeque-squared commented Oct 5, 2024

CurrentPlayer.ScoreLineInt := Floor(CurrentPlayer.ScoreLine / 10) * 10;

Isn't this code simply... plain wrong in the first place? As far as I understand it, ScoreLineInt can (well, should) be anywhere from 0 to 1000 (both inclusive). But due to the Floor you'll only get to 1000 if the input is already 1000. 999.999999999 isn't good enough to be rounded to a 1000, which in my opinion is stupid enough, but float will give you that kind of deviations anyway.

My only question is: at what point a score is "good enough" to be a 1000? Basically it's going to be either:

  • >= 995 (the Floor should have been a Round)
  • >= 999.5 (flooring behaviour is intentional but you have to Floor(Round(ScoreLine)/10)*10)

I don't know which if the two is the correct one, but I'm pretty sure one of them is.

EDIT: naturally whatever is chosen will also affect lower scores, but we're talking a maximum of +10 in the final number -- a correction to the number it should have always been.

@DeinAlptraum
Copy link
Contributor Author

@basisbit I understand your concern, but this change should only affect rounding errors, making a difference of at most 10 points. Do you think this is enough of an issue to not go through with this?
Your proposal also sounds fine to me, but imo a proper fix would be preferable to this sort of workaround, if that is possible.

@barbeque-squared well that's a bit of a different problem: the bug I'm trying to resolve here is that you sometimes can't get 1000 line bonus even when you hit everything perfectly (I checked by setting all notes to hit in the code) due to floating point accuracy errors which computes e.g. 166.666... * 6 = 999.999...
Whether the Floor(Round(ScoreLine)/10)*10) is fair is another question. Do note that it is not required to actually sing a line perfectly to get the full line bonus. From UScreenSingController.pas:

// determine LinePerfection
// Note: the "+2" extra points are a little bonus so the player does not
// have to be that perfect to reach the bonus steps.
LinePerfection := LineScore / (MaxLineScore - 2);

@basisbit
Copy link
Member

basisbit commented Oct 5, 2024

@DeinAlptraum I agree with you. My only concern was the slightly different calculation for anything that is not close to full points. I am okay with any of the solutions, but I would personally prefer if we limit the change to only very high scores to not cause any issues (which we might not yet see) regarding online highscores.

@basisbit
Copy link
Member

basisbit commented Oct 8, 2024

superseded by #910

@basisbit basisbit closed this Oct 8, 2024
@DeinAlptraum DeinAlptraum deleted the fix-9990 branch October 8, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The highest possible score is 9990
3 participants