示例#1
0
//==========================================================================*
// Decide to do a pit stop
//--------------------------------------------------------------------------*
bool TBaseStrategy::NeedPitStop()
{
  float FuelConsum;                              // Fuel consumption per m
  if (oFuelPerM == 0.0)                          // If still undefined
    FuelConsum = oExpectedFuelPerM;              //   use estimated value
  else                                           // If known
    FuelConsum = oFuelPerM;                      //   use it

  bool Result = RtTeamNeedPitStop(
	  oDriver->oTeamIndex, 
	  FuelConsum, 
	  RepairWanted(cPIT_DAMAGE));

  if (oDriver->oForcePitStop)                    // If defined, try
    Result = true;                               //   to stop in pit

  return Result;
};
示例#2
0
//==========================================================================*
// Entscheiden, ob Boxenstopp nötig ist
//--------------------------------------------------------------------------*
bool TSimpleStrategy::NeedPitStop()
{
  float FuelConsum;                              // Fuel consumption per m
  if (oFuelPerM == 0.0)                          // If still undefined
    FuelConsum = oExpectedFuelPerM;              //   use estimated value
  else                                           // If known
    FuelConsum = oFuelPerM;                      //   use it

  bool Result = RtTeamNeedPitStop(oDriver->TeamIndex(), 
	  FuelConsum, RepairWanted(cPIT_DAMMAGE));

  if (oDriver->oCarHasTYC)
  {
	double TdF = oDriver->TyreTreadDepthFront(); // Check tyre condition
	double TdR = oDriver->TyreTreadDepthRear();  // Pit stop needed if
	oDegradationPerLap = (oLaps * oDegradationPerLap 
	  + MAX(oTireLimitFront - TdF,oTireLimitRear - TdR));
	oDegradationPerLap /= ++oLaps;

	if (MIN(TdF,TdR) < 1.5 * oDegradationPerLap) // tyres become critical
	{
		LogSimplix.warning("Tyre condition D: %.1f%% F: %.1f%% R: %.1f%% (%s)\n",
	    oDegradationPerLap,TdF,TdR,oDriver->GetBotName());

	  if ((TdF < 1.1 * oDegradationPerLap) 
		|| (TdR < 1.1 * oDegradationPerLap))
	  {
        Result = true;                           //   to stop in pit
	  }
	}
	oTireLimitFront = TdF;
	oTireLimitRear = TdR;
  }

  if (oDriver->oTestPitStop)                     // If defined, try
    Result = true;                               //   to stop in pit

  return Result;
};
示例#3
0
bool SimpleStrategy::needPitstop(tCarElt* car, tSituation *s, Opponents *opp)
{
    // Do we need to refuel?
    int remainlaps = car->_remainingLaps;//-car->_lapsBehindLeader;
    //int this_pit_dammage = PitDamage;

    if (!car->_pit)
        return false;

    int forcepit = (int) GfParmGetNum( car->_carHandle, SECT_PRIVATE, PRV_FORCE_PIT, (char *)NULL, 0.0 );
    if (forcepit)
        return true;

#ifdef SPEED_DREAMS
    int repairWanted = 10000;

    if ((remainlaps > 0) && (remainlaps < 20))
    {
        repairWanted = MIN(8000, PitDamage + (20-remainlaps)*200);
    }

    if (car->_dammage < 9000 && (remainlaps <= 2 || strategy == STRATEGY_DESPERATE))
        repairWanted = 0;

    if (car->_dammage < MIN(3000, PitDamage/2))
        repairWanted = 0;

    float cmpfuel = (m_fuelperlap == 0.0) ? m_expectedfuelperlap : m_fuelperlap;

    float fuelPerM = cmpfuel / track->length;
    bool GotoPit = RtTeamNeedPitStop(teamIndex,fuelPerM,repairWanted);

    if (m_Driver->HasTYC)
    {
      double TdF = m_Driver->TyreTreadDepthFront(); // Check tyre condition
      double TdR = m_Driver->TyreTreadDepthRear();  // Pit stop needed if
      m_DegradationPerLap = (m_Laps * m_DegradationPerLap
        + MAX(m_TireLimitFront - TdF, m_TireLimitRear - TdR));
      m_DegradationPerLap /= ++m_Laps;

      if (MIN(TdF,TdR) < 1.5 * m_DegradationPerLap) // tyres become critical
      {
          /*LogUSR.warning("Tyre condition D: %.1f%% F: %.1f%% R: %.1f%%\n",
          m_DegradationPerLap, TdF, TdR);*/

        if ((TdF < 1.1 * m_DegradationPerLap)
          || (TdR < 1.1 * m_DegradationPerLap))
        {
          GotoPit = true;                           //   to stop in pit
        }
      }

      m_TireLimitFront = TdF;
      m_TireLimitRear = TdR;
    }

    if (GotoPit)
        is_pitting = 1;
    else
        is_pitting = 0;

    return GotoPit;
#else
    if (remainlaps > 0)
    {
        float cmpfuel = (m_fuelperlap == 0.0) ? m_expectedfuelperlap : m_fuelperlap;
        if (car->_fuel < 2.5*cmpfuel &&
                car->_fuel < remainlaps*cmpfuel)
        {
            is_pitting = 1;
            pit_reason = REASON_FUEL;
            return true;
        }
        else if (remainlaps < 20)
            this_pit_dammage = MIN(8000, PitDamage + (20-remainlaps)*200);
    }

    if (isPitFree(car))
    {
        // don't pit for damage if getting close to end
        if (car->_dammage < MAX(PitDamage/2, 9500 - remainlaps*1000))
        {
            is_pitting = 0;
            return false;
        }

        // Ok, otherwise do we need to repair?
        if (car->_dammage >= PitDamage)
        {
            is_pitting = 1;
            pit_reason = REASON_DAMAGE;
            return true;
        }

        // Can we safely repair a lesser amount of damage?
        int canrepair_damage;
        pit_reason = REASON_NONE;

        if ((canrepair_damage = calcRepair(car, s, opp, 0)) >= PitDamage/2)
        {
            if (car->_pos < 6)
            {
                // if there's a chance of overtaking an opponent that's
                // not far in front, avoid going in to fix optional damage.
                for (int i = 0; i < opp->getNOpponents(); i++)
                {
                    Opponent *o = opp->getOpponentPtr() + i;
                    tCarElt *ocar = o->getCarPtr();
                    if (ocar->_pos >= car->_pos) continue;
                    if (o->getTeam() == TEAM_FRIEND) continue;

                    if (o->getDistance() < 200.0 && car->_dammage < ocar->_dammage + 1500 && car->_dammage < PitDamage)
                    {
                        // close behind opponent, so lets not pit for damage purposes
                        return false;
                    }
                }
            }

            if (is_pitting)
                pit_damage = MIN(car->_dammage, MAX(pit_damage, canrepair_damage));
            else
                pit_damage = MIN(car->_dammage, MIN(pit_damage, canrepair_damage));
            is_pitting = 1;
            pit_reason = REASON_DAMAGE;
            return true;
        }
    }

    is_pitting = 0;
    return false;
#endif
}