Improving A* for memory – IDA*
IDA* is a variant of an algorithm called Iterative Deepening Depth-First Search. Its memory usage is lower than A* because it doesn't make use of data structures to store the looked-up and explored nodes.
Getting ready
For this recipe, it is important to have some understanding of how recursion works.
How to do it...
This is a long recipe that can be regarded as a big two-step process: creating the main function and an internal recursive one. Please take into consideration the comments in the code for better understanding of the implementation and code flow:
- Let's start by defining the main function,
GetPathIDAstar
:
public List<Vertex> GetPathIDAstar(GameObject srcObj, GameObject dstObj, Heuristic h = null) { if (srcObj == null || dstObj == null) return new List<Vertex>(); if (ReferenceEquals(h, null)) h = EuclidDist; // next steps; }
- Declare and compute the variables to use alongside the algorithm:
List<Vertex>...