示例#1
0
 public void ChooseCoop_When_OpponentPreviousIsCoop()
 {
     for (int i = 1; i < RoundsToTest; i++)
     {
         Choice choice = Strategy.GetNextChoice(GameScenarios.RandomChoices(i), GameScenarios.AllCoop(i));
         Assert.AreEqual(Choice.Coop, choice, $"Round {i}");
     }
 }
示例#2
0
 public void ChooseCheat_When_OpponentRandom()
 {
     for (int i = 1; i < RoundsToTest; i++)
     {
         Choice choice = Strategy.GetNextChoice(GameScenarios.RandomChoices(i), GameScenarios.RandomChoices(i));
         Assert.AreEqual(Choice.Cheat, choice);
     }
 }
示例#3
0
 public void ChooseCoop_When_OwnPreviousIsCheat()
 {
     for (int i = 1; i < RoundsToTest; i++)
     {
         Choice choice = Strategy.GetNextChoice(GameScenarios.AllCheat(i), GameScenarios.RandomChoices(i));
         Assert.AreEqual(Choice.Coop, choice);
     }
 }
示例#4
0
        public void AlwaysChooseCheat_When_OpponentEverCheats()
        {
            for (int i = 0; i < RoundsToTest; i++)
            {
                Choice choice = Strategy.GetNextChoice(GameScenarios.RandomChoices(i + 1), GameScenarios.RandomChoices(i).Append(Choice.Cheat));

                Assert.AreEqual(Choice.Cheat, choice);
            }
        }
示例#5
0
        public void AlwaysChooseCoop_When_OpponentAlwaysCoops()
        {
            for (int i = 1; i <= RoundsToTest; i++)
            {
                Choice choice = Strategy.GetNextChoice(GameScenarios.RandomChoices(i), GameScenarios.AllCoop(i));

                Assert.AreEqual(Choice.Coop, choice);
            }
        }
示例#6
0
        public void ChooseSameAsOpponentPrevious_WithRandomGeneration()
        {
            for (int i = 1; i < RoundsToTest; i++)
            {
                IEnumerable <Choice> opponentChoices = GameScenarios.RandomChoices(i);
                Choice choice = Strategy.GetNextChoice(GameScenarios.RandomChoices(i), opponentChoices);

                Choice expected = opponentChoices.Last();
                Assert.AreEqual(expected, choice, $"Opponent's Choices:{string.Join(" | ", opponentChoices)}");
            }
        }
示例#7
0
        public void ChooseOppositeOfOwnPrevious_WithRandomGeneration()
        {
            for (int i = 1; i < RoundsToTest; i++)
            {
                IEnumerable <Choice> ownChoices = GameScenarios.RandomChoices(i);
                Choice choice = Strategy.GetNextChoice(ownChoices, GameScenarios.RandomChoices(i));

                Choice expected = ownChoices.Last() == Choice.Cheat ? Choice.Coop : Choice.Cheat;
                Assert.AreEqual(expected, choice, $"Last Own Choice: {ownChoices.Last()}");
            }
        }
示例#8
0
        public void AlwaysChooseCheat_When_OpponentEverRandomlyCheats()
        {
            for (int i = 1; i <= RoundsToTest; i++)
            {
                IEnumerable <Choice> opponentChoices = GameScenarios.RandomChoices(i);
                Choice choice = Strategy.GetNextChoice(GameScenarios.RandomChoices(i), opponentChoices);

                Choice expected = opponentChoices.Any(oc => oc == Choice.Cheat) ? Choice.Cheat : Choice.Coop;

                Assert.AreEqual(expected, choice);
            }
        }
示例#9
0
        public void LaterMovesAlwaysCheat_When_OpponentCoopAllFirstFour(Choice opponentsFirstChoice, Choice opponentsSecondChoice, Choice opponentsThirdChoice, Choice opponentsFourthChoice)
        {
            var opponentOpener = new Choice[] { opponentsFirstChoice, opponentsSecondChoice, opponentsThirdChoice, opponentsFourthChoice };
            var ownOpener      = new Choice[] { Choice.Coop, Choice.Cheat, Choice.Coop, Choice.Coop };

            for (int i = 0; i <= RoundsToTest - 4; i++)
            {
                Choice choice = Strategy.GetNextChoice(ownOpener.Concat(GameScenarios.RandomChoices(i)), opponentOpener.Concat(GameScenarios.RandomChoices(i)));

                Assert.AreEqual(Choice.Cheat, choice);
            }
        }
示例#10
0
        public void OnlyCheat_When_OpponentLastTwoCheat()
        {
            for (int i = 3; i <= RoundsToTest - 3; i++)
            {
                IEnumerable <Choice> opponentChoices = GameScenarios.RandomChoices(i);
                Choice expected = opponentChoices.TakeLast(2).All(oc => oc == Choice.Cheat) ? Choice.Cheat : Choice.Coop;

                Choice choice = Strategy.GetNextChoice(GameScenarios.RandomChoices(i), opponentChoices);

                Assert.AreEqual(expected, choice);
            }
        }
示例#11
0
        public void ChooseOppositeOfLast_When_OpponentLastCheat()
        {
            for (int i = 0; i <= RoundsToTest - 1; i++)
            {
                var ownMoves = GameScenarios.RandomChoices(i + 1);
                var oppMoves = GameScenarios.RandomChoices(i).Append(Choice.Cheat);

                Choice expected = ownMoves.Last() == Choice.Coop ? Choice.Cheat : Choice.Coop;

                Choice actual = Strategy.GetNextChoice(ownMoves, oppMoves);

                Assert.AreEqual(expected, actual);
            }
        }
示例#12
0
        public void LaterMovesCopyOpponentLast_When_OpponentCheatInAnyFirstFour(Choice opponentsFirstChoice, Choice opponentsSecondChoice, Choice opponentsThirdChoice, Choice opponentsFourthChoice)
        {
            var opponentOpener = new Choice[] { opponentsFirstChoice, opponentsSecondChoice, opponentsThirdChoice, opponentsFourthChoice };
            var ownOpener      = new Choice[] { Choice.Coop, Choice.Cheat, Choice.Coop, Choice.Coop };

            for (int i = 0; i <= RoundsToTest - 4; i++)
            {
                IEnumerable <Choice> opponentChoices = opponentOpener.Concat(GameScenarios.RandomChoices(i));
                Choice expected = opponentChoices.Last();

                Choice choice = Strategy.GetNextChoice(ownOpener.Concat(GameScenarios.RandomChoices(i)), opponentChoices);

                Assert.AreEqual(expected, choice);
            }
        }