using System.Collections.Generic; using System.Linq; namespace Life.Automaton { public class MooreField : BasicField { public MooreField(int width, int height) : base(width, height) { } public override IEnumerable Neighbours(int x, int y) { var potential = new [] { (x - 1, y + 1), (x, y + 1), (x + 1, y + 1), (x - 1, y) /*, (x, y) */, (x + 1, y), (x - 1, y - 1), (x, y - 1), (x + 1, y - 1), }; return potential .Where(c => c.Item1 >= 0 && c.Item1 < Size.Width && c.Item2 >= 0 && c.Item2 < Size.Height) .Select(c => this[c.Item1, c.Item2]); } public override string ToString() { return $"MooreField {Size.Width} x {Size.Height}"; } } }