From 6e243922f6eb0ff0d9d30ff3233335b0822ea451 Mon Sep 17 00:00:00 2001 From: andrewsumner Date: Wed, 30 Sep 2009 23:12:20 +0000 Subject: [PATCH] usr_36GP - performance "enhancement" fixed git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@1495 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 82a72cd6948ffa7764996f8eb4977a6e86b40629 Former-commit-id: e5b5f82b38e48ff570b407961dbacd2b6c11a22c --- src/drivers/usr_36GP/driver.cpp | 31 +++++++++++-------------------- src/drivers/usr_36GP/raceline.cpp | 10 +++++----- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/drivers/usr_36GP/driver.cpp b/src/drivers/usr_36GP/driver.cpp index 1f1734f82..de8ae05ee 100644 --- a/src/drivers/usr_36GP/driver.cpp +++ b/src/drivers/usr_36GP/driver.cpp @@ -55,7 +55,7 @@ const float Driver::USE_LEARNED_OFFSET_RANGE = 0.2f; // [m] if offset < this us const float Driver::TEAM_REAR_DIST = 50.0f; // const int Driver::TEAM_DAMAGE_CHANGE_LEAD = 700; // When to change position in the team? -#define SKIPLIMIT 4 +#define SKIPLIMIT 2 enum { FLYING_FRONT = 1, FLYING_BACK = 2, FLYING_SIDE = 4 }; enum { STUCK_REVERSE = 1, STUCK_FORWARD = 2 }; @@ -524,7 +524,7 @@ void Driver::LoadDAT( tSituation *s, char *carname, char *trackname ) // Start a new race. void Driver::newRace(tCarElt* car, tSituation *s) { - deltaTime = (float) RCM_MAX_DT_ROBOTS*SKIPLIMIT; + deltaTime = (float) RCM_MAX_DT_ROBOTS; MAX_UNSTUCK_COUNT = int(UNSTUCK_TIME_LIMIT/deltaTime); OVERTAKE_OFFSET_INC = OVERTAKE_OFFSET_SPEED*deltaTime; random_seed = 0; @@ -850,19 +850,9 @@ void Driver::drive(tSituation *s) laststeer = car->_steerCmd; memset(&car->ctrl, 0, sizeof(tCarCtrl)); - if (++skipcount > 1) - { - if (skipcount >= SKIPLIMIT) - skipcount = 0; - - car->_accelCmd = cmd_accel; - car->_brakeCmd = cmd_brake; - car->_steerCmd = cmd_steer; - car->_clutchCmd = cmd_clutch; - car->_gearCmd = cmd_gear; - return; - } - + skipcount++; + if (skipcount >= SKIPLIMIT) + skipcount = 0; update(s); @@ -1771,7 +1761,7 @@ float Driver::getClutch() if (car->_gear != car->_gearCmd && car->_gearCmd < MaxGear) clutchtime = maxtime; if (clutchtime > 0.0f) - clutchtime -= (float) (RCM_MAX_DT_ROBOTS * SKIPLIMIT * (0.02f + ((float) car->_gearCmd / 8.0f))); + clutchtime -= (float) (RCM_MAX_DT_ROBOTS * (0.02f + ((float) car->_gearCmd / 8.0f))); return 2.0f * clutchtime; } else { float drpm = car->_enginerpm - car->_enginerpmRedLine/2.0f; @@ -1783,7 +1773,7 @@ float Driver::getClutch() clutchtime = 0.0f; float clutcht = (ctlimit - clutchtime) / ctlimit; if (car->_gear == 1 && car->_accelCmd > 0.0f) { - clutchtime += (float) RCM_MAX_DT_ROBOTS * SKIPLIMIT; + clutchtime += (float) RCM_MAX_DT_ROBOTS; } if (car->_gearCmd == 1 || drpm > 0) { @@ -1866,7 +1856,8 @@ vec2f Driver::getTargetPoint(bool use_lookahead, double targetoffset) { tTrackSeg *seg = car->_trkPos.seg; float length = getDistToSegEnd(); - float offset = (targetoffset > -99 ? targetoffset : getOffset()); + float offset = (targetoffset > -99 ? targetoffset + : (skipcount == 0 ? getOffset() : myoffset)); double time_mod = 1.0; pitoffset = -100.0f; @@ -1952,7 +1943,7 @@ vec2f Driver::getTargetPoint(bool use_lookahead, double targetoffset) lookahead *= LookAhead; // Prevent "snap back" of lookahead on harsh braking. - float cmplookahead = oldlookahead - (car->_speed_x*RCM_MAX_DT_ROBOTS*SKIPLIMIT)*0.65f;//0.55f; + float cmplookahead = oldlookahead - (car->_speed_x*RCM_MAX_DT_ROBOTS)*0.65f;//0.55f; if (lookahead < cmplookahead) { lookahead = cmplookahead; } @@ -3613,7 +3604,7 @@ float Driver::filterABS(float brake) brake = MAX(brake, MIN(origbrake, 0.1f)); //brake = MAX(MIN(origbrake, collision ? 0.15f :0.05f), brake - MAX(fabs(angle), fabs(car->_yaw_rate) / 2)); - brake = (float) (MAX(MIN(origbrake, (collision ? MAX(0.05f, (5.0-collision)/30) : 0.05f)), brake - fabs(angle-speedangle)*3)); + brake = (float) (MAX(MIN(origbrake, (collision ? MAX(0.05f, (5.0-collision)/30) : 0.05f)), brake - fabs(angle-speedangle)*0.3)); if (fbrakecmd) brake = MAX(brake, fbrakecmd); diff --git a/src/drivers/usr_36GP/raceline.cpp b/src/drivers/usr_36GP/raceline.cpp index b766d6135..9150f0d52 100644 --- a/src/drivers/usr_36GP/raceline.cpp +++ b/src/drivers/usr_36GP/raceline.cpp @@ -88,7 +88,7 @@ LRaceLine::LRaceLine() : CornerAccel(0.0), BrakeDelay(20.0), BrakeDelayX(1.0), - BrakeMod(0), + BrakeMod(1.0), IntMargin(1.5), ExtMargin(2.0), AvoidSpeedAdjust(0.0), @@ -329,7 +329,7 @@ void LRaceLine::AllocTrack( tTrack *ptrack ) ExtMargin = GfParmGetNum( carhandle, SECT_PRIVATE, PRV_EXT_MARGIN, (char *)NULL, 1.7f ) + (double) (SRLidx-1)/2; //skill/5; BrakeDelay = GfParmGetNum( carhandle, SECT_PRIVATE, PRV_BASE_BRAKE, (char *)NULL, 35.0f ); BrakeDelayX = GfParmGetNum( carhandle, SECT_PRIVATE, PRV_BASE_BRAKE_X, (char *)NULL, 1.0f ); - BrakeMod = (int) GfParmGetNum( carhandle, SECT_PRIVATE, PRV_BRAKE_MOD, (char *)NULL, 0.0f ); + BrakeMod = GfParmGetNum( carhandle, SECT_PRIVATE, PRV_BRAKE_MOD, (char *)NULL, 1.0f ); SteerMod = (int) GfParmGetNum( carhandle, SECT_PRIVATE, PRV_STEER_MOD, (char *)NULL, 0.0f ); MaxSteerTime = GfParmGetNum( carhandle, SECT_PRIVATE, PRV_MAX_STEER_TIME, (char *)NULL, 1.5f ); MinSteerTime = GfParmGetNum( carhandle, SECT_PRIVATE, PRV_MIN_STEER_TIME, (char *)NULL, 1.0f ); @@ -1197,7 +1197,7 @@ void LRaceLine::ComputeSpeed(int rl) if (tSpeed[rf][i] > tSpeed[rf][next]) { - if (BrakeMod) + if (BrakeMod > 0.1) { double bspd = (MIN(100.0, tSpeed[rf][next]) - 30.0) / 60 + fabs(SRL[rl].tRInverse[next])*40; tSpeed[rf][i] = MIN(tSpeed[rf][i], @@ -1205,12 +1205,12 @@ void LRaceLine::ComputeSpeed(int rl) ((0.1 - MIN(0.085, fabs(SRL[rl].tRInverse[next])*7)) * SRL[rl].tBrakeFriction[i] * MAX(bd/4.0, bd / ((tSpeed[rf][next]*(tSpeed[rf][next]/20))/20))) - * MAX(0.2, 1.0 - (tSpeed[rf][next] > 30.0 ? bspd*(bspd+0.2) : 0.0)))); + * (MAX(0.2, 1.0 - (tSpeed[rf][next] > 30.0 ? bspd*(bspd+0.2) : 0.0)) * BrakeMod))); } else { tSpeed[rf][i] = MIN(tSpeed[rf][i], tSpeed[rf][next] + MAX(0.1, - ((0.1 - MIN(0.085, fabs(SRL[rl].tRInverse[next])*8)) + ((0.1 - MIN(0.085, 0.05 + fabs(SRL[rl].tRInverse[next])*3)) * SRL[rl].tBrakeFriction[i] * MAX(bd/4.0, bd / ((tSpeed[rf][next]*(tSpeed[rf][next]/20))/20))))); }