示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
 public int NeighboursCount(CellularAutomataCell cell)
 {
     return(Neighbours(cell).Count());
 }
示例#4
0
 //conforms
 public bool Matches(CellularAutomataCell cell)
 {
     return(_definition.Invoke(cell));
 }