private void ChangeDifficultyParameter(DifficultyParameter difficultyParameter, int newValue) { Assert.IsTrue(newValue >= GameConstants.MinDifficulty && newValue <= GameConstants.MaxDifficulty); DifficultyCoefs[difficultyParameter] = newValue; EventLogger.PrintToLog("Difficulty Changed: " + difficultyParameter + " Value: " + newValue); print("Difficulty Changed: " + difficultyParameter + " Value: " + newValue); }
public float GetDifficultyMultiplier(DifficultyParameter difficultyParameter) { // returned values for parameters between 1 to 5 are the following: // 0.44 | 0.67 | 1 | 1.5 | 2.25 int difficultyDifference = GameConstants.MidDifficulty - DifficultyCoefs[difficultyParameter]; float difficultyMultiplier = Mathf.Pow(GameConstants.DifficultyCoef, difficultyDifference); return(difficultyMultiplier); }
public float GetAverageDifficultyLevel() { float avgDifficulty = 0.0f; for (DifficultyParameter curParam = 0; curParam < DifficultyParameter.DpCount; ++curParam) { avgDifficulty += DifficultyCoefs[curParam]; } avgDifficulty /= (int)DifficultyParameter.DpCount; return(avgDifficulty); }
private void RandomDiffAdjustment(bool isIncrement) { //TODO LEARN remove below code after ML is implemented //start int numRetries = 3; for (int i = 0; i < numRetries; ++i) { DifficultyParameter selectedDifficultyParameter = (DifficultyParameter)Random.Range(0, (int)DifficultyParameter.DpCount); int oldValue = DifficultyCoefs[selectedDifficultyParameter]; if (isIncrement ? oldValue <GameConstants.MaxDifficulty : oldValue> GameConstants.MinDifficulty) { ChangeDifficultyParameter(selectedDifficultyParameter, oldValue + GameConstants.DifficultyStep * (isIncrement ? 1 : -1)); break; } } //end }
private void DetermineInitialDifficultyLevels() { //pull avg difficulty from questionnaire float initialDifficultyGoal = QuestionnaireManager.DeterminedInitialDifficultyCoef; //TODO LATER temporarily, we're automatically trying to match starting difficulty level //with the determined initial difficulty //by increasing difficulty coefficients until we're close enough to the initial difficulty const int diffParamCount = (int)DifficultyParameter.DpCount; int[] difficultyWeights = Enumerable.Repeat(GameConstants.MinDifficulty, diffParamCount).ToArray(); int currentWeightIndex = 0; float achievedDifficultyCoef = GameConstants.MinDifficulty; int requiredIncrementCount = 0; while (achievedDifficultyCoef < initialDifficultyGoal) { requiredIncrementCount += GameConstants.DifficultyStep; difficultyWeights[currentWeightIndex] += GameConstants.DifficultyStep; currentWeightIndex = (currentWeightIndex + 1) % diffParamCount; achievedDifficultyCoef = (float)(GameConstants.MinDifficulty * diffParamCount + requiredIncrementCount) / diffParamCount; } print("Target: " + initialDifficultyGoal + ", Achieved: " + achievedDifficultyCoef); //shuffle the array new System.Random().Shuffle(difficultyWeights); DifficultyCoefs = new Dictionary <DifficultyParameter, int>(diffParamCount); for (DifficultyParameter curParam = 0; curParam < DifficultyParameter.DpCount; ++curParam) { //TODO LEARN these multipliers have to be pulled out from our learning data (from existing player models) DifficultyCoefs.Add(curParam, difficultyWeights[(int)curParam]); print("Param: " + curParam + " Weight: " + DifficultyCoefs[curParam]); } print("Average Difficulty: " + GetAverageDifficultyLevel()); }