public Animal(Map map, int x, int y) { Random rand = new Random(); Position.X = x; Position.Y = y; Sex = rand.Next() > (Int32.MaxValue / 2); Home = map; Verbose.Birth(this); }
protected Animal(Map map) { Random rand = new Random(); Position.X = rand.Next(map.Width); Position.Y = rand.Next(map.Height); Sex = rand.Next() > (Int32.MaxValue / 2); Home = map; Verbose.Birth(this); }
public virtual void Move() { Random rand = new Random(); Position oldpos = Position; Position.X += rand.Next(Position.X == 0 ? 0 : -1, Position.X == Home.Width - 1 ? 1 : 2); Position.Y += rand.Next(Position.Y == 0 ? 0 : -1, Position.Y == Home.Height - 1 ? 1 : 2); Verbose.Movement(this, oldpos); }
static Map InitializeMap(int height, int width, int population, double coefficient = 0.5) { Map map = new Map(width, height); map.Populate(population, coefficient); TurnsManager.GenerateTilemap(map); Verbose.TurnCounter(0); Verbose.AnimalsAlive(map); Verbose.DrawMap(map); Verbose.PopulationCount(map); Console.WriteLine(""); return(map); }
public static void Run(Map map, int turns, bool debugMode = false) { for (int i = 0; i < turns; i++) { Console.WriteLine($"turn: {i+1}"); foreach (var phase in Phases.PhasesList) { phase.Invoke(map); Verbose.TurnCounter(i + 1); Verbose.DrawMap(map); Verbose.PopulationCount(map); } if (debugMode) { Verbose.AnimalsAlive(map); Console.WriteLine("_________________"); } } }
public void Die() { Home.Population.Remove(this); Verbose.Death(this); }