The online racing simulator
InSim - Drift Calculator Request
I am looking for a drift calculator. Depending on angle and speed, if InSim can calculate points. 1 lap races.

Ex. 5 people racing, and each person has a tally of their score up at the top. However, if someone spins out, or hits another car, or goes off track the points from that specific drift is set to zero.
LFSLapper is already set up to do some of that.
the algorithm is kinda cheesy (i think score=score+(angle*speed)), but it is something.

someone should take a look... i bet you could do everything a drifter might want in a few lines.
If someone could develop a code which calculates a score by using the speed through the corner, the angle, and how good the line is (can use LFS built-in racing line)

IT WOULD BE GREATLY APPRECIATED. I am programming-illiterate. lolz
Here is the drift scoring calculation from insim "Drive_LFSS"

Take into considaration:
Time,
Speed,
CarTraj -> CarAngle,
TrackTraj->CarTraj,
CarAnlge->TrackTraj,
Counter Correction to keep Drifting,
Stay on track,
LostControl,
360 and more,


internal void Update(Driver car)
{
if(!isOn)
return;

packetReceive++;
double speedKhm = car.GetSpeedKmh();
double angleTotraj = car.GetShorterAngleToReachTraj();
if (!started)
{
if(speedKhm > MIN_SPEED)
{
if (angleTotraj > START_ANGLE && angleTotraj < START_MAX_ANGLE)
Start(car);
}
}
else
{
//Player is Too Slow End without Score
if (speedKhm < MIN_SPEED || isLostControl)
{
End(car);
return;
}
//This will occur when orientation change is direction
//Into a perfect drift this happen only at the complete end and not much.
double oriSpeed = car.GetOrientationSpeed();
if(clockWise != (oriSpeed>0))
{
if(Math.Abs(oriSpeed) > MIN_COUNTER_ANGLE_SPEED)
{//he apply correction
counterCorrection++;
if (Math.Abs(oriSpeed) > MAX_COUNTER_ANGLE_SPEED)
{//This should mean a lost control, since is doing "S"
End(car);
return;
}
}
}

//Record Max Angle
if (maxAngleDiff < angleTotraj)
maxAngleDiff = angleTotraj;

//Process Score
ComputeScore(car);

//Find END
if (angleTotraj < STOP_ANGLE)
{
if (score > 0 && scoreTick > (MIN_DRIFT_TIME_MS / SCORE_TICK_TIME_MS))
Sucess(car);
else
End(car);
}
}
}
private void Start(Driver driver)
{
started = true;
startTime = DateTime.Now;
clockWise = (driver.GetOrientationSpeed() > 0 ? true : false);
maxAngleDiff = 0.0d;
scoreAngle = 0.0d;
startSpeed = driver.GetSpeedKmh();
scoreSpeed = 0;
score = 0;
scoreTick = 0;
counterCorrection = 0;
packetReceive = 0;
/*if(driver.IsAdmin)
{
driver.SendUpdateButton((ushort)Button_Entry.INFO_1, "^2Drift Start "+(clockWise?"":"^7-"));
driver.SendUpdateButton((ushort)Button_Entry.INFO_2, "^7Score ^3" + score);
}*/
}
private void End(Driver driver)
{
started = false;
/*if(driver.IsAdmin)
{
driver.SendUpdateButton((ushort)Button_Entry.INFO_1, "^1Drift End");
}*/
}
private void Sucess(Driver driver)
{
if (maxAngleDiff >= BONUS_ANGLE)
score *= BONUS_ANGLE_SCORE_RATIO;

Log.feature(((IDriver)driver).DriverName + ", Done Drift Score: " + (uint)score + ".\r\n");
End(driver);

//Debug think
/*if(((Driver)driver).IsAdmin)
{
((IButton)driver).SendUpdateButton((ushort)Button_Entry.INFO_2, "^7Score ^2" + score);
}*/
((Driver)driver).driftScoreByTime += (uint)score;
if (((Driver)driver).ISession.Script.CarDriftScoring((ICar)driver, (uint)score))
return;
}
private void ComputeScore(Driver driver)
{
//Scoring calculation occur only at all SCORE_TICK_TIME_MS diff.
TimeSpan timeDiff = DateTime.Now - startTime;
if (timeDiff.TotalMilliseconds / SCORE_TICK_TIME_MS < scoreTick)
return;

//How many time we calculated the score
scoreTick++;

//Calculate correction ratio
double correctionRatio = (100.0d-(counterCorrection * 100.0d/packetReceive))/100.0d;

//Gave point for Angle
double angleToReach = driver.GetAngleToReachTraj(clockWise);
scoreAngle += (360.0d - angleToReach) * SCORE_ANGLE_RATIO;

//If player goes faster then start speed WOW, if not loose a little each time
double _scoreSpeed = ((driver.GetSpeedKmh() * 100.0d / startSpeed) - 100.0d) * SCORE_SPEED_RATIO;
if(_scoreSpeed <0.0d)
_scoreSpeed += (startSpeed / 35.0d) * (double)scoreTick;
scoreSpeed += _scoreSpeed;

//All By Correction %, Can only Lower Score
score = ((scoreAngle + scoreSpeed) * correctionRatio) - ((correctionRatio-1.0d)*40.0d);

//Only for debug purpose
/*if(((Driver)car).IsAdmin)
{
((IButton)car).SendUpdateButton((ushort)Button_Entry.INFO_2, "^7Score ^3"+score);
((IButton)car).SendUpdateButton((ushort)Button_Entry.INFO_3, "^3SA ^7" + scoreAngle);
((IButton)car).SendUpdateButton((ushort)Button_Entry.INFO_4, "^3SS ^7" + scoreSpeed);
((IButton)car).SendUpdateButton((ushort)Button_Entry.INFO_5, "^3CR ^7" + correctionRatio);
}*/
}
public bool IsOn
{
get { return isOn; }
set
{
isOn = value;
started = false;
}
}
}

