Пример #1
0
        List <move> elagage()
        {
            move[] around = new move[8];
            around[0].x = 0;
            around[0].y = 1;

            around[1].x = 0;
            around[1].y = -1;
            around[2].x = 1;
            around[2].y = 0;
            around[3].x = -1;
            around[3].y = 0;

            around[4].x = -1;
            around[4].y = -1;

            around[5].x = -1;
            around[5].y = 1;

            around[6].x = 1;
            around[6].y = -1;

            around[7].x = 1;
            around[7].y = 1;

            List <move> ret = new List <move>();
            int         i, j;

            i = j = 0;
            while (i < _height)
            {
                j = 0;
                while (j < _width)
                {
                    if (_board[i, j] != 0)
                    {
                        int k = -1;
                        while (++k <= 7)
                        {
                            if (i + around[k].y >= 0 && j + around[k].x >= 0 &&
                                i + around[k].y < _height && j + around[k].x < _width &&
                                _board[i + around[k].y, j + around[k].x] == 0)
                            {
                                ret.Add(CreateMove(i + around[k].y, j + around[k].x));
                            }
                        }
                    }
                    ++j;
                }
                ++i;
            }
            List <move> r = new List <move>();

            foreach (move m in ret)
            {
                if (_board[m.y, m.x] == 0)
                {
                    r.Add(m);
                }
            }

            return(r);
        }