Esempio n. 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());
        }
Esempio n. 2
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);
        }
Esempio n. 3
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());
        }