示例#1
0
        public double GridDistance(CCell p_goalCell)
        {
            int dx = Math.Abs(X - p_goalCell.X);
            int dy = Math.Abs(Y - p_goalCell.Y);

            return(Math.Max(dx, dy));
        }
示例#2
0
        public double EuclideanDistance(CCell p_goalCell)
        {
            int dx = X - p_goalCell.X;
            int dy = Y - p_goalCell.Y;

            return(Math.Sqrt(dx * dx + dy * dy));
        }
示例#3
0
        public double ManhattanDistance(CCell p_goalCell)
        {
            int dx = Math.Abs(X - p_goalCell.X);
            int dy = Math.Abs(Y - p_goalCell.Y);

            return(dx + dy);
        }
示例#4
0
 protected void BuildGrid()
 {
     m_cells = new CCell[m_width, m_height];
     for (int x = 0; x < m_width; x++)
     {
         for (int y = 0; y < m_height; y++)
         {
             CCell c = new CCell(this, x, y);
             m_cells[x, y] = c;
         }
     }
 }