Beispiel #1
0
        public void MoveSet_AddMultipleDuplicateTest()
        {
            Move[] movesToAdd = _validMovesSorted;

            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            int count = 0;

            Assert.AreEqual(count, ms.Count);

            foreach (Move move in movesToAdd)
            {
                Assert.IsTrue(ms.Add(move));
                count++;
                Assert.AreEqual(count, ms.Count);
                Assert.IsTrue(ms.Contains(move));
            }

            foreach (Move move in movesToAdd)
            {
                Assert.IsFalse(ms.Add(move));
                Assert.AreEqual(count, ms.Count);
                Assert.IsTrue(ms.Contains(move));
            }
        }
Beispiel #2
0
        public void MoveSet_AddMultipleDuplicateByEnumerableTest()
        {
            Move[] movesToAdd = _validMovesSorted;

            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            Assert.AreEqual(0, ms.Count);
            ms.Add(movesToAdd);
            Assert.AreEqual(movesToAdd.Length, ms.Count);

            foreach (Move move in movesToAdd)
            {
                Assert.IsTrue(ms.Contains(move));
            }

            ms.Add(movesToAdd);
            Assert.AreEqual(movesToAdd.Length, ms.Count);

            foreach (Move move in movesToAdd)
            {
                Assert.IsTrue(ms.Contains(move));
            }
        }
Beispiel #3
0
        public void MoveSet_AddSingleDuplicateTest()
        {
            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            Assert.IsTrue(ms.Add(Move.Pass));
            Assert.AreEqual(1, ms.Count);
            Assert.IsTrue(ms.Contains(Move.Pass));

            Assert.IsFalse(ms.Add(Move.Pass));
            Assert.AreEqual(1, ms.Count);
            Assert.IsTrue(ms.Contains(Move.Pass));
        }
Beispiel #4
0
 public void CreateMoveSet()     // Just for testing
 {
     MoveSet.Add(new Attack("Downward Strike", 3));
     MoveSet.Add(new Attack("Upward Strike", 3));
     MoveSet.Add(new Attack("Thrust", 5));
     MoveSet.Add(new Attack("ULTIMATE NOT OVERPOWERED ATTACK", 9999));
 }
Beispiel #5
0
 public override void GenerateMoves(IBoardState boardState)
 {
     foreach (var move in TestMoves)
     {
         MoveSet.Add(move);
     }
 }
Beispiel #6
0
        /// <summary>
        ///     Generates all legal <see cref="IPawn" /> moves
        /// </summary>
        /// <param name="boardState"></param>
        public override void GenerateMoves(IBoardState boardState)
        {
            IChessPieceMover cpm = ModelLocator.ChessPieceMover;

            MoveSet.Clear();
            ChessPosition oneSpaceFromLocation = Color == ChessColor.White ? cpm.North(Location) : cpm.South(Location);
            bool          oneSpaceMoveIsLegal  = !boardState.Contains(oneSpaceFromLocation);

            if (oneSpaceMoveIsLegal)
            {
                MoveSet.Add(oneSpaceFromLocation);
            }
            else
            {
                return;
            }

            ChessPosition twoSpaceFromLocation = Color == ChessColor.White
                ? cpm.North(oneSpaceFromLocation)
                : cpm.South(oneSpaceFromLocation);
            bool twoSpaceMoveIsLegal = !boardState.Contains(twoSpaceFromLocation);

            if (!HasMoved && twoSpaceMoveIsLegal)
            {
                MoveSet.Add(Color == ChessColor.White
                    ? cpm.North(cpm.North(Location))
                    : cpm.South(cpm.South(Location)));
            }
        }
Beispiel #7
0
        public void MoveSet_RemoveMultipleTest()
        {
            Move[] validMoves = _validMovesSorted;

            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            int count = 0;

            Assert.AreEqual(count, ms.Count);

            foreach (Move move in validMoves)
            {
                Assert.IsTrue(ms.Add(move));
                count++;
                Assert.AreEqual(count, ms.Count);
                Assert.IsTrue(ms.Contains(move));
            }

            foreach (Move move in validMoves)
            {
                Assert.IsTrue(ms.Remove(move));
                count--;
                Assert.AreEqual(count, ms.Count);
                Assert.IsFalse(ms.Contains(move));
            }
        }
