Esempio n. 1
0
    private void WeightHorizontal()
    {
        ConnectFinder cf = new ConnectFinder(_width, _me);

        for (int y = 0; y < _height; y++)
        {
            for (int x = 0; x < _width; x++)
            {
                cf.Add(_fields[x, y]);
            }

            _fields = cf.AddWeight(_fields);
        }
    }
Esempio n. 2
0
    private void WeightDiagonal()
    {
        ConnectFinder cfUp   = new ConnectFinder(Math.Max(_width, _height), _me);
        ConnectFinder cfDown = new ConnectFinder(Math.Max(_width, _height), _me);

        // iterate through the rows
        for (int y = 0; y < _height; y++)
        {
            // shifting through positions
            for (int z = 0; z < _width; z++)
            {
                if (y + z < _height)
                {
                    cfUp.Add(_fields[z, y + z]);     // we are 'z' units right and up from home
                }
                if (y - z >= 0)
                {
                    cfDown.Add(_fields[z, y - z]);     // we are 'z' units right and down from home
                }
            }

            _fields = cfUp.AddWeight(_fields);
            _fields = cfDown.AddWeight(_fields);
        }

        // iterate through the columns (the first [0,0], we had already)
        for (int x = 1; x < _width; x++)
        {
            // shifting through positions
            for (int z = 0; z < _height; z++)
            {
                if (x + z < _width)
                {
                    cfUp.Add(_fields[x + z, z]);     // we are 'z' units right and up from home
                }
                if (x - z >= 0)
                {
                    cfDown.Add(_fields[x - z, z]);     // we are 'z' units right and down from home
                }
            }

            _fields = cfUp.AddWeight(_fields);
            _fields = cfDown.AddWeight(_fields);
        }
    }