public static TestResult RunTest(PathfinderAlgorithm algorithm, Coord2 startPos, Coord2 targetPos)
        {
            // Set the pathfinding algorithm
            Level.SetPathfindingAlgorithm(algorithm);

            // Get Start Time
            DateTime startTime = DateTime.Now;

            // Find Path
            Level.Map.pathfinder.Build(startPos, targetPos);

            // Calculate time taken
            DateTime finishTime = DateTime.Now;
            TimeSpan timeTaken  = finishTime - startTime;

            // Return results
            return(new TestResult(timeTaken.Ticks, Level.Map.pathfinder.GetPath().Count));
        }
        /// <summary>
        /// Runs a test and returns the result.
        /// </summary>
        /// <param name="algorithm">The pathfinding algorithm to use.</param>
        /// <param name="startPos">The starting position to use for the test.</param>
        /// <param name="pathLength">The length in manhattan distance that the target position should be from the starting position.</param>
        /// <param name="rand">A seeded random number generator to used to calculate a target position.</param>
        /// <returns></returns>
        public static TestResult RunTest(PathfinderAlgorithm algorithm, Coord2 startPos, List <Coord2> possibleTargets)
        {
            // Initialize result collection
            TestResultCollection results = new TestResultCollection();

            // Set the pathfinding algorithm
            Level.SetPathfindingAlgorithm(algorithm);

            // Create time take variable
            TimeSpan timeTaken;

            // The target position
            Coord2 targetPos;

            do
            {
                // Find random target
                do
                {
                    targetPos = possibleTargets[rand.Next(0, possibleTargets.Count)];
                } while (!level.Map.ValidPosition(targetPos));

                // Get Start Time
                DateTime startTime = DateTime.Now;

                // Find Path
                Level.Map.pathfinder.Build(startPos, targetPos, true);

                // Calculate time taken
                DateTime finishTime = DateTime.Now;
                timeTaken = finishTime - startTime;
            } while (Level.Map.pathfinder.GetPath().Count() == 0); // If no path was found, try again

            // Return result
            return(new TestResult(timeTaken.Ticks, Level.Map.pathfinder.GetPath().Count(), Level.Map.pathfinder.NodesSearched()));
        }
 public static void SetPathfindingAlgorithm(PathfinderAlgorithm algorithm)
 {
     level.SetPathfindingAlgorithm(algorithm);
 }