Exemple #1
0
 public bool IsLegal(Climber climber)
 {
     if (climber.Row >= 0 && climber.Row < Row &&
         climber.Column >= 0 && climber.Column < Column)
     {
         if (mapInfo[climber.Row, climber.Column] != 1)
         {
             return true;
         }
     }
     return false;
 }
Exemple #2
0
        public static Climber GetMinClimber(this List<Climber> list, Climber end)
        {
            if (list.Count > 0)
            {
                var enu = (from climber in list
                          let dis = Map.Distance(climber, end)
                          orderby dis
                          select climber).ToList();

                return enu[0];
            }
            return null;
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var map = new Map();
            map.Show();

            var open = new List<Climber>();
            var close = new List<Climber>();
            var start = new Climber(0, 0);
            var end = new Climber(0, 6);

            if (!map.IsLegal(start) || !map.IsLegal(end))
            {
                Console.WriteLine("Start Or End is Error!");
                return;
            }

            open.Add(start);

            while (open.Count != 0)
            {
                var n = open.GetMinClimber(end);
                if (n == end)
                {
                    break;
                }
                var children = n.GetChildren(map);
                foreach (var climber in children)
                {

                }
                open.Remove(n);
                close.Add(n);
            }

            foreach (var climber in close)
            {
                map.Press(climber);
            }

            Console.WriteLine("After");

            map.Show();
        }
Exemple #4
0
 public void Press(Climber climber)
 {
     mapInfo[climber.Row, climber.Column] = 2;
 }
Exemple #5
0
 public static double Distance(Climber a, Climber b)
 {
     return Math.Sqrt(Math.Pow((b.Row - a.Row), 2) + Math.Pow((b.Column - a.Column), 2));
 }