add session time for driver hymie
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2571 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 662f8ade8734b9353578aac39951d5ca2c017360 Former-commit-id: e00285b98ce97d51fe4f26c4ed87b6b6de8bb783
This commit is contained in:
parent
a1ea0c770d
commit
d80cc5ccac
6 changed files with 49 additions and 9 deletions
|
@ -41,6 +41,7 @@
|
|||
|
||||
#define HYMIE_SECT_PRIV "hymie"
|
||||
#define HYMIE_ATT_FUELPERLAP "fuelperlap"
|
||||
#define HYMIE_ATT_FUELPERSECOND "fuelpersecond"
|
||||
#define HYMIE_ATT_MUFACTOR "mufactor"
|
||||
|
||||
class Opponents;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
<attnum name="red" val="0.4"></attnum>
|
||||
<attnum name="green" val="0.7"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
|
||||
<section name="2">
|
||||
|
@ -40,6 +41,7 @@
|
|||
<attnum name="red" val="0.4"></attnum>
|
||||
<attnum name="green" val="0.7"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
|
||||
<section name="3">
|
||||
|
@ -52,6 +54,7 @@
|
|||
<attnum name="red" val="0.4"></attnum>
|
||||
<attnum name="green" val="0.7"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
|
||||
<section name="4">
|
||||
|
@ -64,6 +67,7 @@
|
|||
<attnum name="red" val="0.4"></attnum>
|
||||
<attnum name="green" val="0.7"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
|
||||
<section name="5">
|
||||
|
@ -76,6 +80,7 @@
|
|||
<attnum name="red" val="1.0"></attnum>
|
||||
<attnum name="green" val="1.0"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
|
||||
<section name="6">
|
||||
|
@ -88,6 +93,7 @@
|
|||
<attnum name="red" val="1.0"></attnum>
|
||||
<attnum name="green" val="1.0"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
|
||||
<section name="7">
|
||||
|
@ -100,6 +106,7 @@
|
|||
<attnum name="red" val="1.0"></attnum>
|
||||
<attnum name="green" val="1.0"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
|
||||
<section name="8">
|
||||
|
@ -112,6 +119,7 @@
|
|||
<attnum name="red" val="1.0"></attnum>
|
||||
<attnum name="green" val="1.0"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
|
||||
<section name="9">
|
||||
|
@ -124,6 +132,7 @@
|
|||
<attnum name="red" val="1.0"></attnum>
|
||||
<attnum name="green" val="1.0"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
|
||||
<section name="10">
|
||||
|
@ -136,6 +145,7 @@
|
|||
<attnum name="red" val="1.0"></attnum>
|
||||
<attnum name="green" val="1.0"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
@ -146,6 +156,7 @@
|
|||
<attnum name="red" val="1.0"></attnum>
|
||||
<attnum name="green" val="1.0"></attnum>
|
||||
<attnum name="blue" val="1.0"></attnum>
|
||||
<attstr name="features" val="timed_session"></attstr>
|
||||
<section name="cars">
|
||||
<section name="1">
|
||||
<attstr name="car name" val="sc-boxer-96" />
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "strategy.h"
|
||||
|
||||
const float SimpleStrategy::MAX_FUEL_PER_METER = 0.0008f; // [kg/m] fuel consumtion.
|
||||
|
||||
const float SimpleStrategy::MAX_FUEL_PER_SECOND = 2.7f/60.0f; // [kg/s] fuel consumtion.
|
||||
|
||||
SimpleStrategy::SimpleStrategy() :
|
||||
fuelchecked(false),
|
||||
|
@ -48,10 +48,13 @@ SimpleStrategy::~SimpleStrategy()
|
|||
void SimpleStrategy::setFuelAtRaceStart(tTrack* t, void **carParmHandle, tSituation *s)
|
||||
{
|
||||
// Load and set parameters.
|
||||
float fuel = GfParmGetNum(*carParmHandle, HYMIE_SECT_PRIV, HYMIE_ATT_FUELPERLAP, (char*) NULL, t->length*MAX_FUEL_PER_METER);
|
||||
float fuel = GfParmGetNum(*carParmHandle, HYMIE_SECT_PRIV, HYMIE_ATT_FUELPERSECOND, (char*) NULL, MAX_FUEL_PER_SECOND);
|
||||
expectedfuelpersecond = fuel;
|
||||
fuel = GfParmGetNum(*carParmHandle, HYMIE_SECT_PRIV, HYMIE_ATT_FUELPERLAP, (char*) NULL, t->length*MAX_FUEL_PER_METER);
|
||||
expectedfuelperlap = fuel;
|
||||
maxfuel = GfParmGetNum(*carParmHandle, SECT_CAR, PRM_TANK, (char*) NULL, 100.0);
|
||||
fuel *= (s->_totLaps + 1.0);
|
||||
fuel += expectedfuelpersecond * MAX(s->_totTime,0);
|
||||
lastfuel = MIN(fuel, maxfuel);
|
||||
if (s->_raceType == RM_TYPE_PRACTICE)
|
||||
lastfuel = maxfuel;
|
||||
|
@ -180,6 +183,12 @@ bool SimpleStrategy::needPitstop(tCarElt* car, tSituation *s, Opponents *opp)
|
|||
if (laps > 0)
|
||||
{
|
||||
float cmpfuel = (fuelperlap == 0.0) ? expectedfuelperlap : fuelperlap;
|
||||
if (s->_totTime > s->currentTime)
|
||||
{
|
||||
if (car->_laps > 2)
|
||||
laps += (int)ceil( ( s->_totTime - s->currentTime ) / car->_bestLapTime + 0.3f );
|
||||
// For the case car->laps <= 2, the old laps only makes a stronger constraight, so no read to calculate it
|
||||
}
|
||||
if (car->_fuel < 1.5*cmpfuel &&
|
||||
car->_fuel < laps*cmpfuel)
|
||||
{
|
||||
|
@ -252,6 +261,18 @@ float SimpleStrategy::pitRefuel(tCarElt* car, tSituation *s)
|
|||
{
|
||||
float fuel;
|
||||
float cmpfuel = (fuelperlap == 0.0) ? expectedfuelperlap : fuelperlap;
|
||||
int laps = car->_remainingLaps;
|
||||
if (s->_totTime > s->currentTime)
|
||||
{
|
||||
if (car->_laps > 2)
|
||||
laps += ( s->_totTime - s->currentTime ) / car->_bestLapTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
// It has a pit stop in the first two laps. Normally we don't want to refuel.
|
||||
// This will cause for at least sufficient fuel.
|
||||
laps += 5;
|
||||
}
|
||||
fuel = MAX(MIN((car->_remainingLaps+1.5)*cmpfuel - car->_fuel, car->_tank - car->_fuel), 0.0);
|
||||
imaxfuel = GfParmGetNum(car->_carHandle, HYMIE_SECT_PRIV, "MaxFuel", (char*) NULL, fuel);
|
||||
if (imaxfuel > 0.0)
|
||||
|
@ -268,8 +289,12 @@ int SimpleStrategy::pitRepair(tCarElt* car, tSituation *s, Opponents *opp)
|
|||
pit_damage = 0;
|
||||
if (car->_dammage > PIT_DAMMAGE || car->_remainingLaps-car->_lapsBehindLeader > 40)
|
||||
{
|
||||
float laps = car->_remainingLaps + 1.0f;
|
||||
if (car->_laps > 2 && s->_totTime > s->currentTime)
|
||||
laps += ceil( ( s->_totTime - s->currentTime ) / car->_bestLapTime + 0.3f );
|
||||
float cmpfuel = (fuelperlap == 0.0) ? expectedfuelperlap : fuelperlap;
|
||||
float fuel = MAX(MIN((car->_remainingLaps+1.0)*cmpfuel, car->_tank), 0.0);
|
||||
float fuel = MAX(MIN(laps*cmpfuel - car->_fuel, car->_tank), 0.0);
|
||||
|
||||
if (fuel < car->_tank-15.0)
|
||||
dammage = MIN(car->_dammage, dammage);
|
||||
else
|
||||
|
|
|
@ -89,9 +89,11 @@ class SimpleStrategy : public AbstractStrategy {
|
|||
float lastpitfuel; // Amount refueled, special case when we refuel.
|
||||
float lastfuel; // the fuel available when we cross the start lane.
|
||||
float expectedfuelperlap; // Expected fuel per lap (may be very inaccurate).
|
||||
float expectedfuelpersecond; // Expected fuel per second (may be very inaccurate).
|
||||
float imaxfuel;
|
||||
|
||||
static const float MAX_FUEL_PER_METER; // [kg/m] fuel consumtion.
|
||||
static const float MAX_FUEL_PER_SECOND; // [kg/s] fuel consumtion.
|
||||
int PIT_DAMMAGE; // If damage > we request a pit stop.
|
||||
int pit_damage;
|
||||
int min_damage;
|
||||
|
|
|
@ -109,6 +109,7 @@ typedef struct RobotItf {
|
|||
|
||||
#define ROB_VAL_FEATURE_PENALTIES "penalties"
|
||||
#define ROB_VAL_FEATURE_TIMEDSESSION "timed_session"
|
||||
#define ROB_VAL_FEATURE_WEATHER "weather"
|
||||
|
||||
#endif /* _ROBOTV1_H_ */
|
||||
|
||||
|
|
|
@ -40,12 +40,12 @@ typedef tDynPt* (*tfGetSimCarTable)(int index);
|
|||
|
||||
typedef struct
|
||||
{
|
||||
tfSimInit init;
|
||||
tfSimConfig config;
|
||||
tfSimReConfig reconfig;
|
||||
tfSimUpdate update;
|
||||
tfSimInit init;
|
||||
tfSimConfig config;
|
||||
tfSimReConfig reconfig;
|
||||
tfSimUpdate update;
|
||||
tfSimSingleUpdate singleupdate;
|
||||
tfSimShutdown shutdown;
|
||||
tfSimShutdown shutdown;
|
||||
tfUpdateSimCarTable updatesimcartable;
|
||||
tfGetSimCarTable getsimcartable;
|
||||
|
||||
|
|
Loading…
Reference in a new issue