IEnumerator ThinkAndAct()
        {
            _isThinking = true;
            foreach (AbstractAIBrain utilityAiBrain in UtilityAiBrains)
            {
                CalculateOptions(utilityAiBrain);
                yield return(null);

                AIOption aiOption = ChooseOption(utilityAiBrain);
                if (aiOption == null)
                {
                    continue;
                }
                if (SelectedOptions.ContainsKey(utilityAiBrain))
                {
                    SelectedOptions[utilityAiBrain] = aiOption;
                }
                else
                {
                    SelectedOptions.Add(utilityAiBrain, aiOption);
                }
                aiOption.ExecuteActions(this);
                yield return(null);
            }
            _isThinking = false;
        }
Example #2
0
        public void TestCase()
        {
            GameController.StartGame();
            GameController.SetDifficulty(AIOption.Easy);
            AIOption expected = AIOption.Easy;
            AIOption actual   = GameController._aiSetting;

            Assert.AreEqual(expected, actual);
        }
        public static void StartGameTest()
        {
            _theGame   = null;
            _aiSetting = AIOption.Medium;
            StartGame();

            String actual = _ai.ToString();

            Assert.AreEqual("BattleShips.AIMediumPlayer", actual, "Fail to Test Start Game");
        }
Example #4
0
        private void ThinkAndAct()
        {
            AIOption option = ChooseOption();

            if (option == null)
            {
                return;
            }
            option.ExecuteActions(this);
        }
Example #5
0
    public void ChooseOption()
    {
        int randomOption = Random.Range(0, 1);

        if (randomOption == 0)
        {
            currentOption = AIOption.Spell;
        }
        else
        {
            currentOption = AIOption.Swap;
        }
    }
Example #6
0
    public AIOption GetRandomOptionToPerform()
    {
        int random = Random.Range(0, 2);

        if (random == 1)
        {
            currentOption = AIOption.Spell;
        }
        else
        {
            currentOption = AIOption.Swap;
        }
        return(currentOption);
    }
Example #7
0
    /// <summary>
    /// Creates a new AI player based on the current setting
    /// Returns the created ai
    /// </summary>
    public static AIPlayer CreateAIPlayer(AIOption setting)
    {
        AIPlayer player = null;

        switch (setting)
        {
        case AIOption.Easy:
            player = new AIEasyPlayer(_theGame);
            break;

        case AIOption.Medium:
            player = new AIMediumPlayer(_theGame);
            break;

        case AIOption.Hard:
            player = new AIHardPlayer(_theGame);
            break;

        default:
            player = new AIHardPlayer(_theGame);
            break;
        }
        return(player);
    }
Example #8
0
 /// <summary>
 /// Sets the difficulty for the next level of the game.
 /// </summary>
 /// <param name="setting">the new difficulty level</param>
 public static void SetDifficulty(AIOption setting)
 {
     _aiSettings = setting;
 }
	/// <summary>
	/// Sets the difficulty for the next level of the game.
	/// </summary>
	/// <param name="setting">the new difficulty level</param>
	public static void SetDifficulty(AIOption setting)
	{
		_aiSetting = setting;
	}
Example #10
0
 /// <summary>
 /// Sets the difficulty.
 /// </summary>
 /// <param name="setting">Setting.</param>
 public static void SetDifficulty(AIOption setting)
 {
     _aiSetting = setting;                                                           /* making the next setting for next level of the game*/
 }