Beispiel #8
0
        public void MoveSet_RemoveMultipleByEnumerableTest()
        {
            Move[] validMoves = _validMovesSorted;

            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            Assert.AreEqual(0, ms.Count);
            ms.Add(validMoves);
            Assert.AreEqual(validMoves.Length, ms.Count);

            foreach (Move move in validMoves)
            {
                Assert.IsTrue(ms.Contains(move));
            }

            ms.Remove(validMoves);
            Assert.AreEqual(0, ms.Count);

            foreach (Move move in validMoves)
            {
                Assert.IsFalse(ms.Contains(move));
            }
        }
Beispiel #9
0
 public void CreateMoveSet()     // Just for testing
 {
     MoveSet.Add(new Attack("Downward Strike", 3, Animation.Downward));
     MoveSet.Add(new Attack("Upward Strike", 3, Animation.Upward));
     MoveSet.Add(new Attack("Thrust", 5, Animation.Thrust));
     MoveSet.Add(new Attack("PRAISE THE SUN", 9999, Animation.Special));
 }
Beispiel #10
0
        private void GenerateEastNorthEastMove(IBoardState boardState, IChessPieceMover cpm)
        {
            ChessPosition move = cpm.East(cpm.NorthEast(Location));

            if (!boardState.Contains(move))
            {
                MoveSet.Add(move);
            }
        }
Beispiel #11
0
        private void GenerateSouthSouthWestMove(IBoardState boardState, IChessPieceMover cpm)
        {
            ChessPosition move = cpm.South(cpm.SouthWest(Location));

            if (!boardState.Contains(move))
            {
                MoveSet.Add(move);
            }
        }
Beispiel #12
0
        public void MoveSet_ToStringTest()
        {
            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            ms.Add(_validMovesSorted);
            Assert.AreEqual(_validMovesSortedString, ms.ToString());
        }
Beispiel #13
0
        private void GenerateEastMoves(IBoardState boardState, IChessPieceMover cpm)
        {
            ChessPosition nextMove = cpm.East(Location);

            if (!boardState.Contains(nextMove))
            {
                MoveSet.Add(nextMove);
            }
        }
Beispiel #14
0
        public void MoveSet_NullAddByEnumerableTest()
        {
            IEnumerable <Move> nullMoves = null;

            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            ms.Add(nullMoves);
        }
Beispiel #15
0
        public void MoveSet_NullAddTest()
        {
            Move move = null;

            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            ms.Add(move);
        }
Beispiel #16
0
        public void MoveSet_CantAddAfterLockedTest()
        {
            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            ms.Lock();

            ms.Add(Move.Pass);
        }
Beispiel #17
0
        protected void GenerateDirectionalMoves(IBoardState boardState,
                                                Func <ChessPosition, ChessPosition> directionFunction)
        {
            ChessPosition nextMove = directionFunction(Location);

            while (!boardState.Contains(nextMove))
            {
                MoveSet.Add(nextMove);
                nextMove = directionFunction(nextMove);
            }
        }
Beispiel #18
0
        public void MoveSet_CantAddByEnumerableAfterLockedTest()
        {
            Move[] movesToAdd = new Move[]
            {
                Move.Pass
            };

            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            ms.Lock();

            ms.Add(movesToAdd);
        }
Beispiel #19
0
        public void MoveSet_RemoveSingleByEnumerableTest()
        {
            Move validMove = Move.Pass;

            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            Assert.AreEqual(0, ms.Count);
            Assert.IsTrue(ms.Add(validMove));
            Assert.AreEqual(1, ms.Count);
            Assert.IsTrue(ms.Contains(validMove));

            Assert.IsTrue(ms.Remove(validMove));
            Assert.AreEqual(0, ms.Count);
            Assert.IsFalse(ms.Contains(validMove));
        }
Beispiel #20
0
        public void MoveSet_AddSingleByEnumerableTest()
        {
            Move[] movesToAdd = new Move[]
            {
                Move.Pass
            };

            MoveSet ms = new MoveSet();

            Assert.IsNotNull(ms);

            Assert.AreEqual(0, ms.Count);
            ms.Add(movesToAdd);
            Assert.AreEqual(movesToAdd.Length, ms.Count);

            foreach (Move move in movesToAdd)
            {
                Assert.IsTrue(ms.Contains(move));
            }
        }