コード例 #1
0
        private static float getWorkersChanceValue(ref NumWorkers numWorkers)
        {
            float chance = WORKER_MAX_CHANCE_VALUE;

            // Check for missing uneducated workers
            if (numWorkers.maxNumUneducatedWorkers > 0 && numWorkers.numUneducatedWorkers < numWorkers.maxNumUneducatedWorkers)
            {
                chance -= (((float)numWorkers.maxNumUneducatedWorkers - (float)numWorkers.numUneducatedWorkers) / (float)numWorkers.maxNumUneducatedWorkers) * 0.15f * WORKER_MAX_CHANCE_VALUE;
            }

            // Check for missing educated workers
            if (numWorkers.maxNumEducatedWorkers > 0 && numWorkers.numEducatedWorkers < numWorkers.maxNumEducatedWorkers)
            {
                chance -= (((float)numWorkers.maxNumEducatedWorkers - (float)numWorkers.numEducatedWorkers) / (float)numWorkers.maxNumEducatedWorkers) * 0.45f * WORKER_MAX_CHANCE_VALUE;
            }

            // Check for missing well educated workers
            if (numWorkers.maxNumWellEducatedWorkers > 0 && numWorkers.numWellEducatedWorkers < numWorkers.maxNumWellEducatedWorkers)
            {
                chance -= (((float)numWorkers.maxNumWellEducatedWorkers - (float)numWorkers.numWellEducatedWorkers) / (float)numWorkers.maxNumWellEducatedWorkers) * 0.25f * WORKER_MAX_CHANCE_VALUE;
            }

            // Check for missing highly educated workers
            if (numWorkers.maxNumHighlyEducatedWorkers > 0 && numWorkers.numHighlyEducatedWorkers < numWorkers.maxNumHighlyEducatedWorkers)
            {
                chance -= (((float)numWorkers.maxNumHighlyEducatedWorkers - (float)numWorkers.numHighlyEducatedWorkers) / (float)numWorkers.maxNumHighlyEducatedWorkers) * 0.15f * WORKER_MAX_CHANCE_VALUE;
            }

            if (LOG_CHANCES)
            {
                Logger.logInfo(LOG_CHANCES, "MoveInProbabilityHelper.getQualityLevelChanceValue -- Worker Chance Value: {0} -- Missing Uneducated: {1} -- Missing Educated: {2} -- Missing Well Educated: {3} -- Missing Highly Educated: {4}", chance, (numWorkers.maxNumUneducatedWorkers - numWorkers.numUneducatedWorkers), (numWorkers.maxNumEducatedWorkers - numWorkers.numEducatedWorkers), (numWorkers.maxNumWellEducatedWorkers - numWorkers.numWellEducatedWorkers), (numWorkers.maxNumHighlyEducatedWorkers - numWorkers.numHighlyEducatedWorkers));
            }
            return(chance);
        }
コード例 #2
0
        //private static readonly float SENIOR_AGE_RANGE = Citizen.AGE_LIMIT_SENIOR - Citizen.AGE_LIMIT_ADULT;

        public static bool checkIfShouldMoveIn(uint[] familyWithStudents, ref Building buildingData, ref Randomizer randomizer, float operationRadius, int quality, ref NumWorkers numWorkers)
        {
            float chanceValue = BASE_CHANCE_VALUE;

            Logger.logInfo(LOG_CHANCES, "---------------------------------");

            // Age
            //chanceValue += getAgeChanceValue(familyWithStudents);

            // Distance
            chanceValue -= getDistanceChanceValue(familyWithStudents, ref buildingData, operationRadius);

            // Family Status
            chanceValue += getFamilyStatusChanceValue(familyWithStudents);

            // Wealth
            chanceValue += getWealthChanceValue(familyWithStudents, quality);

            // Workers
            chanceValue += getWorkersChanceValue(ref numWorkers);

            // Check for no chance
            if (chanceValue <= 0)
            {
                Logger.logInfo(LOG_CHANCES, "MoveInProbabilityHelper.checkIfShouldMoveIn -- No Chance: {0}", chanceValue);
                return(false);
            }

            // Check against random value
            uint maxChance   = (uint)MAX_CHANCE_VALUE;
            int  randomValue = randomizer.Int32(maxChance);

            Logger.logInfo(LOG_CHANCES, "MoveInProbabilityHelper.checkIfShouldMoveIn -- Total Chance Value: {0} -- Random Number: {1} -- result: {2}", chanceValue, randomValue, randomValue <= chanceValue);
            return(randomValue <= chanceValue);
        }