/// <summary> /// Create agent name /// </summary> /// <param name="a">The agent</param> /// <returns>Name</returns> public string CreateName(InsectAgent a) { if (a.GetInsectType() == InsectType.Ant) { return($"a{_currentId++}"); } else if (a.GetInsectType() == InsectType.Doodlebug) { return($"d{_currentId++}"); } throw new Exception($"Unknown agent type: {a.GetType()}"); }
/// <summary> /// Agent breed /// </summary> /// <param name="a">Agent</param> /// <param name="newLine">Line</param> /// <param name="newColumn">Column</param> /// <returns>New agent</returns> public InsectAgent Breed(InsectAgent a, int newLine, int newColumn) { InsectAgent offspring = null; if (a.GetInsectType() == InsectType.Ant) { offspring = new AntAgent(); } else if (a.GetInsectType() == InsectType.Doodlebug) { offspring = new DoodlebugAgent(); } string name = CreateName(offspring); offspring.Name = name; AddAgentToMap(offspring, newLine, newColumn); return(offspring); }