/// <summary>
    /// Main test loop. (Coroutine)
    /// </summary>
    /// <returns>
    /// The <see cref="IEnumerator"/>.
    /// </returns>
    public IEnumerator MainNHTestLoop()
    {
        CurrentMapIndex = 0;
        foreach (var txa in allMaps)
        {
            /* Update the map and recompute the map. */
            BDPMap.Instance.MapFile = txa;
            BDPMap.Instance.ComputeMap();

            var bd = new BenchmarkData(this) { TMin = Windows };

            while (!BDPMap.Instance.MapIsLoaded)
            {
                yield return new WaitForSeconds(0.5f);
            }

            agent.CleanBelief();

        #if PATHTESTER_DEBUG_LOG
            Debug.Log(string.Format("[MAINLOOP] Starting Iteration on map {0}", txa.name));
        #endif
            CurrentMapIteration = 0;
            agent.CurrentPosition = this.RandomFreePosition();
            RandomStrategy.Init();
            while (CurrentMapIteration < NumberOfRuns)
            {
        #if PATHTESTER_DEBUG_LOG
                Debug.Log("--------------------------------------------------");
                Debug.Log(string.Format("[MAINLOOP] Computing Path {0} of {1}", CurrentMapIteration + 1, NumberOfRuns));
        #endif

                // Debug.Log("Iteration " + counter);
                if (CurrentMapIteration % ScrambleRate == 0)
                {
        #if PATHTESTER_DEBUG_LOG
                    Debug.Log("[MAINLOOP] Randomizing Portals");
        #endif
                    StepCounter.Increase();
                    RandomStrategy.RandomizeWorldPortals();
                }

                var targetPos = this.DraftRandomTargetPos();

                /* BENCHMARK */
                InitializeSRD(agent.CurrentPosition, targetPos);

                /* ********* */
                UpdateAllPortalInArea(agent.CurrentPosition);

                var startTime = 0;
                var valid = true;

                while (agent.CurrentPosition != targetPos)
                {
                    startTime++;
                    this.executionError = false;
                    if (startTime > 30)
                    {
                        srd.PathFound = false;
                        Debug.Log("[MAINLOOP] Time out! Go to next pick.");
                        valid = false;
                        break;
                    }

        #if PATHTESTER_DEBUG_LOG
                    Debug.Log(string.Format("[MAINLOOP] Execution Step from {0} to {1}", agent.CurrentPosition, targetPos));
        #endif

                    if (ThePathfinder.AgentBelief.Hierarchical)
                    {
                        ThePathfinder.AgentBelief.CurrentTarget = targetPos;
                    }

                    if (!Caching) {
                        agent.ReviewBeliefOlderThan(Windows);
                    }

                    var path = ThePathfinder.PathFind(agent.CurrentPosition, targetPos);

                    /* BENCHMARK */
                    UpdateSRD();

                    if (path == null)
                    {

                        Debug.Log("[MAINLOOP] No path found! Try to perform belief revision.");
                        if (ThePathfinder.AgentBelief.Hierarchical)
                        {
                            Debug.Log("[MAINLOOP] Starting Belief Revision Loop");
                            path = BeliefRevisionLoop(agent.CurrentPosition, targetPos);
                        }

                        if (path == null)
                        {
                            srd.PathFound = false;
        #if PATHTESTER_DEBUG_LOG
                            Debug.Log("[MAINLOOP] No path found! Go to next pick.");
        #endif
                            break;
                        }
                    }

                    srd.PathFound = true;

                    /* ********* */
                    var pathList = Path2MapSquareList(path);

                    //Debug.Log("[MAINLOOP] Path Found. Start Execution.");
                    if (ThePathfinder.AgentBelief.Hierarchical)
                    {
                        yield return StartCoroutine(ExecuteHierarchicalPath(pathList));
                    }
                    else
                    {
                        yield return StartCoroutine(ExecutePath(pathList));
                    }
                }

                if (true)
                {
                    CurrentMapIteration++;
                    bd.RunsData.Add(srd);
                }

                yield return new WaitForSeconds(0.1f);
            }

            bd.PrintToFile();
            CurrentMapIndex++;
        }

        #if PATHTESTER_DEBUG_LOG
        myLogger.Log("[MAINLOOP] TEST COMPLETED");
        #endif
    }