Exemplo n.º 1
0
        public void MiniMaxEvaluator()
        {
            position  = new FrogsAndToadsPosition(gameString1);
            evaluator = new MiniMaxEvaluator();
            value     = evaluator.LeftEvaluation(position);
            Assert.AreEqual(2, value);

            position  = new FrogsAndToadsPosition(gameString2);
            evaluator = new MiniMaxEvaluator();
            value     = evaluator.LeftEvaluation(position);
            Assert.AreEqual(0, value);
            value = evaluator.LeftEvaluation(position.Reverse() as FrogsAndToadsPosition);
            Assert.AreEqual(0, value);

            position  = new FrogsAndToadsPosition(gameString3);
            evaluator = new MiniMaxEvaluator();
            value     = evaluator.LeftEvaluation(position);
            Assert.AreEqual(2, value);

            position  = new FrogsAndToadsPosition(gameString4);
            evaluator = new MiniMaxEvaluator();
            value     = evaluator.LeftEvaluation(position);
            Assert.AreEqual(3, value);

            position  = new FrogsAndToadsPosition(gameString5);
            evaluator = new MiniMaxEvaluator();
            value     = evaluator.RightEvaluation(position);
            Assert.AreEqual(-3, value);
        }
Exemplo n.º 2
0
        public void EvaluateToadMoves()
        {
            position = new FrogsAndToadsPosition(gameString6);
            MiniMaxEvaluator evaluator = new MiniMaxEvaluator();
            var x = evaluator.EvaluateToadMoves(position);

            Assert.AreEqual(2, x.Count);
            Assert.AreEqual(-2, x.First().value);
            Assert.AreEqual(1, x.Skip(1).First().value);

            position = position.PlayMove(new FrogsAndToadsMove(0, 2));
            x        = evaluator.EvaluateToadMoves(position.Reverse());
            Assert.AreEqual(2, x.Count);
            Assert.AreEqual(2, x.First().value);
            Assert.AreEqual(-1, x.Skip(1).First().value);
        }