private CellularAutomataCell UpdatedCell(CellularAutomataCell cell) { var matchedRule = _rules.FirstOrDefault(rule => rule.Matches(cell)); var cellState = matchedRule != null ? matchedRule.State : cell.State; return(new CellularAutomataCell(cell.Position, cellState)); }
public IEnumerable <KeyValuePair <Vector2D, CellularAutomataCell> > Neighbours(CellularAutomataCell target) { var neighbourPositions = _neighbourPositions.Select(pos => pos.Add(target.Position)); return(_state.Where(pair => neighbourPositions.Contains(pair.Key) && pair.Value.IsAlive)); }
public int NeighboursCount(CellularAutomataCell cell) { return(Neighbours(cell).Count()); }
//conforms public bool Matches(CellularAutomataCell cell) { return(_definition.Invoke(cell)); }