- update dandroid's driver
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8135 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 4d43ede696819e497f9544d5341823800905159f Former-commit-id: ca1811d7e92032c8d153251755f2c3bec2a7f68d
This commit is contained in:
parent
059b6b277e
commit
129af0a0d4
5 changed files with 111 additions and 89 deletions
|
@ -140,13 +140,13 @@ void DanLine::createSectors(std::vector <DanSector>& sect)
|
|||
dansect.fromstart = mLine[i].fromstart;
|
||||
lastfromstart = dansect.fromstart;
|
||||
sect.push_back(dansect);
|
||||
//GfOut("fs:%g radius:%g\n", mLine[i].fromstart, fabs(mLine[i].radius));
|
||||
LogDANDROID.debug("fs:%g radius:%g\n", mLine[i].fromstart, fabs(mLine[i].radius));
|
||||
}
|
||||
else
|
||||
{
|
||||
sect[sector].fromstart = mLine[i].fromstart;
|
||||
lastfromstart = mLine[i].fromstart;
|
||||
//GfOut("overwrite fs:%g radius:%g\n", mLine[i].fromstart, fabs(mLine[i].radius));
|
||||
LogDANDROID.debug("overwrite fs:%g radius:%g\n", mLine[i].fromstart, fabs(mLine[i].radius));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -451,6 +451,7 @@ void TDriver::updateWheels()
|
|||
|
||||
tireF = MIN(oCar->_tyreCondition(0), oCar->_tyreCondition(1));
|
||||
tireR = MIN(oCar->_tyreCondition(2), oCar->_tyreCondition(3));
|
||||
|
||||
mTirecondition = MIN(tireF, tireR);
|
||||
}
|
||||
|
||||
|
@ -1815,6 +1816,7 @@ void TDriver::readPrivateSection(PCarSettings* CarParmHandle)
|
|||
mBRAKESCALE = GfParmGetNum(*CarParmHandle, "private", "brakescale", (char*)NULL, 1.9);
|
||||
mBUMPSPEEDFACTOR = GfParmGetNum(*CarParmHandle, "private", "bumpspeedfactor", (char*)NULL, 3.0);
|
||||
mFUELPERMETER = GfParmGetNum(*CarParmHandle, "private", "fuelpermeter", (char*)NULL, 0.001f);
|
||||
mWEARPERMETER = GfParmGetNum(*CarParmHandle, "private", "wearpermeter", (char*)NULL, 0.001f);
|
||||
mFUELWEIGHTFACTOR = GfParmGetNum(*CarParmHandle, "private", "fuelweightfactor", (char*)NULL, 1.0);
|
||||
mPITDAMAGE = (int)GfParmGetNum(*CarParmHandle, "private", "pitdamage", (char*)NULL, 5000);
|
||||
mPITENTRYMARGIN = GfParmGetNum(*CarParmHandle, "private", "pitentrymargin", (char*)NULL, 200.0);
|
||||
|
@ -2367,7 +2369,8 @@ void TDriver::updateCurveAhead()
|
|||
|
||||
if (!mCurveAhead)
|
||||
{
|
||||
if (mTrackType != TR_STR && mTrackRadius < 200.0) {
|
||||
if (mTrackType != TR_STR && mTrackRadius < 200.0)
|
||||
{
|
||||
mCurveAheadFromStart = fromStart(mFromStart + 5);
|
||||
mCurveAhead = true;
|
||||
}
|
||||
|
@ -2504,7 +2507,7 @@ void TDriver::calcMaxspeed()
|
|||
}
|
||||
}
|
||||
|
||||
mMaxspeed = mSkillGlobal * mMaxspeed * mTirecondition;
|
||||
mMaxspeed = mSkillGlobal * mMaxspeed;
|
||||
|
||||
if(mHASTYC)
|
||||
{
|
||||
|
@ -2698,10 +2701,22 @@ bool TDriver::hysteresis(bool lastout, double in, double hyst)
|
|||
|
||||
double TDriver::getFuel(double dist)
|
||||
{
|
||||
double fuel = dist * mFUELPERMETER;
|
||||
if (mTestpitstop) {
|
||||
if (mHASTYC)
|
||||
{
|
||||
double tiredist = dist / mWEARPERMETER;
|
||||
LogDANDROID.info("Distance : %.2f - Tire distance : %.7g\n", dist, tiredist);
|
||||
double mindist = MIN(dist, tiredist);
|
||||
LogDANDROID.info("Minimum distance : %.3f\n", mindist);
|
||||
dist = mindist;
|
||||
}
|
||||
|
||||
double fuel = 1.2 * dist * mFUELPERMETER;
|
||||
|
||||
if (mTestpitstop)
|
||||
{
|
||||
fuel = 1.0 * mTrack->length * mFUELPERMETER;
|
||||
}
|
||||
|
||||
return fuel = MAX(MIN(fuel, mTANKVOL), 0.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -170,103 +170,103 @@ private:
|
|||
Opponent* mOppLetPass;
|
||||
double mOppDist;
|
||||
double mOppSidedist;
|
||||
bool mOppAside;
|
||||
bool mOppLeft;
|
||||
bool mOppLeftHyst;
|
||||
bool mOppLeftOfMe;
|
||||
bool mOppLeftOfMeHyst;
|
||||
int mOppPredictSide;
|
||||
bool mOppInFrontspace;
|
||||
bool mBackmarkerInFrontOfTeammate;
|
||||
bool mTwoOppsAside;
|
||||
bool mOppComingFastBehind;
|
||||
bool prev_mOppComingFastBehind;
|
||||
bool mLearning;
|
||||
bool mTestpitstop;
|
||||
int mTestLine;
|
||||
int mDriverMsgLevel;
|
||||
int mDriverMsgCarIndex;
|
||||
Pit mPit;
|
||||
bool mOppAside;
|
||||
bool mOppLeft;
|
||||
bool mOppLeftHyst;
|
||||
bool mOppLeftOfMe;
|
||||
bool mOppLeftOfMeHyst;
|
||||
int mOppPredictSide;
|
||||
bool mOppInFrontspace;
|
||||
bool mBackmarkerInFrontOfTeammate;
|
||||
bool mTwoOppsAside;
|
||||
bool mOppComingFastBehind;
|
||||
bool prev_mOppComingFastBehind;
|
||||
bool mLearning;
|
||||
bool mTestpitstop;
|
||||
int mTestLine;
|
||||
int mDriverMsgLevel;
|
||||
int mDriverMsgCarIndex;
|
||||
Pit mPit;
|
||||
double mMu; // friction coefficient
|
||||
double mTirecondition;
|
||||
double mMass; // mass of car + fuel
|
||||
double mSpeed;
|
||||
double mClutchtime;
|
||||
int mPrevgear;
|
||||
bool mControlAttackAngle;
|
||||
bool prev_mControlAttackAngle;
|
||||
int mPrevgear;
|
||||
bool mControlAttackAngle;
|
||||
bool prev_mControlAttackAngle;
|
||||
double mAttackAngle;
|
||||
bool mControlYawRate;
|
||||
bool prev_mControlYawRate;
|
||||
bool mBumpSpeed;
|
||||
bool prev_mBumpSpeed;
|
||||
bool mControlYawRate;
|
||||
bool prev_mControlYawRate;
|
||||
bool mBumpSpeed;
|
||||
bool prev_mBumpSpeed;
|
||||
double mSectorTime;
|
||||
double mOldTimer;
|
||||
bool mTenthTimer;
|
||||
int mShiftTimer;
|
||||
int mGear;
|
||||
bool mStuck;
|
||||
int mStuckcount;
|
||||
bool mStateChange;
|
||||
bool mPathChange;
|
||||
bool mTenthTimer;
|
||||
int mShiftTimer;
|
||||
int mGear;
|
||||
bool mStuck;
|
||||
int mStuckcount;
|
||||
bool mStateChange;
|
||||
bool mPathChange;
|
||||
double mPathChangeTime;
|
||||
bool mOvertake;
|
||||
bool prev_mOvertake;
|
||||
int mOvertakeTimer;
|
||||
int mOvertakePath;
|
||||
bool mLetPass;
|
||||
bool prev_mLetPass;
|
||||
bool mLeavePit;
|
||||
bool mOvertake;
|
||||
bool prev_mOvertake;
|
||||
int mOvertakeTimer;
|
||||
int mOvertakePath;
|
||||
bool mLetPass;
|
||||
bool prev_mLetPass;
|
||||
bool mLeavePit;
|
||||
double mFriction;
|
||||
double mCentrifugal;
|
||||
double mBrakeFriction;
|
||||
double mBrakeforce;
|
||||
double mBrakedistfactor;
|
||||
double mBorderdist;
|
||||
bool mOnLeftSide;
|
||||
bool mTargetOnLeftSide;
|
||||
int mTrackType;
|
||||
bool mOnLeftSide;
|
||||
bool mTargetOnLeftSide;
|
||||
int mTrackType;
|
||||
double mTrackRadius;
|
||||
double mCurvature;
|
||||
bool mTargetOnCurveInside;
|
||||
bool mTargetOnCurveInside;
|
||||
double mAngleToTrack;
|
||||
bool mAngleToLeft;
|
||||
bool mPointingToWall;
|
||||
bool mAngleToLeft;
|
||||
bool mPointingToWall;
|
||||
double mWallToMiddleAbs;
|
||||
double mWalldist;
|
||||
int mLastDamage;
|
||||
int mDamageDiff;
|
||||
int mPrevRacePos;
|
||||
int mRacePosChange;
|
||||
int mLastDamage;
|
||||
int mDamageDiff;
|
||||
int mPrevRacePos;
|
||||
int mRacePosChange;
|
||||
double mAccel;
|
||||
double mAccelAvg;
|
||||
double mAccelAvgSum;
|
||||
int mAccelAvgCount;
|
||||
int mAccelAvgCount;
|
||||
double mMaxspeed;
|
||||
std::vector <DanSector> mSect;
|
||||
int mSector;
|
||||
int prev_mSector;
|
||||
int mSector;
|
||||
int prev_mSector;
|
||||
double mSectSpeedfactor;
|
||||
PathInfo mPath[3];
|
||||
bool mCurveAhead;
|
||||
bool prev_mCurveAhead;
|
||||
bool mCurveAhead;
|
||||
bool prev_mCurveAhead;
|
||||
double mCurveAheadFromStart;
|
||||
bool mDrivingFast;
|
||||
bool prev_mDrivingFast;
|
||||
int mDrivingFastCount;
|
||||
bool mCatchingOpp;
|
||||
bool mLearnSectTime;
|
||||
bool mGetLapTime;
|
||||
bool mDrivingFast;
|
||||
bool prev_mDrivingFast;
|
||||
int mDrivingFastCount;
|
||||
bool mCatchingOpp;
|
||||
bool mLearnSectTime;
|
||||
bool mGetLapTime;
|
||||
double mLastLapTime;
|
||||
double mBestLapTime;
|
||||
bool mLearnLap;
|
||||
bool mAllSectorsFaster;
|
||||
bool mLearnSingleSector;
|
||||
int mLearnSector;
|
||||
bool mNewFile;
|
||||
bool mLearnedAll;
|
||||
bool mOfftrackInSector;
|
||||
bool mFinalLearnLap;
|
||||
bool mLearnLap;
|
||||
bool mAllSectorsFaster;
|
||||
bool mLearnSingleSector;
|
||||
int mLearnSector;
|
||||
bool mNewFile;
|
||||
bool mLearnedAll;
|
||||
bool mOfftrackInSector;
|
||||
bool mFinalLearnLap;
|
||||
double mFromStart;
|
||||
double mToMiddle;
|
||||
double mTargetFromstart;
|
||||
|
@ -274,33 +274,33 @@ private:
|
|||
double mNormalTargetToMiddle;
|
||||
double mPrevTargetdiff;
|
||||
double mTargetAngle;
|
||||
bool mMaxSteerAngle;
|
||||
bool prev_mMaxSteerAngle;
|
||||
Vec2d mGlobalCarPos;
|
||||
Vec2d mGlobalTarget;
|
||||
bool mCatchedRaceLine;
|
||||
bool prev_mCatchedRaceLine;
|
||||
bool mMaxSteerAngle;
|
||||
bool prev_mMaxSteerAngle;
|
||||
Vec2d mGlobalCarPos;
|
||||
Vec2d mGlobalTarget;
|
||||
bool mCatchedRaceLine;
|
||||
bool prev_mCatchedRaceLine;
|
||||
double mCatchedRaceLineTime;
|
||||
double mAbsFactor;
|
||||
double mTclFactor;
|
||||
double mFrontCollFactor;
|
||||
bool mColl;
|
||||
bool mColl;
|
||||
double mCollDist;
|
||||
double mCollBrakeDist;
|
||||
double mCollOvershooting;
|
||||
bool mWait;
|
||||
bool mWait;
|
||||
double mTANKVOL;
|
||||
double mFuelStart;
|
||||
double mPathOffs;
|
||||
double mAccelX;
|
||||
double mAccelXSum;
|
||||
int mAccelXCount;
|
||||
int mAccelXCount;
|
||||
double mSkillGlobal;
|
||||
double mSkillDriver;
|
||||
bool mGarage;
|
||||
PidController mSpeedController;
|
||||
PidController mAttackAngleController;
|
||||
int mWatchdogCount;
|
||||
int mWatchdogCount;
|
||||
// Data that should stay constant after first initialization
|
||||
double mBRAKEPRESS;
|
||||
double mBRAKEREPARTITION;
|
||||
|
@ -322,13 +322,14 @@ private:
|
|||
double mBUMPSPEEDFACTOR;
|
||||
double mFUELPERMETER;
|
||||
double mFUELWEIGHTFACTOR;
|
||||
int mPITDAMAGE;
|
||||
double mWEARPERMETER;
|
||||
int mPITDAMAGE;
|
||||
double mPITENTRYMARGIN;
|
||||
double mPITENTRYSPEED;
|
||||
double mPITEXITSPEED;
|
||||
double mTARGETFACTOR;
|
||||
double mTARGETWALLDIST;
|
||||
bool mTRACTIONCONTROL;
|
||||
bool mTRACTIONCONTROL;
|
||||
double mMAXLEFT;
|
||||
double mMAXRIGHT;
|
||||
double mMARGININSIDE;
|
||||
|
|
|
@ -255,7 +255,7 @@ void Pit::update(double fromstart)
|
|||
totalfuel += lastfuel + lastpitfuel - car->priv.fuel;
|
||||
fuellapscounted++;
|
||||
avgfuelperlap = totalfuel / fuellapscounted;
|
||||
//GfOut("Car:%s fuelpermeter:%g\n", car->_name, avgfuelperlap / track->length);
|
||||
LogDANDROID.info("Car:%s fuelpermeter:%g\n", car->_name, avgfuelperlap / track->length);
|
||||
}
|
||||
|
||||
lastfuel = car->priv.fuel;
|
||||
|
@ -309,7 +309,7 @@ void Pit::update(double fromstart)
|
|||
setPitstop(true);
|
||||
}
|
||||
|
||||
if(tyreTreadDepth() < 30.0)
|
||||
if(tyreTreadDepth() < 20.0)
|
||||
setPitstop(true);
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,8 @@ double Pit::getFuel()
|
|||
}
|
||||
|
||||
double fuel = MAX(MIN(stintfuel - car->_fuel, car->_tank - car->_fuel), 0.0);
|
||||
//GfOut("fromStart:%g laps:%g lapsBehindLeader:%d fueltoend:%g pitstops:%d stintfuel:%g fuel:%g\n", mFromStart, laps, car->_lapsBehindLeader, fueltoend, pitstops, stintfuel, fuel);
|
||||
LogDANDROID.debug("fromStart:%g laps:%g lapsBehindLeader:%d fueltoend:%g pitstops:%d stintfuel:%g fuel:%g\n", mFromStart, laps, car->_lapsBehindLeader, fueltoend, pitstops, stintfuel, fuel);
|
||||
|
||||
return fuel;
|
||||
}
|
||||
|
||||
|
@ -427,6 +428,6 @@ void Pit::pitCommand()
|
|||
car->_pitRepair = getRepair();
|
||||
lastpitfuel = getFuel();
|
||||
car->_pitFuel = (tdble) lastpitfuel;
|
||||
car->pitcmd.tireChange = tyreTreadDepth() > 30.0 ? tCarPitCmd::ALL : tCarPitCmd::NONE;
|
||||
car->pitcmd.tireChange = tyreTreadDepth() > 10.0 ? tCarPitCmd::ALL : tCarPitCmd::NONE;
|
||||
setPitstop(false);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,11 @@
|
|||
|
||||
#define NPOINTS 7
|
||||
|
||||
// The "DANDROID" logger instance.
|
||||
extern GfLogger* PLogDANDROID;
|
||||
#define LogDANDROID (*PLogDANDROID)
|
||||
|
||||
|
||||
class Pit
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue