public GameEngine(EngineSettings settings) { Board = new List <BoardCell>(); for (var i = 0; i < 9; i++) { Board.Add(new BoardCell()); } Players = new List <IPlayer> { new Player { PlayerId = 1, IsPlayerTurn = true, PlayerAvatar = settings.Player1AvatarId }, new Player { PlayerId = 2, IsPlayerTurn = false, PlayerAvatar = settings.Player2AvatarId } }; if (settings.GameType == GameType.Singleplayer) { Players[1].PlayerType = PlayerType.Ai; } GameType = settings.GameType; AiDifficulty = settings.Difficulty; }
//private bool FindWorkerBesideOutpost(Dice_Control playerOutpost) //{ // //revise to look next to outposts for a worker. // List<Dice_Control> workers = gameControl.playerControl.GetAllPlayerWorkers(playerOutpost.player); // if (workers.Count == 1) // { // Debug.Log($"1 worker for player: {playerOutpost.player.playerName} at {workers[0].tileControl.tileIndex}"); // List<TileControl> foundOutpost = pathFinding.GetAjacentTiles(workers[0].tileControl, GetAdjacentTilesType.AllFriendlyOutposts, playerOutpost.player); // if (foundOutpost.Count > 0) // { // Debug.Log($"worker {workers[0].tileControl.tileIndex} is next to outpost at {foundOutpost[0].tileIndex}"); // leiginToUse = workers[0];//set a worker next to an outpost to the active unit // return true; // } // else // { // Debug.Log($"worker not next to outpost"); // return false; // } // } // else // { // Debug.Log($"Multible workers for player: {playerOutpost.player.playerName}"); // foreach (Dice_Control worker in workers) // { // if (pathFinding.GetAjacentTiles(worker.tileControl, GetAdjacentTilesType.AllFriendlyOutposts, playerOutpost.player).Count > 0) // { // Debug.Log($" - worker {worker.currentValue} {worker.tileControl.tileIndex} is next to outpost"); // leiginToUse = worker;//set a worker next to an outpost to the active unit // //for multible outposts get the tile with the outpost on it// easy ai won't make new outpost, so todo // return true; // } // else // { // Debug.Log($" - worker {worker.tileControl.tileIndex} not next to outpost"); // } // } // } // return false; //there was no worker next to a base //} //private bool PlayerHasSoldier(Player player) //{ // leiginToUse = gameControl.playerControl.GetFirstPlayerSoldier(player); // if (leiginToUse != null) // { // Debug.Log($"Soldier found at {leiginToUse.tileControl.tileIndex}"); // return true; // } // else // { // Debug.Log($"No soldier found for {player.playerName}"); // return false; // } //} //------------------------------------------------------------------------------------------------------------------------------ internal void SetDifficulty(AiDifficulty AIdifficulty) { this.difficulty = AIdifficulty; switch (difficulty) { case AiDifficulty.Easy: { workerValueThreshold = GlobalVariables.data.EASY_AI_WORKER_VALUE_THRESHOLD; soldierValueThreshold = GlobalVariables.data.EASY_AI_SOLDIER_VALUE_THRESHOLD; incomeValueThreshold = GlobalVariables.data.EASY_AI_INCOME_THRESHOLD; break; } case AiDifficulty.Medium: { workerValueThreshold = GlobalVariables.data.MEDIUM_AI_WORKER_VALUE_THRESHOLD; soldierValueThreshold = GlobalVariables.data.MEDIUM_AI_SOLDIER_VALUE_THRESHOLD; incomeValueThreshold = GlobalVariables.data.MEDIUM_AI_INCOME_THRESHOLD; break; } case AiDifficulty.Hard: { workerValueThreshold = GlobalVariables.data.HARD_AI_WORKER_VALUE_THRESHOLD; soldierValueThreshold = GlobalVariables.data.HARD_AI_SOLDIER_VALUE_THRESHOLD; incomeValueThreshold = GlobalVariables.data.HARD_AI_INCOME_THRESHOLD; break; } } }
private void Start() { DontDestroyOnLoad(gameObject); if (playerInstance == null) { playerInstance = this; } else { Object.Destroy(gameObject); } }
public void Initialize() { if (IsInitialized == true) { return; } difficulty = TeamController.AiDifficulty; difficultyData = Resources.Load <Data.AiDifficultyData>("Data/Ai/AiDifficultyData_" + difficulty.ToString()); difficultyData.Probabilities.GetDatas(Probabilities); difficultyData.RandomRanges.GetDatas(RandomRanges); difficultyData.StatusValues.GetDatas(StatusValues); }
public void SetDifficulty(AiDifficulty _difficulty) { if (_difficulty == AiDifficulty.Custom) { return; } difficulty = _difficulty; switch (_difficulty) { case AiDifficulty.Easy: accelerationSensitivity = 0.5f; brakeSensitivity = 0.5f; accelerationWander = Random.Range(0.5f, 0.75f); nitroProbability = Random.Range(0.0f, 0.25f); break; case AiDifficulty.Meduim: accelerationSensitivity = 0.8f; brakeSensitivity = 0.8f; accelerationWander = Random.Range(0.1f, 0.25f); nitroProbability = Random.Range(0.25f, 0.75f); break; case AiDifficulty.Hard: accelerationSensitivity = 1f; brakeSensitivity = 1f; accelerationWander = 0; nitroProbability = Random.Range(0.5f, 1f); break; } }
public Player CreatePlayer(AiDifficulty difficulty, string name) { var standardOrder = new StandardOrder(); var scoreCalculator = new ScoreCalculator(); switch (difficulty) { case AiDifficulty.Easy: return new Player(name, -1, new LowestCardPlayStrategy(standardOrder), new MinAverageDecision(scoreCalculator), new PercentageScoreCountStrategy(70, scoreCalculator)); case AiDifficulty.Medium: return new Player(name, -1, new LowestCardPlayStrategy(standardOrder), new RandomDecision(), new PercentageScoreCountStrategy(80, scoreCalculator)); case AiDifficulty.Hard: return new Player(name, -1, new LowestCardPlayStrategy(standardOrder), new OptimisticDecision(), new PercentageScoreCountStrategy(90, scoreCalculator)); case AiDifficulty.Expert: return new Player(name, -1, new LowestCardPlayStrategy(standardOrder), new MaxAverageDecision(scoreCalculator), new PercentageScoreCountStrategy(100, scoreCalculator)); default: throw new NotSupportedException("Difficulty type not supported."); } }