Пример #1
0
        private int dcv2(MapTile mt, int c, List <MapTile> list)//part of denscheck
        {
            int count = c;

            list.Add(mt);
            if (count > 250 || mt.countneigb() >= 2)
            {
                return(count);
            }
            if (mt.countneigb() == 1)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (mt.neighbours[i].type == 1)
                    {
                        if (i == 0 && mt.neighbours[2].neighbours[2].type == 1)
                        {
                            return(count);
                        }
                        else if (i == 2 && mt.neighbours[0].neighbours[0].type == 1)
                        {
                            return(count);
                        }
                        else if (i == 1 && mt.neighbours[3].neighbours[3].type == 1)
                        {
                            return(count);
                        }
                        else if (i == 3 && mt.neighbours[1].neighbours[1].type == 1)
                        {
                            return(count);
                        }
                        break;
                    }
                }
            }
            foreach (MapTile til in mt.neighbours)
            {
                if (cellvalid(til) && !list.Exists(m => m == til))
                {
                    count++;
                    count = dcv2(til, count, list);
                }
            }
            return(count);
        }
Пример #2
0
        public int denscheck(MapTile mt)//checks cell quality for creating offsprings by checking how much free space is available from this point
        {
            if (mt.countneigb() == 4)
            {
                return(2);
            }
            int dens = 0;

            foreach (MapTile m in mt.neighbours)
            {
                if (m.type == 0)
                {
                    int t = dcv2(m, 0, new List <MapTile>());
                    if (t > 250)
                    {
                        dens = dens + 4;
                    }
                    else if (t > 100 && t <= 250)
                    {
                        dens = dens + 1;
                    }
                }
            }
            if (dens >= 4)
            {
                return(0);
            }
            else if (dens <= 3 && dens > 1)
            {
                return(1);
            }
            else
            {
                return(2);
            }
        }