Exemple #1
0
        /// <summary>
        /// Checking if Drone reached Queen
        /// </summary>
        /// <returns>Returns bool</returns>
        public bool ReachedQueen()
        {
            var queenPosition = AntColony.GetTheQueen().GetPosition();

            if (Coordinates.DistanceToCoordinate(queenPosition) == 0)
            {
                return(true);
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Drone tries mating with Queen
        /// </summary>

        public void TryMating()
        {
            if (AntColony.GetTheQueen().IsInGoodMood())
            {
                Console.WriteLine("Drone says: HALLELUJAH");
                _isMating = true;
            }
            else if (!AntColony.GetTheQueen().IsInGoodMood() && !_isMating)
            {
                Console.WriteLine("Drone says: :(\n");
                Coordinates = GetPositionAfterKickout();
            }
        }
Exemple #3
0
        /// <summary>
        /// Moves Drone towards Queen
        /// </summary>
        /// <returns>Returns Position</returns>
        public Position MoveTowardsQueen()
        {
            var nextPosition  = Coordinates.NextCoordinatesInDirection(DirectionExtensions.GetRandomDirection());
            var queenPosition = AntColony.GetTheQueen().GetPosition();

            while (nextPosition.DistanceToCoordinate(queenPosition) > Coordinates.DistanceToCoordinate(queenPosition))
            {
                nextPosition = Coordinates.NextCoordinatesInDirection(DirectionExtensions.GetRandomDirection());
            }

            Coordinates = nextPosition;

            return(Coordinates);
        }