コード例 #1
0
ファイル: RRAStar.cs プロジェクト: seky16/MultiRobotSimulator
        private bool Resume(AbstractTile n)
        {
            while (_open.Count > 0)
            {
                var p = _open.Dequeue();
                _closed.Add(p);

                if (p == n)
                {
                    return(true);
                }

                foreach (var q in _graph.AdjacentVertices(p).Reverse())
                {
                    var gScore = _gScore.GetValueOrDefault(p, double.PositiveInfinity) + Metrics.Octile(p, q);
                    var fScore = gScore + Metrics.Octile(q, _start);

                    if (!_open.Contains(q) && !_closed.Contains(q))
                    {
                        _open.Enqueue(q, double.PositiveInfinity);
                    }

                    if (_open.Contains(q) && fScore < _open.GetPriority(q))
                    {
                        _gScore[q] = gScore;
                        _open.UpdatePriority(q, fScore);
                    }
                }
            }

            return(false);
        }