i++)
flights.push_back(new FGScheduledFlight((*(*i))));*/
AIManagerRef = 0;
- //score = scre;
+ score = 0;
firstRun = true;
+ runCount = 0;
+ hits = 0;
+ initialized = false;
}
FGAISchedule::FGAISchedule(const FGAISchedule &other)
radius = other.radius;
groundOffset = other.groundOffset;
flightType = other.flightType;
- //score = other.score;
+ score = other.score;
distanceToUser = other.distanceToUser;
currentDestination = other.currentDestination;
firstRun = other.firstRun;
+ runCount = other.runCount;
+ hits = other.hits;
+ initialized = other.initialized;
}
+
FGAISchedule::~FGAISchedule()
{
/* for (FGScheduledFlightVecIterator flt = flights.begin(); flt != flights.end(); flt++)
bool FGAISchedule::update(time_t now, const SGVec3d& userCart)
{
- if (!fgGetBool("/sim/traffic-manager/enabled"))
- return true;
-
time_t
totalTimeEnroute,
elapsedTimeEnroute,
if (distanceToUser >= TRAFFICTOAIDISTTOSTART) {
return true; // out of visual range, for the moment.
}
-
return createAIAircraft(flight, speed, deptime);
}
}
currentDestination = flight->getArrivalAirport()->getId();
+ if (!initialized) {
+ string departurePort = flight->getDepartureAirport()->getId();
+ //cerr << "Scheduled " << registration << " " << score << " for Flight "
+ // << flight-> getCallSign() << " from " << departurePort << " to " << currentDestination << endl;
+ if (fgGetString("/sim/presets/airport-id") == departurePort) {
+ hits++;
+ }
+ //runCount++;
+ initialized = true;
+ }
time_t arr, dep;
dep = flight->getDepartureTime();
SG_CLAMP_RANGE(speed, 300.0, 500.0);
return speed;
}
-/*
+
+void FGAISchedule::setScore ()
+{
+ if (runCount) {
+ score = ((double) hits / (double) runCount);
+ } else {
+ if (homePort == fgGetString("/sim/presets/airport-id")) {
+ score = 0.1;
+ } else {
+ score = 0.0;
+ }
+ }
+ runCount++;
+}
+
bool compareSchedules(FGAISchedule*a, FGAISchedule*b)
{
- //return (*a) < (*b);
+ return (*a) < (*b);
}
-*/
+
// void FGAISchedule::setClosestDistanceToUser()
// {