/// <summary> /// Erases different number of sudoku cells based on the passed sudoku difficulty. /// </summary> /// <param name="sudokuBoard">A 9x9 jagged byte array.</param> public void EraseCells(byte[][] sudokuBoard, GameDifficultyType sudokuDifficulty) { if (!GameUtils.IsSudokuBoardValid(sudokuBoard)) { throw new ArgumentException(InvalidSudokuBoardMessage); } int cellsToErase = 0; if (sudokuDifficulty == GameDifficultyType.Easy) { cellsToErase = CellsToEraseOnEasyDifficulty; } else if (sudokuDifficulty == GameDifficultyType.Medium) { cellsToErase = CellsToEraseOnMediumDifficulty; } else if (sudokuDifficulty == GameDifficultyType.Hard) { cellsToErase = CellsToEraseOnHardDifficulty; } else { cellsToErase = CellsToEraseOnImpossibleDifficulty; } // the "algorithm" here is that we take a random cell from each row, erase it // and then erase the cell opposite to it by the minor diagonal while (cellsToErase > 0) { for (int row = 0; row < 9; row++) { int col = this.random.Next(0, 9); if (sudokuBoard[row][col] != 0) { sudokuBoard[row][col] = 0; cellsToErase--; } if (cellsToErase <= 0) { return; } int oppositeRow = 9 - col - 1; int oppositeCol = 9 - row - 1; if (sudokuBoard[oppositeRow][oppositeCol] != 0) { sudokuBoard[oppositeRow][oppositeCol] = 0; cellsToErase--; } if (cellsToErase <= 0) { return; } } } }
/// <summary> /// Generates a valid sudoku grid ready for solving. /// </summary> /// <param name="sudokuDifficulty">The difficulty for the generated sudoku.</param> public SudokuRow[] GenerateSudoku(GameDifficultyType sudokuDifficulty) { this.sudokuTransformer.ShuffleSudoku(this.generatedSudokuBoard); for (int i = 0; i < 9; i++) { this.generatedSudokuBoard[i].CopyTo(this.sudokuBoardForPlayer[i], 0); } this.sudokuTransformer.EraseCells(this.sudokuBoardForPlayer, sudokuDifficulty); return(GameUtils.GenerateSudokuGridFromBoard(this.sudokuBoardForPlayer)); }
public WorldModel Build(List <ServerPlayerModel> serverPlayerModels, GameDifficultyType gameDifficultyType, int npcTeamID) { // calculate average level (higher game difficulty increases npc level) float levelsSum = 0; for (int i = 0; i < serverPlayerModels.Count; i++) { levelsSum += serverPlayerModels[i].CombatantModel.Level; } int averageNpcLevelPlusDifficulty = (int)(levelsSum / serverPlayerModels.Count + .5f) + (int)gameDifficultyType * NPC_LEVELS_PER_DIFFICULTY_MULT; WorldModel worldModel = new WorldModel(); worldModel.ZoneModels = new ZoneModel[2]; for (int j = 0; j < worldModel.ZoneModels.Length; j++) { worldModel.ZoneModels[j] = buildZone(averageNpcLevelPlusDifficulty, RarityType.Common, RarityType.Legendary, npcTeamID, 1); worldModel.ZoneModels[j].ID = j; worldModel.ZoneModels[j].IsFinalZone = j == worldModel.ZoneModels.Length - 1; } return(worldModel); }
public void SetDifficulty(GameDifficultyType gameDifficultyType) { this.gameDifficultyType = gameDifficultyType; }
public static GameDifficultySettings GetPresetDifficultySettings(GameDifficultyType type) { //现在只返回Easy return(Easy); }
public GameDifficultySettings(GameDifficultyType difficulty, List <CustomerTypeInfo> numberOfType) { Difficulty = difficulty; NumberOfType = numberOfType; }