/** The transition choose the most fitted state at the moment of the race. */
void
FSMDriver3::transition(CarState &cs) {
    DrivingState *state = current_state;

    if(gameTicks <= 10000){
        distRaced = cs.getDistRaced();
        ticks_on_inside_track = inside_track->get_ticks_in_state();
        ticks_on_stuck = stuck->get_ticks_in_state();
        ticks_on_out_of_track = out_of_track->get_ticks_in_state();
        damage = cs.getDamage();
        gameTicks += 1;
    }/*
    else if(gameTicks == 10000){
        distRaced = cs.getDistRaced();
        gameTicks+=1;
        ticks_on_inside_track = inside_track->get_ticks_in_state();
        ticks_on_stuck = stuck->get_ticks_in_state();
        ticks_on_out_of_track = out_of_track->get_ticks_in_state();
        damage = cs.getDamage();
    }*/

    setTrackType();

    if(stuck->isStuck(cs)) {
        state = stuck;
    } else {
        if (cs.getTrack(1) > 0)
            state = inside_track;
        else {
            state = out_of_track;
        }
    }

    if (current_state != state) changeTo(state);
}
void
SimpleDriver::clutching(CarState &cs, float &clutch)
{
  double maxClutch = clutchMax;

  // Check if the current situation is the race start
  if (cs.getCurLapTime()<clutchDeltaTime  && stage==RACE && cs.getDistRaced()<clutchDeltaRaced)
    clutch = maxClutch;

  // Adjust the current value of the clutch
  if(clutch > 0)
  {
    double delta = clutchDelta;
    if (cs.getGear() < 2)
	{
      // Apply a stronger clutch output when the gear is one and the race is just started
	  delta /= 2;
      maxClutch *= clutchMaxModifier;
      if (cs.getCurLapTime() < clutchMaxTime)
        clutch = maxClutch;
	}

    // check clutch is not bigger than maximum values
	clutch = min(maxClutch,double(clutch));

	// if clutch is not at max value decrease it quite quickly
	if (clutch!=maxClutch)
	{
	  clutch -= delta;
	  clutch = max(0.0,double(clutch));
	}
	// if clutch is at max value decrease it very slowly
	else
		clutch -= clutchDec;
  }
}
Exemple #3
0
bool
Stuck::justStartedRace(CarState &cs) {
    return (cs.getDistRaced() <= minimum_distance_raced);
}
Exemple #4
0
bool Stuck::justStartedRace(CarState &cs) {
    return (cs.getDistRaced() <= MIN_RACED_DISTANCE);
}