コード例 #1
0
        public LabirintGraph(IEnumerable <LabirintVertex> vertices)
        {
            Vertices = vertices.ToList();
            try
            {
                Start = Vertices.First(v =>
                                       v.NodeType == CellTypes.Start);        //находим первый элемент с типом старт, отмечаем его для доступа
                Finish = Vertices.First(v => v.NodeType == CellTypes.Finish); //аналогично финиш
            }

            catch (Exception e)
            {
                var msg = e.Message;
            }
        }
コード例 #2
0
 public int ManhattanToFinish(LabirintVertex v)
 {
     return(Math.Abs(GetX(v) - FinishX) + Math.Abs(GetY(v) - FinishY));
 }
コード例 #3
0
 public int GetY(LabirintVertex v)
 {
     return(Vertices.IndexOf(v) / Size);
 }