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}"); } }
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); } }
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); } }
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); } }
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); } }
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)}"); } }
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()}"); } }
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); } }
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); } }
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); } }
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); } }
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); } }