public string CreateName(InsectAgent a) { if (a.GetType().Name == "AntAgent") { return($"a{_currentId++}"); } else if (a.GetType().Name == "DoodlebugAgent") { return($"d{_currentId++}"); } throw new Exception($"Unknown agent type: {a.GetType().Name}"); }
public string CreateName(InsectAgent a) { if (a.GetType().Name == "AntAgent") { return(string.Format("a{0}", _currentId++)); } else if (a.GetType().Name == "DoodlebugAgent") { return(string.Format("d{0}", _currentId++)); } throw new Exception("Unknown agent type: " + a.GetType().ToString()); }
public void AddAgentToMap(InsectAgent a, int line, int column) { if (a.GetType().Name == "AntAgent") { _map[line, column].State = CellState.Ant; } else if (a.GetType().Name == "DoodlebugAgent") { _map[line, column].State = CellState.Doodlebug; } a.Line = line; a.Column = column; _map[line, column].AgentInCell = a; }
public void Breed(InsectAgent a, int newLine, int newColumn) { InsectAgent offspring = null; if (a.GetType().Name == "AntAgent") { offspring = new AntAgent(); } else if (a.GetType().Name == "DoodlebugAgent") { offspring = new DoodlebugAgent(); } Add(offspring, CreateName(offspring)); // Add is from ActressMas.Environment AddAgentToMap(offspring, newLine, newColumn); if (Settings.Verbose) { Console.WriteLine($"Breeding {offspring.Name}"); } }