diff --git a/src/drivers/shadow/src/Driver.cpp b/src/drivers/shadow/src/Driver.cpp index e8a05dd90..9ed2fec73 100644 --- a/src/drivers/shadow/src/Driver.cpp +++ b/src/drivers/shadow/src/Driver.cpp @@ -218,7 +218,6 @@ TDriver::TDriver(int Index, const int robot_type): Frc = 0.95; break; - case SHADOW_LS1: robot_name = "shadow_ls1"; Frc = 0.85; @@ -373,19 +372,17 @@ void TDriver::GetSkillingParameters(const char* BaseParamPath, const char* PathF if (SkillEnabled > 0) // If skilling is enabled { // Get Skill level - Skilling = true; // of TORCS-Installation + Skilling = true; // of TORCS-Installation LogSHADOW.debug("#Skilling: On\n"); void* SkillHandle = NULL; - snprintf(PathFilenameBuffer, 256, - "%sconfig/raceman/extra/skill.xml",GetLocalDir()); + snprintf(PathFilenameBuffer, 256, "%sconfig/raceman/extra/skill.xml",GetLocalDir()); LogSHADOW.debug("#skill.xml: %s\n", PathFilename); SkillHandle = GfParmReadFile(PathFilename, GFPARM_RMODE_REREAD); if (SkillHandle) { - SkillGlobal = MAX(0.0,MIN(10.0,GfParmGetNum(SkillHandle, "skill", "level", - (char *) NULL, 10.0))); + SkillGlobal = MAX(0.0,MIN(10.0,GfParmGetNum(SkillHandle, "skill", "level", (char *) NULL, 10.0))); LogSHADOW.debug("#LocalDir: SkillGlobal: %g\n", SkillGlobal); } else @@ -396,8 +393,7 @@ void TDriver::GetSkillingParameters(const char* BaseParamPath, const char* PathF SkillHandle = GfParmReadFile(PathFilename, GFPARM_RMODE_REREAD); if (SkillHandle) { - SkillGlobal = MAX(0.0,MIN(10.0, GfParmGetNum(SkillHandle, - "skill", "level", (char *) NULL, 10.0))); + SkillGlobal = MAX(0.0,MIN(10.0, GfParmGetNum(SkillHandle, "skill", "level", (char *) NULL, 10.0))); LogSHADOW.debug("#DataDir: SkillGlobal: %g\n", SkillGlobal); } } @@ -433,14 +429,12 @@ void TDriver::InitTrack( tTrack* pTrack, void* pCarHandle, void** ppCarParmHandl { void* hCarParm = 0; char buf[1024]; + char trackName[256]; track = pTrack; - char trackName[256]; strncpy( trackName, strrchr(track->filename, '/') + 1, sizeof(trackName) ); *strrchr(trackName, '.') = '\0'; - - - + if (track->length < 2000) RtTeamManagerLaps(3); else if (track->length < 3000) @@ -471,7 +465,7 @@ void TDriver::InitTrack( tTrack* pTrack, void* pCarHandle, void** ppCarParmHandl // ok, lets read/merge the car parms. // - Meteorology(); + Meteorology(); // default params for car type (e.g. clkdtm) snprintf( buf, BUFSIZE, "drivers/%s/%s/%s.xml", robot_name, m_CarType, trackName ); @@ -618,9 +612,7 @@ void TDriver::InitTrack( tTrack* pTrack, void* pCarHandle, void** ppCarParmHandl MyTrack::SideMod sideMod; sideMod.side = -1; const char* pStr = GfParmGetStr(hCarParm, SECT_PRIV, PRV_SIDE_MOD, ""); - if( pStr == 0 || - sscanf(pStr, "%d , %d , %d", - &sideMod.side, &sideMod.start, &sideMod.end) != 3 ) + if( pStr == 0 || sscanf(pStr, "%d , %d , %d", &sideMod.side, &sideMod.start, &sideMod.end) != 3 ) { sideMod.side = -1; } @@ -667,6 +659,7 @@ void TDriver::NewRace( tCarElt* pCar, tSituation* pS ) LogSHADOW.debug( "CARMASS %g TYRE_MU %g TYRE_MU_F %g TYRE_MU_R %g \n", m_cm.MASS, m_cm.TYRE_MU, m_cm.TYRE_MU_F, m_cm.TYRE_MU_R ); + LogSHADOW.debug( "MU_SC %g KZ_SCALE %g FLY_HEIGHT %g\n", m_cm.MU_SCALE, m_cm.KZ_SCALE, FLY_HEIGHT ); @@ -730,12 +723,9 @@ void TDriver::NewRace( tCarElt* pCar, tSituation* pS ) LogSHADOW.debug("m_path passed\n"); - m_pitPath[PATH_NORMAL].MakePath( car, &m_path[PATH_NORMAL], m_cm, - PIT_ENTRY_OFFSET, PIT_EXIT_OFFSET ); - m_pitPath[PATH_LEFT]. MakePath( car, &m_path[PATH_LEFT], m_cm2, - PIT_ENTRY_OFFSET, PIT_EXIT_OFFSET ); - m_pitPath[PATH_RIGHT]. MakePath( car, &m_path[PATH_RIGHT], m_cm2, - PIT_ENTRY_OFFSET, PIT_EXIT_OFFSET ); + m_pitPath[PATH_NORMAL].MakePath( car, &m_path[PATH_NORMAL], m_cm, PIT_ENTRY_OFFSET, PIT_EXIT_OFFSET ); + m_pitPath[PATH_LEFT]. MakePath( car, &m_path[PATH_LEFT], m_cm2, PIT_ENTRY_OFFSET, PIT_EXIT_OFFSET ); + m_pitPath[PATH_RIGHT]. MakePath( car, &m_path[PATH_RIGHT], m_cm2, PIT_ENTRY_OFFSET, PIT_EXIT_OFFSET ); LogSHADOW.debug("m_pit Path passed\n"); diff --git a/src/drivers/shadow/src/PitControl.cpp b/src/drivers/shadow/src/PitControl.cpp index bbd04cea6..0fd1a2590 100644 --- a/src/drivers/shadow/src/PitControl.cpp +++ b/src/drivers/shadow/src/PitControl.cpp @@ -102,8 +102,7 @@ void PitControl::Process( CarElt* pCar ) // bool likeToPit = pCar->_dammage >= 500 || pCar->_fuel < 90; // bool likeToPit = pCar->_dammage + damagePerLap >= repairLimit || - bool likeToPit = pCar->_dammage >= repairLimit || - pCar->_fuel < fuelPerLap * 1.5; + bool likeToPit = pCar->_dammage >= repairLimit || pCar->_fuel < fuelPerLap * 1.5; // likeToPit = true; // pitting on the last lap is a silly thing to do (think about it!). diff --git a/src/drivers/shadow/src/PitControl.h b/src/drivers/shadow/src/PitControl.h index 84f0a6d07..294690610 100644 --- a/src/drivers/shadow/src/PitControl.h +++ b/src/drivers/shadow/src/PitControl.h @@ -34,11 +34,15 @@ public: private: enum { - PIT_NONE, - PIT_BEFORE, - PIT_ENTER, - PIT_ASKED, - PIT_EXIT + PIT_NONE, + PIT_BEFORE, + PIT_PREPARE, + PIT_ENTER, + PIT_ASKED, + PIT_SERVICE, + PIT_EXIT_WAIT, + PIT_EXIT, + PIT_GONE }; private: diff --git a/src/drivers/shadow/src/Strategy.cpp b/src/drivers/shadow/src/Strategy.cpp index 029310611..77ac34d1d 100644 --- a/src/drivers/shadow/src/Strategy.cpp +++ b/src/drivers/shadow/src/Strategy.cpp @@ -51,7 +51,8 @@ SimpleStrategy::SimpleStrategy() m_maxDamage = 0; // [-] max damage before we request a pit stop. m_Fuel = 0; // [Kg] Security fuel at the strat race. m_expectedfuelperlap = 0; // [Kg] Expected fuel per lap - + TrackLength = 0; + RaceDistance = 0; } @@ -63,6 +64,9 @@ SimpleStrategy::~SimpleStrategy() void SimpleStrategy::setFuelAtRaceStart(tTrack* t, void **carParmHandle, tSituation *s, int index) { + Track = t; + TrackLength = Track->length; + RaceDistance = TrackLength * s->_totLaps; /* Trivial strategy: fill in as much fuel as required for the whole race, or if the tank is too small fill the tank completely. */ // Load and set parameters. diff --git a/src/drivers/shadow/src/Strategy.h b/src/drivers/shadow/src/Strategy.h index 696f8c87b..d66d1380a 100644 --- a/src/drivers/shadow/src/Strategy.h +++ b/src/drivers/shadow/src/Strategy.h @@ -156,6 +156,9 @@ protected: int AlwaysPit; int strategy_verbose; + float TrackLength; + float RaceDistance; + int laps_to_go(tCarElt *car) {return car->_remainingLaps - car->_lapsBehindLeader;} virtual void updateFuelStrategy(tCarElt* car, tSituation *s); };