コード例 #1
0
ファイル: SpHelper.cs プロジェクト: sesteves86/GOrganizer
        static internal int GetQualPosition(Classes.Driver driver, Classes.Car car, Classes.Divisions division)
        {
            int   position = 1;
            float sd       = Constants.sd;

            float qPerformance   = 80 - 0.03f * driver.GetOA() - 0.18f * car.GetCarLevel();
            float qOpPerformance = 80 - 0.03f * SpHelper.GetAvgOA(division) - 0.18f * SpHelper.GetAvgCarLevel(division);

            position = (int)(40 - 39 * Classes.Maths.NormalDistribution.GetCumulativeDistribution(qPerformance, qOpPerformance, sd));

            position = AssurePositionWithinLimits(position);

            return(position);
        }
コード例 #2
0
ファイル: SpHelper.cs プロジェクト: sesteves86/GOrganizer
        static internal int GetRacePosition(Driver driver, Car car, Divisions division, int ct)
        {
            int   position = 1;
            float sd       = Constants.sd;

            float rPerformance = (80 - 0.03f * driver.GetOA() - 0.18f * car.GetCarLevel())
                                 / (1f + 0.033f * ct / 100);
            float rOpPerformance = (80 - 0.03f * SpHelper.GetAvgOA(division) - 0.18f * SpHelper.GetAvgCarLevel(division))
                                   / (1f + 0.033f * SpHelper.GetAvgCT(division) / 100);

            position = (int)(40 - 39 * Classes.Maths.NormalDistribution.GetCumulativeDistribution(rPerformance, rOpPerformance, sd));

            position = AssurePositionWithinLimits(position);

            return(position);
        }
コード例 #3
0
ファイル: SpHelper.cs プロジェクト: sesteves86/GOrganizer
        static private int GetAfterRaceBalance(Driver driver, TechnicalDirector td, StaffFacilities sf, bool testing, TyresSupplier tyre, Car car, Divisions division, int qualPosition, int racePosition, int trainning, int[] carPartsBought)
        {
            int qualifyingCost = Constants.qualCost;

            int totalCosts = driver.Salary + driver.TrainningCost((DriverTrainning)trainning) +
                             td.Salary +
                             sf.GetExpenses() +
                             (testing ? 1000000 : 0) +
                             qualifyingCost +
                             tyre.GetActiveSupplierCost() +
                             car.GetCarUpgradesCost(carPartsBought);

            int raceWinnings = SpHelper.GetRaceWinnings(division, qualPosition, racePosition);

            //int balanceAfterRace = (int)(balanceM * 1000000f - totalCosts + raceWinnings);
            int balanceAfterRace = (int)(raceWinnings - totalCosts);

            return(balanceAfterRace);
        }
コード例 #4
0
ファイル: SpHelper.cs プロジェクト: sesteves86/GOrganizer
        static internal SeasonPlannerFullLine ProcessSeasonPlanner(SeasonPlannerFullLine spFull)
        {
            #region  Initial Values
            Classes.RaceTab rt = spFull.spOptimizer.raceTab;
            Classes.SeasonPlannerForDataTable spForDataTable = spFull.spTable; //null. Filled later
            Classes.TechnicalDirector         td             = spFull.spOptimizer.technicalDirector;
            Classes.Car             car          = (Classes.Car)spFull.spOptimizer.car.Clone();
            Classes.Car             carAfterRace = (Classes.Car)car.Clone();
            Classes.Driver          driver       = spFull.spOptimizer.driver;
            int                     trackId      = DB.SeasonTrack.GetTrackId(spFull.spTable.SeasonRaceNumber);
            Classes.Track           track        = DB.Track.ReadTrackFromDB(trackId);
            Classes.StaffFacilities sf           = spFull.spOptimizer.staffFacilities;
            Classes.TyresSupplier   tyre         = DB.Tyres.ReadActiveTyreSupplierFromDB();

            int seasonRaceNumber = rt.SeasonTrackIndex;
            //float balanceM = spFull.spTab.StartingBalanceM;
            float balanceM       = spFull.spTable.BalanceAfterRaceM;
            int[] carPartsBought = new int[11];

            Divisions division = (Divisions)spFull.spTab.Division;

            int  trainning       = (int)spFull.spDecisions.Training;
            bool testing         = spFull.spDecisions.Testing;
            int  targetCarLevel  = spFull.spDecisions.TargetCarLevelEngBra;
            int  targetCarLevel2 = spFull.spDecisions.TargetCarLevelOthers;
            int  ct = spFull.spDecisions.CT;
            #endregion

            #region Process
            carAfterRace.UpdateCarWearAfterRace(track, driver, ct);

            if (testing)
            {
                carAfterRace.DoTesting(td, track, sf);
            }
            carPartsBought = GetWhichCarPartsChange(car, carAfterRace, targetCarLevel, targetCarLevel2);

            carAfterRace = (Classes.Car)car.Clone();
            carAfterRace = GetCarAfterPartsChangeAndWear(car, testing, track, driver, td, sf, ct, carPartsBought);

            int qualPosition = SpHelper.GetQualPosition(driver, car, division);
            int racePosition = SpHelper.GetRacePosition(driver, car, division, ct);
            int racePoints   = SpHelper.GetPoints(racePosition);

            //Expenses processing
            float balanceAfterRaceM = ((balanceM * 1000000) + GetAfterRaceBalance(driver, td, sf, testing, tyre, car, division, qualPosition, racePosition, trainning, carPartsBought)) / 1000000f;
            #endregion

            #region Output
            SeasonPlannerDecision spDecisionsNext = new SeasonPlannerDecision();
            spDecisionsNext = (Classes.SeasonPlannerDecision)spFull.spDecisions.Clone();

            SeasonPlannerForDataTable spTableNext = new SeasonPlannerForDataTable();
            spTableNext.SeasonRaceNumber  = spFull.spTable.SeasonRaceNumber + 1;
            spTableNext.BalanceAfterRaceM = balanceAfterRaceM;
            spTableNext.CarPartsChanged   = carPartsBought;
            spTableNext.CarWearAfterRace  = carAfterRace.GetWears();
            spTableNext.QualPosition      = qualPosition;
            spTableNext.RacePosition      = racePosition;

            SeasonPlannerForOptimizer spOptimizerNext = new SeasonPlannerForOptimizer();
            spOptimizerNext.car = (Classes.Car)carAfterRace.Clone();

            driver.DoTrainning((DriverTrainning)trainning);
            driver.DriverUpdateAfterRace(racePosition);
            spOptimizerNext.driver            = driver;
            spOptimizerNext.Id                = spFull.spOptimizer.Id + 1;
            spOptimizerNext.raceTab           = rt; //How to update trackId?
            spOptimizerNext.staffFacilities   = sf; //To Do: Update sf after races (convert levels to float type)
            spOptimizerNext.technicalDirector = td;

            SeasonPlannerTab spTabNext = new SeasonPlannerTab();
            spTabNext.CurrentPoints    = spFull.spTab.CurrentPoints + racePoints;
            spTabNext.Division         = spFull.spTab.Division;
            spTabNext.StartingBalanceM = balanceAfterRaceM;
            spTabNext.TargetPoints     = spFull.spTab.TargetPoints;

            SeasonPlannerFullLine spFullNext = new SeasonPlannerFullLine(spDecisionsNext, spTableNext, spOptimizerNext, spTabNext);

            return(spFullNext);

            #endregion
        }