/// <summary> /// Eat /// </summary> /// <param name="da">Doodle agent</param> /// <param name="newLine">Line</param> /// <param name="newColumn">Column</param> /// <returns>The eaten ant</returns> public AntAgent Eat(DoodlebugAgent da, int newLine, int newColumn) { AntAgent ant = (AntAgent)_map[newLine, newColumn].AgentInCell; Move(da, newLine, newColumn); return(ant); }
private static void Main(string[] args) { var worldEnv = new WorldEnvironment(Settings.NoTurns); // derived from ActressMas.EnvironmentMas var world = worldEnv.Memory["World"]; int noCells = Settings.GridSize * Settings.GridSize; int[] randVect = RandomPermutation(noCells); for (int i = 0; i < Settings.NoDoodlebugs; i++) { var a = new DoodlebugAgent(); worldEnv.Add(a, world.CreateName(a)); // unique name world.AddAgentToMap(a, randVect[i]); } for (int i = Settings.NoDoodlebugs; i < Settings.NoDoodlebugs + Settings.NoAnts; i++) { var a = new AntAgent(); worldEnv.Add(a, world.CreateName(a)); world.AddAgentToMap(a, randVect[i]); } worldEnv.Start(); }
public void Eat(DoodlebugAgent da, int newLine, int newColumn) { // removing the ant AntAgent ant = (AntAgent)_map[newLine, newColumn].AgentInCell; _activeAnts.Remove(ant.Name); this.Remove(ant); // from ActressMas.Environment if (Utils.Verbose) { Console.WriteLine("Removing " + ant.Name); } // moving the doodlebug if (Utils.Verbose) { Console.WriteLine("Moving " + da.Name); } _map[newLine, newColumn].State = CellState.Doodlebug; _map[newLine, newColumn].AgentInCell = _map[da.Line, da.Column].AgentInCell; _map[da.Line, da.Column].State = CellState.Empty; _map[da.Line, da.Column].AgentInCell = null; // updating doodlebug position da.Line = newLine; da.Column = newColumn; }
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 (a.GetType().Name == "AntAgent") { _activeAnts.Add(offspring.Name); } else if (a.GetType().Name == "DoodlebugAgent") { _activeDoodlebugs.Add(offspring.Name); } if (Utils.Verbose) { Console.WriteLine("Breeding " + offspring.Name); } offspring.Start(); }
public AntAgent Eat(DoodlebugAgent da, int newLine, int newColumn) { AntAgent ant = (AntAgent)_map[newLine, newColumn].AgentInCell; if (Settings.Verbose) { Console.WriteLine($"Removing {ant.Name}"); } // moving the doodlebug if (Settings.Verbose) { Console.WriteLine($"Moving {da.Name}"); } _map[newLine, newColumn].State = CellState.Doodlebug; _map[newLine, newColumn].AgentInCell = _map[da.Line, da.Column].AgentInCell; _map[da.Line, da.Column].State = CellState.Empty; _map[da.Line, da.Column].AgentInCell = null; // updating doodlebug position da.Line = newLine; da.Column = newColumn; return(ant); }
public InsectAgent 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(); } string name = CreateName(offspring); offspring.Name = name; AddAgentToMap(offspring, newLine, newColumn); if (Settings.Verbose) { Console.WriteLine($"Breeding {offspring.Name}"); } return(offspring); }
public void Die(DoodlebugAgent da) { _activeDoodlebugs.Remove(da.Name); this.Remove(da); // from ActressMas.Environment _map[da.Line, da.Column].State = CellState.Empty; _map[da.Line, da.Column].AgentInCell = null; }
/// <summary> /// Eat /// </summary> /// <param name="da">Doodle agent</param> /// <param name="newLine">Line</param> /// <param name="newColumn">Column</param> public void Eat(DoodlebugAgent da, int newLine, int newColumn) { // Get ant AntAgent ant = (AntAgent)Map[newLine, newColumn].AgentInCell; // Delete game object Map[newLine, newColumn].SetState(null); // Remove agent _environment.Remove(ant); // Move doodlebug to the new location Move(da, newLine, newColumn); }
/// <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); }
/// <summary> /// Init agents in the world /// </summary> /// <param name="environment"></param> public void InitAgents(World world) { int noCells = Settings.GridSize * Settings.GridSize; int[] randVect = RandomPermutation(noCells); // Create agents Doodle bugs for (int i = 0; i < Settings.NoDoodlebugs; i++) { var a = new DoodlebugAgent(); Add(a, world.CreateName(a)); // Unique name world.AddAgentToMap(a, randVect[i]); } // Create agents Ants for (int i = Settings.NoDoodlebugs; i < Settings.NoDoodlebugs + Settings.NoAnts; i++) { var a = new AntAgent(); Add(a, world.CreateName(a)); world.AddAgentToMap(a, randVect[i]); } }
/// <summary> /// Kill doodle agent /// </summary> /// <param name="da">Doodle agent</param> public void Die(DoodlebugAgent da) { da.CurrentCell.SetState(null); da.CurrentCell = null; }
public void Die(DoodlebugAgent da) { _map[da.Line, da.Column].State = CellState.Empty; _map[da.Line, da.Column].AgentInCell = null; }