/// <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); }
/// <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(); } }
/// <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); }