Пример #1
0
        private Node GetNodeForCA(Node node, NeighbourhoodEnum type)
        {
            switch (type)
            {
            case NeighbourhoodEnum.Moore:
            case NeighbourhoodEnum.VonNeumann:
                return(GetNodeforStandardMethod(node));

            case NeighbourhoodEnum.Moore2:
                return(GetNodeforModificationMethod(node));
            }
            return(null);
        }
Пример #2
0
        public List <Node> GetNeighbourhoods(int x, int y, NeighbourhoodEnum type, bool isFromCurrent = false)
        {
            switch (type)
            {
            case NeighbourhoodEnum.Moore:
                return(GetMooreNeighbourhoods(x, y, isFromCurrent));

            case NeighbourhoodEnum.VonNeumann:
                return(GetVonNeumannNeighbourhoods(x, y, isFromCurrent));

            case NeighbourhoodEnum.Cross:
                return(GetCrossNeighbourhoods(x, y, isFromCurrent));
            }
            return(new List <Node>());
        }
Пример #3
0
        private List <KeyValuePair <Node, int> > GetListOfGrainNeighbourhood(Node node, NeighbourhoodEnum type)
        {
            var neighbourhood = _simulationEngine.MapController.GetNeighbourhoods(node.X, node.Y, type);

            neighbourhood = neighbourhood.Where(k => k.Type == TypeEnum.Grain).ToList();

            if (neighbourhood.Any())
            {
                var orderedNeighbourhood = neighbourhood.GroupBy(s => s).Select(g => new KeyValuePair <Node, int>(g.First(), g.Count())).OrderByDescending(p => p.Value).ToList();
                return(orderedNeighbourhood);
            }
            return(null);
        }