public void Tick() { HashSet <Cell> toRemove = new HashSet <Cell>(); lock (cells) { foreach (Cell c in Cells) { if (!c.Alive) { toRemove.Add(c); } } foreach (Cell c in toRemove) { cells.Remove(c); } foreach (Cell c in Cells) { CellConditions localConditions = conditions; localConditions.Sunlight = Math.Max(0, conditions.Sunlight * (3 - c.Location.Y / 100f) / 3); c.Tick(localConditions); } foreach (Cell c in newCells) { cells.Add(c); } newCells.Clear(); } }
public override void Tick(CellConditions conditions) { if (!Alive) { return; } Mass += Math.Min(30f, conditions.Sunlight * ((float)Math.PI * Radius * Radius) / 10); base.Tick(conditions); }
public virtual void Tick(CellConditions conditions) { if (!Alive) { return; } // Surface area / Salinity Mass -= 4 * (float)Math.PI * Radius * Radius * 1f / conditions.Salinity; if (Mass > 1000) { Mass = 1000; } else if (Mass <= 100) { Kill(); } if (Mass >= Mode.SplitMass) { Container.SplitCell(this); } }
public Simulation() { cells = new HashSet <Cell>(); conditions = new CellConditions(10, 0, 10); newCells = new HashSet <Cell>(); }