Ejemplo n.º 1
0
        public void Test_CanMove()
        {
            // Init Game
            CustomGame customGame = InitGame();

            // launch move function
            Movements move   = new Movements(null, null, customGame.Board);
            var       result = move.CanMove(new Coordinates(4, 4));

            // Tests
            Assert.IsFalse(result[DirectionType.Right]);
            Assert.IsFalse(result[DirectionType.Left]);
            Assert.IsFalse(result[DirectionType.DownRight]);
            Assert.IsFalse(result[DirectionType.DownLeft]);
            Assert.IsFalse(result[DirectionType.UpRight]);
            Assert.IsFalse(result[DirectionType.UpLeft]);


            result = move.CanMove(new Coordinates(3, 5));

            // Tests
            Assert.IsFalse(result[DirectionType.Right]);
            Assert.IsFalse(result[DirectionType.Left]);
            Assert.IsFalse(result[DirectionType.DownRight]);
            Assert.IsFalse(result[DirectionType.DownLeft]);
            Assert.IsFalse(result[DirectionType.UpRight]);
            Assert.IsFalse(result[DirectionType.UpLeft]);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the penguin to move
        /// </summary>
        /// <param name="possibilitiesOrigin"></param>
        /// <returns>Position of the penguin or [-1;-1] if the AI can't move his penguins</returns>
        public Coordinates FindOrigin(List <Coordinates> possibilitiesOrigin)
        {
            Movements moveOrigin = new Movements(null, null, Board);

            foreach (var possibility in possibilitiesOrigin)
            {
                foreach (var direction in moveOrigin.CanMove(possibility))
                {
                    if (direction.Value == false)
                    {
                        return(possibility);
                    }
                }
            }
            return(new Coordinates(-1, -1));
        }