root/src/BRAINSFramework/PathFinding/PathFinder.cs
| 21 | 23 | ||
|---|---|---|---|
108 | { | 108 | { |
109 | for (int h = 0; h < _map.Rows; h++) | 109 | for (int h = 0; h < _map.Rows; h++) |
110 | { | 110 | { |
111 | _grid[w, h] = _agent.TypeToCost(_map.GetCell(w, h).Type); | 111 | if (_agent == null) |
112 | { | ||
113 | if (_map.GetCell(w, h).Type == 0) | ||
114 | _grid[w, h] = 99; | ||
115 | else | ||
116 | _grid[w, h] = _map.GetCell(w, h).Type; | ||
117 | } | ||
118 | else | ||
119 | _grid[w, h] = _agent.GetCostOfCellType(_map.GetCell(w, h).Type); | ||
112 | } | 120 | } |
113 | } | 121 | } |
114 | } | 122 | } |
... | ... | ||
237 | 245 | ||
238 | float Heuristic = 0; | 246 | float Heuristic = 0; |
239 | //Three different types of Heuristic calculation | 247 | //Three different types of Heuristic calculation |
240 | if(HType==HeuristicType.Euclidean) | 248 | //if(HType==HeuristicType.Euclidean) |
241 | Heuristic = (int)(_heuristicEstimateValue * (Math.Sqrt(Math.Pow((_node.X - _endNode.X), 2) + Math.Pow((_node.Y - _endNode.Y), 2)))); | 249 | // Heuristic = (int)(_heuristicEstimateValue * (Math.Sqrt(Math.Pow((_node.X - _endNode.X), 2) + Math.Pow((_node.Y - _endNode.Y), 2)))); |
242 | else if(HType==HeuristicType.Manhattan) | 250 | //else //if(HType==HeuristicType.Manhattan) |
243 | Heuristic = _heuristicEstimateValue * (Math.Abs(_endNode.X - _node.X) + Math.Abs(_endNode.Y - _node.Y)); | 251 | Heuristic = _heuristicEstimateValue * (Math.Abs(_endNode.X - _node.X) + Math.Abs(_endNode.Y - _node.Y)); |
244 | else if(HType==HeuristicType.Diagonal) | 252 | //else if(HType==HeuristicType.Diagonal) |
245 | Heuristic = _heuristicEstimateValue * Math.Max(Math.Abs(_node.X - _endNode.X), Math.Abs(_node.X- _endNode.Y)); | 253 | // Heuristic = _heuristicEstimateValue * Math.Max(Math.Abs(_node.X - _endNode.X), Math.Abs(_node.X- _endNode.Y)); |
246 | 254 | ||
247 | _node.H = (int)Heuristic; | 255 | _node.H = (int)Heuristic; |
248 | 256 |
Download diff