public void DefaultByOpa()
{
tableGear = new Dictionary<int, Dictionary<double, int>>();
tableThrottle = new Dictionary<int, Dictionary<double, double>>();
// Make sure there are 20 rpm steps, and 20 load steps
// (20x20 = 400 items)
for (int speed = 0; speed <= MaximumSpeed; speed += 1)
{
tableGear.Add(speed, new Dictionary<double, int>());
tableThrottle.Add(speed, new Dictionary<double, double>());
for (var load = 0.0; load <= 1.0; load += 0.1)
{
tableThrottle[speed].Add(load, 1);
var gearSet = false;
var shiftRpm = 800 + 600*load;
var highestGearBeforeStalling = 0;
for (int gear = 0; gear < Drivetrain.Gears; gear++)
{
var calculatedRpm = Drivetrain.GearRatios[gear] * speed;
if (calculatedRpm < 800) continue;
highestGearBeforeStalling = gear;
if (calculatedRpm > shiftRpm) continue;
gearSet = true;
tableGear[speed].Add(load, gear + 1);
break;
}
if (!gearSet)
tableGear[speed].Add(load, highestGearBeforeStalling+1);
}
}
}