Exemple #1
0
        public void TestIsTigerGoalState()
        {
            State s = new State();
            Board b = s.Board;
            Assert.IsNotNull(b);
            Assert.IsNotNull(b.GetSpace(2,2));
            Assert.IsNotNull(s.GetSpaceState(2,2));

            GoatPlacementMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat);
            TigerCaptureMove t1 = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger);
            TigerCaptureMove t2 = new TigerCaptureMove(b.GetSpace(2,2), b.GetSpace(0,4), b.GetSpace(1, 3), s.Tiger);

            Assert.IsFalse(s.IsTigerGoalState());
            Assert.IsFalse(s.IsGoatGoalState());

            g.ExecuteMove(s);
            t1.ExecuteMove(s);  // 1 down
            g.ExecuteMove(s);
            t2.ExecuteMove(s);  // 2 down
            g.ExecuteMove(s);
            t1.ExecuteMove(s);  // 3 down
            g.ExecuteMove(s);
            t2.ExecuteMove(s);  // 4 down
            g.ExecuteMove(s);
            t1.ExecuteMove(s);  //5 down

            Assert.IsTrue(s.IsTigerGoalState());
            Assert.IsFalse(s.IsGoatGoalState());
        }
Exemple #2
0
        public void TestCloneMove()
        {
            State s = new State();
            Board b = s.Board;
            Assert.IsNotNull(b.GetSpace(1, 3));
            Assert.IsNotNull(s.Tiger);
            GoatPlacementMove g1 = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat);
            GoatPlacementMove g2 = (GoatPlacementMove) g1.Clone();
            Assert.AreNotEqual(g1, g2);
            Assert.AreEqual(g1.EndSpace, g2.EndSpace);

            TigerCaptureMove t1 = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger);
            Assert.IsNotNull(t1.StartSpace);
            TigerCaptureMove t2 = (TigerCaptureMove) t1.Clone();
            Assert.AreNotEqual(t1, t2);
            Assert.AreEqual(t1.EndSpace, t2.EndSpace);

            SlideMove s1 = new SlideMove(b.GetSpace(4, 4), b.GetSpace(3, 3), s.Tiger);
            Assert.IsNotNull(s1.StartSpace);
            SlideMove s2 = (SlideMove) s1.Clone();
            Assert.AreNotEqual(s1, s2);
            Assert.AreEqual(s1.EndSpace, s2.EndSpace);
        }
Exemple #3
0
        public void TestMoveList()
        {
            State s = new State();
            Board b = s.Board;

            Assert.AreEqual(s.Goat.GetCountLegalMoves(s), 21);
            Assert.AreEqual(s.Tiger.GetCountLegalMoves(s), 12);

            GoatPlacementMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat);
            g.ExecuteMove(s);
            Assert.AreEqual(s.Goat.GetCountLegalMoves(s), 20);

            TigerCaptureMove t = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger);
            t.ExecuteMove(s);

            Assert.AreEqual(s.Goat.GetCountLegalMoves(s), 21);
            Assert.AreEqual(s.Tiger.GetCountLegalMoves(s), 17);
        }
Exemple #4
0
        public void TestTigerCaptureMove()
        {
            State s = new State();
            Board b = s.Board;
            Assert.IsNotNull(b.GetSpace(1, 3));
            Assert.IsNotNull(s.Tiger);
            AbstractMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat);
            g.ExecuteMove(s);

            TigerCaptureMove t = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger);
            Assert.IsNotNull(t.StartSpace);
            Assert.IsNotNull(t.EndSpace);
            Assert.IsNotNull(t.JumpSpace);
            Assert.IsNotNull(t.Player);
            t.ExecuteMove(s);
            Assert.AreEqual(b.GetSpace(0, 4).GetSpaceState(), 'X');
            Assert.AreEqual(b.GetSpace(2, 2).GetSpaceState(), 'T');
            Assert.AreEqual(b.GetSpace(1, 2).GetSpaceState(), 'X');
            Assert.AreEqual(s.Goat.GoatsKilled, 1);
            Console.WriteLine("Tested placement 1,3 and capture from 0,4 to 2,2 \r\n" + s.Board.GetBoardPic());
        }