Example #1
0
        public void Initialize()
        {
            var contestant1 = new Contestant("Nice",new Nice());
              var contestant2 = new Contestant("Mean",new Mean());

              pd = new PrisonersDilemma(contestant1, contestant2);
        }
Example #2
0
        public void ContestantTest()
        {
            var name = "NameONE";

              IContestant contestant = new Contestant(name,new Nice());
              Assert.IsNotNull(contestant);

              Assert.AreEqual(name, contestant.Name);
        }
Example #3
0
        public void NiceVSNiceTest()
        {
            var contestant1 = new Contestant("Nice", new Nice());
              var contestant2 = new Contestant("Nice2", new Nice());

              pd = new PrisonersDilemma(contestant1, contestant2);

              var result = pd.Step();
              Assert.AreEqual("C,C 1,1 1,1", result);

              result = pd.Step();
              Assert.AreEqual("C,C 1,1 2,2", result);

              result = pd.Step();
              Assert.AreEqual("C,C 1,1 3,3", result);

              result = pd.Step();
              Assert.AreEqual("C,C 1,1 4,4", result);
        }
Example #4
0
        private static void RunPrisonersDilemma()
        {
            var contestant1 =
              //new Contestant("Nice", new Nice());
              //new Contestant("mean", new Mean());
              new Contestant("titfortat", new TitForTat());
              //new Contestant("RNG", new RandomChoice());

              var contestant2 =
              //new Contestant("Mean", new Mean());
              //new Contestant("nice", new Nice());
              //new Contestant("titfortat", new TitForTat());
              new Contestant("RNG", new RandomChoice());

              var pd = new PrisonersDilemma(contestant1, contestant2);

              Console.WriteLine(pd.ShowContestants());

              for (int i = 1; i < 40; i++) {
            Console.WriteLine(pd.Step());
              }
        }
 public void StepWithLastChoiceTest()
 {
     var contestant1 = new Contestant("TitForTat", new TitForTat());
       var result = contestant1.Step(StrategyChoice.Defect);
       Assert.AreEqual(result, StrategyChoice.Defect);
 }
 public void StepNoLastChoiceTest()
 {
     var contestant1 = new Contestant("TitForTat", new TitForTat());
       var result = contestant1.Step(null);
       Assert.AreEqual(result,StrategyChoice.Cooperate);
 }
 public void ContestantNullStrategyTest()
 {
     var contestant1 = new Contestant("Nice", null);
       Assert.IsNotNull(contestant1);
 }
 public void ContestantEmptyNameTest()
 {
     var contestant1 = new Contestant(string.Empty, new Nice());
       Assert.IsNotNull(contestant1);
 }
 public void ContestantConstructTest()
 {
     var contestant1 = new Contestant("Nice", new Nice());
       Assert.IsNotNull(contestant1);
 }