Here is the LostControl thing, make a difference between a drift and a lost control , really depend on the Track Direction


double tracjectoryDiff = GetAngleDiff(trackOrientation,car.GetTrajectory());
car.SendTrajDisplay(GetTrajectoryDisplay(tracjectoryDiff));

double orientationDiff = GetAngleDiff(trackOrientation, car.GetOrientation());
car.SendOriDisplay( GetOrientationDisplay(orientationDiff) );

double perpenDist = GetPerpendicularDist(car.GetPosX(), car.GetPosY(), node.centreX, node.centreY, node.centreX + node.dirX, node.centreY + node.dirY);
car.SendPathDisplay(GetPathSideDisplay(node.driveLeft,node.driveRight, perpenDist,car));


if (car.GetSpeedMs() > 0.1 && (Math.Abs(tracjectoryDiff) > 16 && Math.Abs(orientationDiff) > 19))
lostControl = true;
else if (car.GetSpeedMs() > 0.1 && Math.Abs(orientationDiff) > 19)
drift = true;

Scoring happen at a static Tick time , me i use 150ms , so each 150ms i calculate your drift score until i detect your no more into a drift or you completely lost control.


P.S. a sucess 360 into a drift can be real good if you keep on the Track.



All this code is very old and was made before i complete Map System, so it can be a lot better.

Let say i don't have motivation or help needed to update that code , but hope gave you idea to build your own or anyone else bye bye!
I've done something like that in LFSLapper, but not to the extent you're looking for.

Might be a start?
Attached images
DriftMaster.bmp
Where i need to put that code ?
Quote from kepp1313 :Where i need to put that code ?

If you've got recent copy of lapper (any of the version 6 releases), then read posts 4 then 2 HERE.

Note: Lapper is not laggy - score for any drift will only show once drift completed.

It may be possible for lapper to show score and angle as drift is ongoing, but I haven't found anyway to do that using the standard lapper variables and functions.
Quote from sinanju :It may be possible for lapper to show score and angle as drift is ongoing, but I haven't found anyway to do that using the standard lapper variables and functions.

Although this isn't a Lapper topic, it is possible to have a constantly refreshed value being displayed in Lapper.
I've used several of them for a hidden project I work on every now and then.
Not totaly sure if it could be used for drift as well, but I think it can be.
I see in demo server drift insim in c++
It's probable that all server owners don't read this forum all the time, so the ones using the code you've seen may be unaware of your request.

As you have found a server that is using the code (of whatever variety), why not try asking admins when next on server, or if there is a website, asking there?
Yes, there is, but admins is not giving me thad drift calculator, and i'm askig you! Smile
Then you are still asking the wrong person! I don't know how to code.

I made a drift scorer in LFSLapper, but there's little 'coding' involved.

Good things about it though, is that it works, is consistent, same for all drivers, and is free.

So it doesn't show an ongoing score every 10th of a second. So what? Drivers compare their scores at the end of a lap, to show that they can drift consistently for the full lap, and not just one turn. I've lost count on the number of drifters I've seen on my servers who get 9/10ths round, spin on last couple of corners, and lose all their points. It's tough. But then so is hotlapping. You may have world record splits, but worth nothing unless you finish the lap.

*Rant*
Why do you think someone can come along, play LFS for few months, think "I'd like to run a server", then expect to get code for free? That any server owner should give you their code? Code that probably took a lot of time, money and effort to make. Forgetting for a minute that you haven't even bothered to pay for a S1 or S2 license (and don't say you don't have money for a license when you want to run a server), why should they increase the competition? Why should they give away something that may make their server unique? Why, when there is already well over 300 other servers all competing to get drivers to race/drift/drag/cruise, should they help another one get started? And especially one who has a demo account? You've had a demo account for over 6 months without making a commitment - you're not going to be making a commitment about putting effort into making code - are you going to be as committed about running a server? Apart from asking for things, what 'effort' are you putting into all this?

Now, if you were to come onto this forum and say something like - trying to do this, done this, doesn't work, what can I do? - then you will get people falling over themselves to help. This is because you have made some effort, and they like to see the effort rewarded.

You are just another in a long line of people who want and expect to get, without putting in any effort.

Maybe you'll get lucky. No effort required for that.
*End Rant*
-
(kingwalter) DELETED by kingwalter
-
(kingwalter) DELETED by kingwalter
Where need put this codes?
You don't have to put it anywhere...it's already included (in V6)...you only need to configure 2 files slightly to get it working. In fact, as you only have a demo license and can't use all 20 cars available, only the addonused.lpr file needs slight change. But if you want to future proof things in case you do purchase a license, then worth also changing the lfslapper.lpr file too.

These files can be opened in any text editor.

Read post 7 (which takes you to another post where it's explained what to do).

FGED GREDG RDFGDR GSFDG