The TORCS Racing Board
Username: Password: Remember Me?
Lost Password Register
Author: phi | Created: 2017-10-31 19:01:37
Subject: Corkscrew - Raw Data
Hi Danny

What happened to Klin 1 (121 laps) to get behind Klin 2 (118 laps) and Jay Cob (42 laps)?
Last Edited: 2017-10-31 19:01:37 by phi
    Author: dummy | Created: 2017-10-31 21:10:46
    Subject: Re: Corkscrew - Raw Data
    I guess it's about time to look into the code that's making the rankings ;)
    It happened on e-track-2 as well, there fa1 2 should have been 14th instead of 17th for example.
    Last Edited: 2017-10-31 21:10:46 by dummy
    Author: firechief | Created: 2017-10-31 23:01:57
    Subject: Re: Corkscrew - Raw Data
    Its a bug in TORCS, its been around for a few years & we haven't found a fix yet. Its made more difficult by the fact that it only occurs sporadically. Here's a notable example from one of my test races last year on dirt-2:-

    It seems to be caused by the penalty calculations. When a car's been eliminated & was carrying a time penalty, all sorts of odd things happen.
    Last Edited: 2017-10-31 23:01:57 by firechief
      Author: phi | Created: 2017-11-01 00:03:39
      Subject: Re: Corkscrew - Raw Data
      Yes, I remember now an old thread ( I said that this did not make any sense, but Bernhard said it made perfect sense:

      Regarding the implemented algorithm it makes sense, yes, see:
      Around line 90, ReApplyRaceTimePenalties. Basically you run a virtual race against averaged laptimes as long as you have a penalty pending. Just clear it and you are fine.

      There is an issue though if the car is taken out of the race for another reason than damage (e.g. running out of fuel). This will be improved in the next version.

      I do not see the "whole picture", but the things are not very good in the way they are. I hope that in next version this problem can be solved.
      Last Edited: 2017-11-01 00:03:39 by phi
    Author: wdbee | Created: 2017-11-04 14:23:48
    Subject: Re: Corkscrew - Raw Data
    AFAIK results like this are caused by the "extrapolation" of the race.

    Berhards idea is to calculate the not driven laps of the race based on the result of the diven laps, when a car was taken out of the race. This is done to compare only "complete" races as final result. He's assuming that taking out the car is caused by bad luck, not by own setup issues/bad code/... .

    I had some cases from test races I did send to Bernhard. The extrapolation of the remaining race is not taking into account, that the cars driving all laps of the race have to pit, overlap opponents, drive through heavy traffic. At begin of the race there are no cars to overlap and there is no traffic, the fastest cars are in front. Using this laps and extrapolate it will result in much too good total race times for the cars taken out of the race, especially if they never did pit.

    So start with low fuel, drive a very fast lap and cause a damage over 10000 to make your car be taken out of the race. The current extrapolation should bring you at top of the ranking ;)
    Last Edited: 2017-11-04 14:23:48 by wdbee
      Author: firechief | Created: 2017-11-04 15:03:09
      Subject: Re: Corkscrew - Raw Data
      I'd have to ask why extrapolation is even necessary? Surely if a car is eliminated with 50 laps to go, no matter the reason, then it should be given a ranking behind every car that finished more laps. The only adjustment is adding on carried-over penalty time - that's all.

      I don't know of any racing series in the world that extrapolates the potential finishing position of eliminated cars as if they'd completed the race, and awards points accordingly. It would be farcical to do so.
      Last Edited: 2017-11-04 15:03:09 by firechief
        Author: phi | Created: 2017-11-04 18:24:12
        Subject: Re: Corkscrew - Raw Data
        Yes, it's simple. I am curious about the fact that this is not implemented and that extrapolation is necessary.
        Last Edited: 2017-11-04 18:24:12 by phi
          Author: berniw | Created: 2017-11-07 01:03:54
          Subject: Re: Corkscrew - Raw Data
          Just read the reasoning in the code, and think of a case where on Forza a driver goes straight over the grass instead of taking the chicane for the whole race, ending up maybe 5 laps in front of everybody else... the machine learning of Green Monster found this solution;-)

          In formula one it happend too, that a driver could run the final lap, because the 30 second penalty was pending, see reasoning in the code;-)

          Regards, Bernhard
          Last Edited: 2017-11-07 01:08:40 by berniw
            Author: firechief | Created: 2017-11-07 02:59:13
            Subject: Re: Corkscrew - Raw Data
            Surely though, in that case the car cutting the corner would build up a significant time penalty each lap, which would be added to its time at each pit stop, and then again at the end of the race to adjust its finishing position. Nobody has any argument against that.

            What I & others here are questioning are results like this:

            A car that was eliminated with 44 laps to go was ranked 6th, ahead of three cars that finished 17, 19 and 21 laps behind the leader. Each of those cars carried small time penalties that were in no way large enough to put them behind the car that was given 6th place. This kind of result just doesn't make any sense at all, which is why we believe there's either a bug or a flaw in the logic.
            Last Edited: 2017-11-07 02:59:13 by firechief
            Author: phi | Created: 2017-11-08 04:36:08
            Subject: Re: Corkscrew - Raw Data
            I understand the problem:

            Applying time penalties with cars in different laps is problematic, picture
            this situation: We have 3 cars running, pos 1 car is right behind the pos 3
            car (so it will overlap in a moment), pos 3 car is right behind pos 2 car,
            and pos 2 car has a 30s penalty pending. Now right before the finish line the pos 1 car passes (overlaps) the pos 3 car, so the race is done for pos 1 car, and a moment later for the pos 3 car. But the pos 2 car can finish its last lap, although it has a 30s penalty pending, which would have thrown it behind the pos 3 car, if the overlapping not had happened.

            So just adding times is not enough (btw. the FIA does just add times... weird).
            » (lines 66-75)

            Yet I recognize that something is wrong, and Andrew has put the question very well and clearly.

            I took the liberty of making some observations (I hope I can do it in an understandable way):

            A) Should we let car 2 recover the 30s on its complementary lap, or is it meant to be behind car 3? The linear model put car 2 in the back of car 3? car 2 has a penalty to be met, but car 3 is penalized relatively to car 2 [l1 = l2 + 1 (line 151)] only because it is overlapped, and... is this correct? If the race stopped when the car 1 cut the finish line and the times and the distances were calculated, the car 2 would be behind the car 3, even though it was overlapped by car 1; on the other hand we would have a new problem if there was a new car between car 2 and car 3 (the car 2.5), also not having overlapped by car 1, and now competes with car 2 on the last lap -- the race should continue, at least for these two cars; it is obvious that the race should not stop as soon as the winner cuts the finish line, and TORCS is correct not to stop it.

            B) The condition 'line 138' can account for out of race cars for reasons other than damage, thus correcting the existing error. But the algorithm should end here? there are cars out of race that are ahead of others that can reach them on the last lap, and the penalties of these have to be taken into account: (i) if a car 6 stops for lack of gas (or another reason) 10 meters away from cutting the finish line, and car 7 overtakes it with 50s penalty? and (ii) what if this out of race car has a 2 minute penalty? should not we take into account the penalties of cars out of racing? and (iii) if car 4 gets out of the race, and cars 11 and 12 (at 40 laps of the car 4) compete side by side and one of them has a penalty to meet?

            C) Would work if we based the algorithm on the following schema (lines 128-166)?

            int j;
            for(i = 1; i < s->_ncars; i++) {
            j = i;
            while(j > 0) {
            tdble d1 = s->cars[j - 1]->_distRaced;
            tdble d2 = s->cars[j]->_distRaced;

            if(s->cars[j - 1]->_penaltyTime > 0.0f) {
            d1 -= d1 / s->cars[j - 1]->_curTime * s->cars[j - 1]->_penaltyTime;

            if(s->cars[j]->_penaltyTime > 0.0f) {
            d2 -= d2 / s->cars[j]->_curTime * s->cars[j]->_penaltyTime;

            if(d1 < d2) {
            // Swap
            car = s->cars[j];
            s->cars[j] = s->cars[j - 1];
            s->cars[j - 1] = car;
            s->cars[j]->_pos = j + 1;
            s->cars[j - 1]->_pos = j;



            j = 0;

            It seems to me that in this situation car 2 would be ahead of car 3, but this also seems to happen in the current algorithm. All other situations seem to me (???) resolved.
            Last Edited: 2017-11-08 04:36:08 by phi
        Author: wdbee | Created: 2017-11-05 10:44:06
        Subject: Re: Corkscrew - Raw Data
        +1 from me ;)
        Last Edited: 2017-11-05 10:44:06 by wdbee