public List<Climber> GetChildren(Map map) { var list = new List<Climber>(); var eum = from climber in DefaultChildren where map.IsLegal(climber) select climber; list.AddRange(eum); return list; }
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(); }