64Soft / NRatings.Client

NRatings for NR2003
MIT License
8 stars 5 forks source link

NR2003 Track Type is not inclusive of all tracks #27

Closed ai-line-mod closed 2 years ago

ai-line-mod commented 2 years ago

There appears to be an anomaly in the "Use NR2003 Track Type" option. If you select the year 2003, select all races, and then Variable Inspector, there are 2 RC, 4 SS, 6 ST, and 6 SW races when you select the Filter by Track Type drop down, totaling 18 races (half the season). However if you do not select this rating, there are 2 RC, 6 ST, 10 SS, and 18 SW, totaling the appropriate 36 races. It seems that if you select to filter by NR2003 track type, the outcome should be 2 RC, 4 SS, 6 ST, and 24 SW, where SW is anything one mile or over and not restrictor plate or road course (corresponding to track types 1,2, and 3 in the game).

ai-line-mod commented 2 years ago

I believe I might have a reasonable hypothesis on what is causing this issue. Using the 2003 season as an example still, there are 6 speedway courses if "Use NR2003 Track Type" is checked. That is the difference between how many superspeedway tracks there are between the two settings (10-4) and the difference between how many speedway tracks are expected (24-18). By looking at the results of select years and matching winners with the track types in NRatings Variable Inspector, it appears that the six races that comprise the track type "speedway" when "Use NR2003 Track Type" is selected are precisely the six races which are considered speedway by NR2003, and superspeedway by other standards (non road course tracks 2 miles or greater in length; i.e. California, Indianapolis, Michigan x2, Pocono x2).

This leads me to believe that there is an error in the logic, where if "use the NR2003 track type" is selected, the races at these tracks are used as the type speedway, replacing the existing 18 speedway tracks, rather than being added to the existing 18 speedway races. I'm sure the code is not as simple as changing an if statement or modifying how an array is aggregated... But I am fairly certain that this is the cause of the issue.

64Soft commented 2 years ago

Might have a lead on the issue. In this file you can see the logic what determines the "regular" tracktype and the "NR2003" tracktype: https://github.com/64Soft/NRatings.Client/blob/main/src/NRatings.Client/Domain/Race.cs. In the NR2003TrackTypeId logic I think races with tracklength >= 1 mile and < 2 miles that do NOT have the words Daytona or Talladega in their tracknames, do not satisfy any of the "if" conditions and thus return null for the property. To fix it I'll need to figure out again exactly what logic NR2003 uses to determine its tracktypes as it's been a while since I've coded this and I've stopped playing NR2003 a long time ago. If you can shed some light on it please feel free :-)

ai-line-mod commented 2 years ago

Ah yes there it is! Starting with the if statement on 48:

                if (TrackLengthMiles < 1.0)
                    return "ST";
                else if (this.Track.Name.Contains("Daytona") || this.Track.Name.Contains("Talladega"))
                    return "SS";
                if (TrackLengthMiles >= 2.0)
                    return "SW";

should be:

                if (TrackLengthMiles < 1.0)
                    return "ST";
                else if (this.Track.Name.Contains("Daytona") || this.Track.Name.Contains("Talladega"))
                    return "SS";
                if (TrackLengthMiles >= 1.0)
                    return "SW";

It's strange to me that it needs to call out Daytona and Talladega before identifying entities which are 1 mile or greater, but maybe that's correct? Otherwise the else if and the final if statement might need to be switched around. However, just changing the if (TrackLengthMiles >= 2.0) to if (TrackLengthMiles >= 1.0) on line 54 might do the trick, since the logic seems to work out just fine as is when running the program.

64Soft commented 2 years ago

It's strange to me that it needs to call out Daytona and Talladega before identifying entities which are 1 mile or greater, but maybe that's correct?

Well if the check on Daytona or Talladega would come as last, it would already have satisfied the condition TrackLengthMiles >= 1.0 and returned "SW"

I'll make the correction from 2.0 to 1.0 in that final if statement.

ai-line-mod commented 2 years ago

Great thank you! I think I also found a possible solution to the other issue brought up here: https://github.com/64Soft/NRatings.Client/issues/26

64Soft commented 2 years ago

First of all happy New Year :-). This has now been fixed in PR #28 and the new client (v5.1.8) has been published. Please confirm if this now works as intended.

ai-line-mod commented 2 years ago

Happy new year! Yes, I checked a few series over several years and this release has resolved this issue. Now, the sum of all races as a result of sorting by the track type subset totals all races for a season (or however many selected). Thank you very much!

64Soft commented 2 years ago

You're welcome