Пример #1
0
    public double InitializeViability()
    {
        /*
         * _square = Helper.GetSquare(_organismInfo);
         * _perimeter = Helper.GetPerimeter(SideList);
         * _disparity = Helper.GetSideDisparity(Settings.SideSize, SideList);
         * _viability = _perimeter - _square - _disparity + _organismInfo.Points().Count * 30;
         * //_viability = square - perimeter - _disparity + _organismInfo.Points().Count;
         * //if (_square < 10000)
         * // _viability = Double.NegativeInfinity;
         *
         * if (Helper.CheckFigureIntersection(_organismInfo.Points()))
         *  _viability = Double.NegativeInfinity;
         *
         */
        if (Helper.CheckFigureIntersection(_organismInfo.Points()))
        {
            _viability = Double.NegativeInfinity;
            return(_viability);
        }

        _square = Helper.GetSquare(_organismInfo);

        if (_square <= 0)
        {
            _viability = Double.NegativeInfinity;
            return(_viability);
        }

        _disparity = Helper.GetSideDisparity(Settings.SideSize, SideList);

        _perimeter = Helper.GetPerimeter(SideList);
        _viability = _disparity * (-1) + _organismInfo.Points().Count;
        // _disparity = Helper.GetSideDisparity(Settings.SideSize, SideList);
        //_viability = (_organismInfo.Points().Count * 10) - _disparity;



        return(_viability);
    }
Пример #2
0
    public static double GetSquare(OrganismInfo organismInfo)
    {
        double square = 0;
        float  value1 = 0;
        float  value2 = 0;
        int    i      = 0;

        for (i = 0; i < organismInfo.Points().Count - 1; i++)
        {
            value1 += organismInfo.Points()[i].X * organismInfo.Points()[i + 1].Y;
            value2 += organismInfo.Points()[i].Y * organismInfo.Points()[i + 1].X;
        }
        value1 += organismInfo.Points()[i].X * organismInfo.Points()[0].Y;
        value2 += organismInfo.Points()[i].Y * organismInfo.Points()[0].X;
        square  = (value1 - value2) / 2;
        square  = Math.Abs(square);
        return(square);
    }
Пример #3
0
 public Organism(OrganismInfo organismInfo)
 {
     _organismInfo = new OrganismInfo(organismInfo.Points());
     InitializeViability();
 }