Esempio n. 1
0
        /// <summary>
        /// Takes two preferably disjoint Neighborhoods and measures if one has
        /// a dominant amount of Rocks over the other.
        /// This score should be very weak in the case where there are few rocks as it may not
        /// be feasible to cover all distinct halves. This can be controlled with the
        /// "balanceOfNeighborhoods" property.
        /// </summary>
        /// <param name="upper">One neighborhood to measure.</param>
        /// <param name="lower">The other neighborhood to measure.</param>
        /// <returns></returns>
        private static double balanceOfNeighborhoods(Neighborhood upper, Neighborhood lower)
        {
            int    nRocksUpper = upper.numberOfRocks();
            int    nRocksLower = upper.numberOfRocks();
            double resultRatio;

            if (nRocksUpper >= nRocksLower)
            {
                //adding 1.0 to cast to double and prevent division by zero
                resultRatio = (nRocksLower + 1.0) / (nRocksUpper + 1.0);
            }
            else
            {
                resultRatio = (nRocksUpper + 1.0) / (nRocksLower + 1.0);
            }
            return(resultRatio);
        }
Esempio n. 2
0
        /// <summary>
        /// Go through every point in the upper neighborhood and compare it to the lower.
        /// Need to implement how to refernce points (Offsetting)
        /// </summary>
        /// <param name="upper"></param>
        /// <param name="lower"></param>
        /// <param name="jigger"></param>
        /// <returns></returns>
        private double symmetric(Neighborhood upper, Neighborhood lower, int jigger, bool flipCoordinates, bool flipOnWidth)
        {
            int totalRocks;
            int upperRocks = upper.numberOfRocks();
            int lowerRocks = lower.numberOfRocks();

            totalRocks = upperRocks < lowerRocks ? upperRocks : lowerRocks;
            List <double> products = new List <double>();
            Atom          tempAtom;
            Point         tempLocation;

            foreach (Atom a in upper.getAtoms())
            {
                if (!a.getResident().isGravel)
                {
                    if (flipCoordinates)
                    {
                        tempLocation = invert(a.getLocation());
                    }
                    else
                    {
                        if (flipOnWidth)
                        {
                            tempLocation = new Point(a.getLocation().X, length - 1 - a.getLocation().Y);
                        }
                        else
                        {
                            tempLocation = new Point(width - 1 - a.getLocation().X, a.getLocation().Y);
                        }
                    }
                    tempAtom = atomAt(tempLocation);
                    products.Add(singleSymmetry(tempAtom, lower, jigger, a.getLocation()));
                }
            }
            return(1 - Math.Pow(average(products), 1 / 4.0));
        }