Esempio n. 1
0
        public bool equals(Object o)
        {
            if (null == o || !(o is XYLocation))
            {
                return(base.Equals(o));
            }
            XYLocation anotherLoc = (XYLocation)o;

            return((anotherLoc.getXCoOrdinate() == xCoOrdinate) && (anotherLoc
                                                                    .getYCoOrdinate() == yCoOrdinate));
        }
        public int evaluateManhattanDistanceOf(int i, XYLocation loc)
        {
            int retVal = -1;
            int xpos = loc.getXCoOrdinate();
            int ypos = loc.getYCoOrdinate();
            switch (i)
            {

            case 1:
            retVal = Math.Abs(xpos - 0) + Math.Abs(ypos - 1);
            break;
            case 2:
            retVal = Math.Abs(xpos - 0) + Math.Abs(ypos - 2);
            break;
            case 3:
            retVal = Math.Abs(xpos - 1) + Math.Abs(ypos - 0);
            break;
            case 4:
            retVal = Math.Abs(xpos - 1) + Math.Abs(ypos - 1);
            break;
            case 5:
            retVal = Math.Abs(xpos - 1) + Math.Abs(ypos - 2);
            break;
            case 6:
            retVal = Math.Abs(xpos - 2) + Math.Abs(ypos - 0);
            break;
            case 7:
            retVal = Math.Abs(xpos - 2) + Math.Abs(ypos - 1);
            break;
            case 8:
            retVal = Math.Abs(xpos - 2) + Math.Abs(ypos - 2);
            break;

            }
            return retVal;
        }
Esempio n. 3
0
        public List<XYLocation> getPositions()
        {
            List<XYLocation> retVal = new List<XYLocation>();
            for (int i = 0; i < 9; i++)
            {
            int absPos = getPositionOf(i);
            XYLocation loc = new XYLocation(getXCoord(absPos),
                getYCoord(absPos));
            retVal.Add(loc);

            }
            return retVal;
        }
Esempio n. 4
0
 public int getValueAt(XYLocation loc)
 {
     return getValueAt(loc.getXCoOrdinate(), loc.getYCoOrdinate());
 }