private static void threadbench(int m)
        {
            string        filename = $"C:\\Users\\Public\\Gridworld_Heuristics\\testresults_world{m}_{DateTime.Now.ToFileTime()}";
            MainViewModel benchvm  = new MainViewModel();
            float         w1       = 1;
            float         w2       = 1;

            GridHelper.readInputs(m, benchvm.world, benchvm.startPairs, benchvm.endPairs, benchvm.hardPairs);
            Naiive     searchLocal    = new Naiive(benchvm.world);
            Sequential seqsearchLocal = new Sequential(benchvm.world);
            Integrated intSearchLocal = new Integrated(benchvm.world);

            for (int j = 0; j < 5; j++)     //Startend pairs
            {
                for (int k = 0; k < 5; k++) //Algos
                {
                    if (k < 2)
                    {
                        for (int f = 0; f < 5; f++) // Heuristics
                        {
                            searchLocal.initAttr(f, k, w1, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                 benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                            searchLocal.hSearch();
                            snapshot(searchLocal, filename, m, j, k, f, w1, w2);
                            if (k == 1)
                            {//Weighted a*
                                w1 = 1.25f;
                                searchLocal.initAttr(f, k, w1, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                     benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                                searchLocal.hSearch();
                                snapshot(searchLocal, filename, m, j, k, f, w1, w2);
                                w1 = 2f;
                                searchLocal.initAttr(f, k, w1, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                     benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                                searchLocal.hSearch();
                                snapshot(searchLocal, filename, m, j, k, f, w1, w2);
                            }
                        }
                    }
                    if (k == 2)
                    {
                        searchLocal.initAttr(-1, k, w1, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                             benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal.hSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                    }
                    if (k == 3)
                    {
                        w1 = 1.25f;
                        w2 = 1.25f;
                        seqsearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = seqsearchLocal.seqSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);

                        w2 = 2f;
                        seqsearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = seqsearchLocal.seqSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);

                        w1 = 2f;
                        seqsearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = seqsearchLocal.seqSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);

                        w2 = 1.25f;
                        seqsearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = seqsearchLocal.seqSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                    }
                    else
                    {
                        w1 = 1.25f;
                        w2 = 1.25f;
                        intSearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = intSearchLocal.intSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                        w2 = 2f;
                        intSearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = intSearchLocal.intSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                        w1 = 2f;
                        intSearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = intSearchLocal.intSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                        w2 = 1.25f;
                        intSearchLocal.initAttr(w1, w2, benchvm.startPairs[j, 0], benchvm.startPairs[j, 1],
                                                benchvm.endPairs[j, 0], benchvm.endPairs[j, 1]);
                        searchLocal = intSearchLocal.intSearch();
                        snapshot(searchLocal, filename, m, j, k, -1, w1, w2);
                    }
                }
            }
        }
        private void recalculateAlgorithm()
        {
            SolidColorBrush whiteBrush = new SolidColorBrush();

            whiteBrush.Color = Colors.White;
            SolidColorBrush blackBrush = new SolidColorBrush();

            blackBrush.Color = Colors.Black;
            SolidColorBrush chartreuseBrush = new SolidColorBrush();

            chartreuseBrush.Color = Colors.Chartreuse;
            SolidColorBrush beigeBrush = new SolidColorBrush();

            beigeBrush.Color = Colors.Beige;
            SolidColorBrush grayBrush = new SolidColorBrush();

            grayBrush.Color = Colors.Gray;
            SolidColorBrush pathBrush = new SolidColorBrush();

            pathBrush.Color = Colors.BlueViolet;
            SolidColorBrush startBrush = new SolidColorBrush();

            startBrush.Color = Colors.Green;
            SolidColorBrush endBrush = new SolidColorBrush();

            endBrush.Color = Colors.Red;

            SolidColorBrush transparent = new SolidColorBrush();

            transparent.Color = Colors.Transparent;


            int spi = StartEndPairs.SelectedIndex;

            if (spi < 0)
            {
                spi = 0;
            }
            int startx = mvm.startPairs[spi, 0];
            int starty = mvm.startPairs[spi, 1];
            int endx   = mvm.endPairs[spi, 0];
            int endy   = mvm.endPairs[spi, 1];

            //Rerun the algorithm, update runtime
            int pairIdx = StartEndPairs.SelectedIndex;

            if (pairIdx < 0)
            {
                pairIdx = 0;
            }
            float wght;

            if (!float.TryParse(Weight.Text, out wght))
            {
                wght = 1;
            }
            float wght2;

            if (!float.TryParse(Weight2.Text, out wght2))
            {
                wght2 = 1;
            }
            if (Algo.SelectedIndex < 3)
            {
                search.initAttr(Heuristic.SelectedIndex, Algo.SelectedIndex, wght, mvm.startPairs[pairIdx, 0], mvm.startPairs[pairIdx, 1],
                                mvm.endPairs[pairIdx, 0], mvm.endPairs[pairIdx, 1]);
                search.hSearch();
            }
            else if (Algo.SelectedIndex == 3)
            {
                seqsearch.initAttr(wght, wght2, mvm.startPairs[pairIdx, 0], mvm.startPairs[pairIdx, 1],
                                   mvm.endPairs[pairIdx, 0], mvm.endPairs[pairIdx, 1]);
                search = seqsearch.seqSearch();
            }
            else
            {
                intsearch.initAttr(wght, wght2, mvm.startPairs[pairIdx, 0], mvm.startPairs[pairIdx, 1],
                                   mvm.endPairs[pairIdx, 0], mvm.endPairs[pairIdx, 1]);
                search = intsearch.intSearch();
            }

            mvm.Expanded = search.expanded;
            myPath.Children.Clear();
            //Interpret search data.
            Button    chunk;
            worldNode a = search.end;

            //int path = 1;
            while (a.parent != null)
            {
                //path++;
                chunk = new Button();
                if (a.x == endx && a.y == endy)
                {
                    chunk.BorderBrush = endBrush;
                }
                else
                {
                    chunk.BorderBrush = pathBrush;
                }
                chunk.Background      = transparent;
                chunk.BorderThickness = new Thickness(1);
                chunk.Content         = new int[] { a.x, a.y };
                chunk.Click          += chunkClick;
                Grid.SetColumn(chunk, a.y);
                Grid.SetRow(chunk, a.x);

                a = a.parent;
                myPath.Children.Add(chunk);
            }
            //mvm.PathLen = path;
            mvm.PathLen           = search.end.g;
            chunk                 = new Button();
            chunk.Background      = transparent;
            chunk.BorderBrush     = startBrush;
            chunk.BorderThickness = new Thickness(1);
            chunk.Content         = new int[] { a.x, a.y };
            chunk.Click          += chunkClick;
            Grid.SetColumn(chunk, a.y);
            Grid.SetRow(chunk, a.x);
            myPath.Children.Add(chunk);
            //Update Start/end pair appearance
        }