Hi I am creating a game for fun using c#. I have a function that determines the shortest distance between two locations on a grid. I am using a form of dijkstra's algorithm but it still seems to be a little too slow for me. When I ask for a location from one corner to another in a grid of 140 by 140. It takes about 4 seconds.
The list of possible paths gets pretty large and searching for the next shortest path involves an iteration through all available paths. So I wanted to use an ordered list of paths to greatly reduce the number of iterations.
So my question is if there is a generic collection that I could use that automatically inserts a Comparable object into a sorted list and will be able to search for an object using the binary search algorithm? Right now I am just using List<T>. I was unable to find anything via google and do not want to create my own insert/sort methods. Plus I will be able to use this in other areas of the game. Thanks in advance and I you need more information let me know.
The list of possible paths gets pretty large and searching for the next shortest path involves an iteration through all available paths. So I wanted to use an ordered list of paths to greatly reduce the number of iterations.
So my question is if there is a generic collection that I could use that automatically inserts a Comparable object into a sorted list and will be able to search for an object using the binary search algorithm? Right now I am just using List<T>. I was unable to find anything via google and do not want to create my own insert/sort methods. Plus I will be able to use this in other areas of the game. Thanks in advance and I you need more information let me know.
Comment