Exemple #1
0
        public void TestGraphAlgorithms()
        {
            var bfs = new BFS<char>(_graph);
            var path1 = bfs.GetPath('A', 'E');
            CollectionAssert.AreEqual(path1, new char[] { 'A', 'D', 'E' });

            var dfs = new DFS<char>(_graph);
            var path2 = dfs.GetPath('A', 'E');
            CollectionAssert.AreEqual(path2, new char[] { 'A', 'D', 'E' });
        }
Exemple #2
0
        private void btnFindPath_Click(object sender, EventArgs e)
        {
            BFS bfs = new BFS(this.Adjacent);

            int start = this.cboFrom.SelectedIndex;
            int end = this.cboTo.SelectedIndex;

            // reset picGraphics va txtResult
            this.picGraphics.Image = this.g.Reset(this.Adjacent, this.lstPointVertices);
            this.txtResult.Clear();

            if (start == end)
            {
                MessageBox.Show("Vertices are duplicate. Please choose again!", "Error vertices Selected");
                return;
            }
            List<int> res = bfs.findPathbyBfs(this.Vertices, start, end);

            if (res == null)
            {
                string text = "Can't find any path from {0} to {1}.";
                MessageBox.Show(string.Format(text, start + 1, end + 1),"Find Path");
                return;
            }
            else
            {

                int index;
                this.txtResult.Text = "";

                // reset bit map

                // xuat ket qua ra text box
                for (index = 0; index < res.Count - 1; ++index)
                    this.txtResult.Text += (1 + res[index]).ToString() + " ---> ";
                this.txtResult.Text += (1 + res[index]).ToString();

                // ve duong di len bitmap
                this.picGraphics.Image = this.g.DrawPath(res, this.lstPointVertices);
            }
        }
        void CheckVisibility(IntVector3 location, TileData oldData, TileData newData)
        {
            var env = m_environment;

            var initLocs = new IntVector3[] { location };
            var target = new MyTarget(env, this);

            var bfs = new BFS(initLocs, target);

            var revealed = bfs.Find().ToList();

            //Debug.Print("Revealed {0} tiles: {1}", revealed.Count, string.Join(", ", revealed.Select(p => p.ToString())));

            if (revealed.Count == 0)
                return;

            foreach (var p in revealed)
                SetVisible(p);

            // Send new tiles

            var msg = new Messages.MapDataTerrainsListMessage()
            {
                Environment = env.ObjectID,
                TileDataList = revealed.Select(l => new KeyValuePair<IntVector3, TileData>(l, env.GetTileData(l))).ToArray(),
            };

            m_player.Send(msg);

            // Send new objects

            foreach (var ob in revealed.SelectMany(env.GetContents))
            {
                var vis = m_player.GetObjectVisibility(ob);
                Debug.Assert(vis != ObjectVisibility.None);
                ob.SendTo(m_player, vis);
            }
        }
Exemple #4
0
    private void Start()
    {
        List <Nodo> path = new List <Nodo>();

        //Aca va a cambiar el método.
        switch (method)
        {
        case FindingMethod.BFS:
            path = BFS.Run(start, satisfies, Expand);
            break;

        case FindingMethod.DFS:
            path = DFS.Run(start, satisfies, Expand);
            break;

        case FindingMethod.Dijkstra:
            path = Dijkstra.Run(start, satisfies, ExpandWeighted);
            break;

        case FindingMethod.AStar:
            path = AStar.Run(start, satisfies, ExpandWeighted, heuristic);
            break;

        case FindingMethod.ThetaStar:
            path = ThetaStar.Run(start, satisfies, ExpandWeighted, heuristic, insigth, cost);
            break;

        default:
            break;
        }

        // foreach (var nodo in path )
        // {
        //     Debug.Log(nodo.name);
        // }

        walker.waypoints = path;
    }
Exemple #5
0
    //Resets the grid to use the same map with a different search algorithm.
    public void TriggerReset()
    {
        _path = new List <Node>();

        depth   = new DFS();
        breadth = new BFS();
        astar   = new AStar();

        Debug.Log("Reseting Grid:");
        for (int x = 0; x < sx; x++)
        {
            for (int z = 0; z < sz; z++)
            {
                Node n = _tiles[x, z].GetComponent("Node") as Node;
                n.Visited = false;
                n.parent  = null;
                n.G       = 0;
                n.H       = 0;
                n.F       = 0;
                n.Path    = false;
            }
        }
    }
    void Initialize()
    {
        Initalized = true;
        ResetNeighbourList();
        switch (algo)           //when i add future algorithms.
        {
        case Algo.BFS:
            BFSObject = new BFS(Map.RetMap(), Map.RetMapSize());
            break;

        case Algo.A_Star:
            ASObject = new A_Star(Map.RetMap(), Map.RetMapSize());
            break;

        case Algo.DFS:
            DFSObject = new DFS(Map.RetMap(), Map.RetMapSize());
            break;

        case Algo.Dijikstra:
            djkObject = new Dijikstra(Map.RetMap(), Map.RetMapSize());
            break;
        }
    }
    private void move()
    {
        if ((target.transform.position - transform.position).sqrMagnitude < FIELD_OF_VIEW)
        {
            if (bfs == null)
            {
                bfs = new BFS(GameObject.Find("GameCore").GetComponent <GameManagerSample>().GetColumns(),
                              GameObject.Find("GameCore").GetComponent <GameManagerSample>().GetRows());
            }

            Path = bfs.CalculateBFS(GameObject.Find("BoardCreator").GetComponent <Grid>(), target.transform.position,
                                    transform.position);
            if ((transform.position - new Vector3((int)Path[0].Position.x, (int)Path[0].Position.y)).sqrMagnitude <=
                DISTANCE_MIN_NODE)
            {
                Path.RemoveAt(0);
            }

            move_monster = (new Vector3((int)Path[0].Position.x, (int)Path[0].Position.y) - transform.position)
                           .normalized;
            //this.gameObject.GetComponent<Rigidbody2D>().velocity = (speed) * dir;
        }
    }
Exemple #8
0
    public void MakeMockTroop(Factory ally, int count)
    {
        Troop mockTroop = new Troop
        {
            start   = ally,
            count   = count,
            team    = Team.Ally,
            isAlly  = true,
            isEnemy = false,
        };

        BFS.UseBFS(mockTroop, mission.factory);

        int distance = ally.links[mockTroop.end];

        if (Bomb.bombs.Values.Any(b => b.isAlly && b.end == mission.factory && b.turns > distance))
        {
            return;
        }

        if (mockTroop.end.team != Team.Ally && mockTroop.end != mission.factory)
        {
            //troop goes through enemy land
            if (mockTroop.end.count != 0)
            {
                Mission newMission = new Mission(MissionType.Capture, mockTroop.end);

                if (!mission.prereqs.Contains(newMission))
                {
                    mission.prereqs.Add(newMission);
                }
                //return;
            }
        }

        mission.acceptedMission.Add(mockTroop); //ally factory accepts the mission
    }
Exemple #9
0
        public void Test()
        {
            for (int i = 0; i < _testFiles.Length; i++)
            {
                string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "Boot File System (RDB)",
                                               _testFiles[i]);

                IFilter filter = new ZZZNoFilter();
                filter.Open(location);
                IMediaImage image = new AaruFormat();
                Assert.AreEqual(true, image.Open(filter), _testFiles[i]);
                Assert.AreEqual(_sectors[i], image.Info.Sectors, _testFiles[i]);
                Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, _testFiles[i]);
                List <Partition> partitions = Core.Partitions.GetAll(image);
                IFilesystem      fs         = new BFS();
                int part = -1;

                for (int j = 0; j < partitions.Count; j++)
                {
                    if (partitions[j].Type == "\"UNI\\0\"")
                    {
                        part = j;

                        break;
                    }
                }

                Assert.AreNotEqual(-1, part, $"Partition not found on {_testFiles[i]}");
                Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testFiles[i]);
                fs.GetInformation(image, partitions[part], out _, null);
                Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testFiles[i]);
                Assert.AreEqual(_clusterSize[i], fs.XmlFsType.ClusterSize, _testFiles[i]);
                Assert.AreEqual(_type[i], fs.XmlFsType.Type, _testFiles[i]);
                Assert.AreEqual(_volumeName[i], fs.XmlFsType.VolumeName, _testFiles[i]);
                Assert.AreEqual(_volumeSerial[i], fs.XmlFsType.VolumeSerial, _testFiles[i]);
            }
        }
        public void BFSFunc_EqualGraphs_ReturnsAllGraphsNodes()
        {
            //Graph init

            var graph = new Graph();

            var nodeOne   = new Node("One");
            var nodeTwo   = new Node("Two");
            var nodeThree = new Node("Three");
            var nodeFour  = new Node("Four");
            var nodeFive  = new Node("Five");

            graph.AddConnection(new Edge(nodeOne, nodeTwo));
            graph.AddConnection(new Edge(nodeOne, nodeThree));
            graph.AddConnection(new Edge(nodeTwo, nodeThree));
            graph.AddConnection(new Edge(nodeTwo, nodeFour));
            graph.AddConnection(new Edge(nodeThree, nodeFive));
            graph.AddConnection(new Edge(nodeFour, nodeFive));

            //Check collection init

            var graphsNodes = new HashSet <Node>();

            graphsNodes.Add(nodeOne);
            graphsNodes.Add(nodeTwo);
            graphsNodes.Add(nodeThree);
            graphsNodes.Add(nodeFour);
            graphsNodes.Add(nodeFive);

            //BFS check

            HashSet <Node> bfsResult = BFS.BFSFunc(graph, nodeOne);

            //Assert

            Assert.AreEqual(true, HashSet <Node> .CreateSetComparer().Equals(bfsResult, graphsNodes));
        }
Exemple #11
0
        private static void RunBFS()
        {
            Graph <char> myGraph = new Graph <char>();

            GraphNode <char> nodeA = new GraphNode <char>('A');
            GraphNode <char> nodeB = new GraphNode <char>('B');
            GraphNode <char> nodeC = new GraphNode <char>('C');
            GraphNode <char> nodeD = new GraphNode <char>('D');
            GraphNode <char> nodeE = new GraphNode <char>('E');
            GraphNode <char> nodeF = new GraphNode <char>('F');
            GraphNode <char> nodeG = new GraphNode <char>('G');
            GraphNode <char> nodeP = new GraphNode <char>('P');
            GraphNode <char> nodeQ = new GraphNode <char>('Q');

            myGraph.AddVertex(nodeA);
            myGraph.AddVertex(nodeB);
            myGraph.AddVertex(nodeC);
            myGraph.AddVertex(nodeP);
            myGraph.AddVertex(nodeQ);
            myGraph.AddVertex(nodeD);
            myGraph.AddVertex(nodeE);
            myGraph.AddVertex(nodeF);
            myGraph.AddVertex(nodeG);

            myGraph.AddEdge(nodeA, nodeG, 1, true);
            myGraph.AddEdge(nodeA, nodeD, 2, true);
            myGraph.AddEdge(nodeA, nodeC, 3, true);
            myGraph.AddEdge(nodeG, nodeF, 4, true);
            myGraph.AddEdge(nodeC, nodeE, 1, true);
            myGraph.AddEdge(nodeC, nodeD, 2, true);
            myGraph.AddEdge(nodeD, nodeB, 3, true);
            myGraph.AddEdge(nodeE, nodeB, 4, true);
            myGraph.AddEdge(nodeP, nodeQ, 1, true);

            BFS <char> .BreadthFirstSearch(myGraph.VertexList);
        }
        public void BinarySearchTest()
        {
            /*
             *    5
             *   / \
             *  3   6
             * /  \
             * 2   4
             * /
             * 1
             */

            BinarySearchTree <int> bst = new BinarySearchTree <int>();

            bst.AddChild(5);
            bst.AddChild(3);
            bst.AddChild(2);
            bst.AddChild(6);
            bst.AddChild(1);
            bst.AddChild(4);

            Assert.AreEqual(4, BFS.FindBinaryTreeNode(bst.root, 4).Value);
            Assert.AreEqual(null, BFS.FindBinaryTreeNode(bst.root, 24));
        }
        private void ConnectNodes(IEnumerable <LineEntity> lineEntities)
        {
            foreach (var line in lineEntities)
            {
                var start = _map.GetById(line.FirstEnd);
                var end   = _map.GetById(line.SecondEnd);

                if (start == null || end == null || AreConnected(start, end))
                {
                    continue;
                }

                // Prev line is obstacle
                line.Vertices = BFS.GetShortestPath(start, end, _map, isObstacle: IsNotNull);
                if (line.Vertices.Count < 2)
                {
                    // Prev line is not obstacle
                    line.Vertices = BFS.GetShortestPath(start, end, _map, isObstacle: IsPowerEntity);
                }

                start.Lines.Add(line);
                _map.Connect(line.Vertices);
            }
        }
Exemple #14
0
        private List <PacPath> GetAllPathBetweenPacsAndSuperPellets()
        {
            var paths = new List <PacPath>();

            foreach (var(_, pac) in _game.MyPlayer.Pacs)
            {
                foreach (var superPellet in _game.Map.SuperPellets)
                {
                    if (!pac.IsAlive || _actions.ContainsKey(pac.Id))
                    {
                        continue;
                    }

                    var pacCell = _game.Map.Cells[pac.Position.Y, pac.Position.X];
                    var path    = BFS.GetPath(pacCell, superPellet, GetObstacleCondition(pac, pacCell));
                    if (path != null)
                    {
                        paths.Add(new PacPath(pac, superPellet, path));
                    }
                }
            }

            return(paths.OrderBy(a => a.Path.Count).ToList());
        }
Exemple #15
0
        public static void CompareSolvers(int row, int col)
        {
            //create maze
            Maze             maze;
            DFSMazeGenerator myMazeGen = new DFSMazeGenerator();

            maze = myMazeGen.Generate(row, col);
            Console.WriteLine(maze);//print
            Console.WriteLine("Starting point: " + maze.InitialPos.ToString());
            Console.WriteLine("Goal point: " + maze.GoalPos.ToString());
            // Maze myMaze = myMazeGen.Generate(rows,cols);
            ObjectAdapter mazeAdapter = new ObjectAdapter(maze);
            //BFS solution
            ISearcher <Position> sbfs = new BFS <Position>();

            sbfs.search(mazeAdapter);
            //print num of stages
            Console.WriteLine("BFS: " + sbfs.getNumberOfNodesEvaluated());
            //DFS solution
            ISearcher <Position> sdfs = new DFS <Position>();
            //sdfs.search(mazeAdapter);
            //print num of stages
            //Console.WriteLine("DFS: "+sdfs.getNumberOfNodesEvaluated());
        }
Exemple #16
0
        public void GetConnectedComponentsCountTest()
        {
            var singleComponentGraph = new GraphAdjacentLists <int>(GraphAdjacentLists <int> .DirectedGraphEnum.Undirected);

            singleComponentGraph.AddVertex(1);
            singleComponentGraph.AddVertex(2);
            singleComponentGraph.AddVertex(3);
            singleComponentGraph.AddVertex(4);
            singleComponentGraph.AddEdge(1, 2);
            singleComponentGraph.AddEdge(2, 3);
            singleComponentGraph.AddEdge(3, 4);
            singleComponentGraph.AddEdge(4, 1);

            var twoComponentsGraph = new GraphAdjacentLists <int>(GraphAdjacentLists <int> .DirectedGraphEnum.Undirected);

            twoComponentsGraph.AddVertex(1);
            twoComponentsGraph.AddVertex(2);
            twoComponentsGraph.AddVertex(3);
            twoComponentsGraph.AddVertex(4);
            twoComponentsGraph.AddEdge(1, 2);
            twoComponentsGraph.AddEdge(2, 3);

            Assert.Equal(2, BFS.GetConnectedComponentsCount(twoComponentsGraph));
        }
Exemple #17
0
    public Troop MakeMockTroop(Factory ally, int count)
    {
        Troop mockTroop = new Troop
        {
            start   = ally,
            count   = count,
            team    = Team.Ally,
            isAlly  = true,
            isEnemy = false,
        };

        BFS.UseBFS(mockTroop, mission.factory);

        int distance = ally.links[mockTroop.end];

        if (Bomb.bombs.Values.Any(b => b.isAlly && b.end == mission.factory && b.turns > distance))
        {
            return(null);
        }

        mission.acceptedMission.Add(mockTroop); //ally factory accepts the mission

        return(mockTroop);
    }
Exemple #18
0
    void Start()
    {
        //startTime = Time.time;
        life       = maxLife;
        script     = object_manager.GetComponent <ObjectManager_>();
        script_bfs = GameObject.Find("Player").GetComponent <BFS>();

        if (script_bfs.is_root_interface() == 1)
        {
            Debug.Log("exist");
        }
        else
        {
            SceneManager.LoadScene("MAP1"); // 신 다시시작
        }
        Debug.Log("No_exist");
        print(script.getBFS_v());
        script.print_distance();
        //startTime = Time.time;
        life = maxLife;



        PlayerRoundHoles = GameObject.FindGameObjectWithTag("PlayerRoundHoles").GetComponent <Text>();           // 우측 상단 플레이어 중심 구멍수 택스트

        playerPoint.position = new Vector2(-(script.gridWorldSize.x * 5) + 5, (script.gridWorldSize.y * 5) - 5); // 플레이어 시작 위치 지정
        movePoint();                                                                                             // 플레이어 시작 위치에 타일 까는작업
        StartCoroutine(CoMove());                                                                                //코루틴 시작 = update와 거의 동일하다 보면됨(마우스 클릭 위치 실시간으로 받게됨)
        f        = g.GetComponent <Hole>();
        lifeObj1 = GameObject.Find("Life1");                                                                     // life 오브젝트
        lifeObj2 = GameObject.Find("Life2");
        lifeObj3 = GameObject.Find("Life3");


        int mapsize = Mathf.RoundToInt(script.gridWorldSize.x);
    }
Exemple #19
0
        /// <summary>
        /// Solves the specified maze.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="typeOfSolve">The type of solve.</param>
        /// <returns>the solve of the maze</returns>
        /// <exception cref="System.Exception">This maze does not exist - " + name</exception>
        public MazeSolution Solve(string name, int typeOfSolve)
        {
            if (mazes.ContainsKey(name))
            {
                Maze maze = mazes[name];

                ObjectAdapter adapter = new ObjectAdapter(maze);

                BFS <Position, int> bfs = new BFS <Position, int>();
                DFS <Position, int> dfs = new DFS <Position, int>();
                switch (typeOfSolve)
                {
                case 0:
                    return(ConvertSolution(bfs.Search(adapter), maze.Name));

                case 1:
                    return(ConvertSolution(dfs.Search(adapter), maze.Name));

                default:
                    throw new Exception("This search type does not exist - " + typeOfSolve);
                }
            }
            throw new Exception("This maze does not exist - " + name);
        }
Exemple #20
0
        /// <summary>
        /// Generates a thread that solves the maze 'mazeName'
        /// </summary>
        /// <param name="mazeName">maze name</param>
        /// <param name="algorithm">algorithm to solve with</param>
        public void solveMaze(string mazeName, string algorithm)
        {
            ISearchingAlgorithm searching = null;

            if ("BFS" == algorithm)
            {
                searching = new BFS();
            }

            else if ("DFS" == algorithm)
            {
                searching = new DFS();
            }

            else
            {
                m_controller.errOutput("wrong argument inserted for <algorithm>, Algorithm options are BFS/DFS\n");
                return;
            }
            Thread thread = new Thread(() => solve(searching, mazeName));

            m_threads.Add(thread);
            thread.Start();
        }
Exemple #21
0
 protected override void getNextPath()
 {
     //Look for player within alertdistance (will lose track of player soon)
     if (Vector2.Distance(PlayerController.instance.transform.position, transform.position) < alertDistance) //Actual space
     {
         path = BFS.getShortest(maze, MazeVisual.instance.convertPosToMazeSq(transform.position),
                                MazeVisual.instance.convertPosToMazeSq(PlayerController.instance.transform.position), alertDistance); //grid distance
         //if found
         if (path.Count > 0)
         {
             if (speed != chaseSpeed)
             {
                 source.PlayOneShot(chaseclip);
             }
             speed = chaseSpeed;
             next  = path[0];
             path.Clear();
             return;
         }
     }
     speed = baseSpeed;
     //Did not find player, so revert to wandering
     base.getNextPath();
 }
Exemple #22
0
        public void BFS_SeparationCount_GivenSameStartAndGoal_ShouldReturnZero()
        {
            BFSVertex firstAndLast = new BFSVertex();

            Assert.AreEqual(0, BFS.SeparationCount(firstAndLast, firstAndLast));
        }
Exemple #23
0
 public void BFS_SeparationCount_GivenNullValues_ShouldThrowArgumentNullException()
 {
     Assert.ThrowsException <ArgumentNullException>(() => BFS.SeparationCount(null, null));
     Assert.ThrowsException <ArgumentNullException>(() => BFS.SeparationCount(new BFSVertex(), null));
     Assert.ThrowsException <ArgumentNullException>(() => BFS.SeparationCount(null, new BFSVertex()));
 }
Exemple #24
0
    public void GenerateIncisionList()
    {
        AdjacencyList.Instance.WorldPositionUpdate();
        Vector3[]      vertices      = MeshManager.Instance.mesh.vertices;
        List <Vector3> worldPosition = AdjacencyList.Instance.worldPositionVertices;

        ////MeshManager.Instance.mesh.vertices = AdjacencyList.Instance.worldPositionVertices.ToArray();
        leftSideWeight.Add(new List <float>());
        rightSideWeight.Add(new List <float>());

        float zMin = 1000000;
        float zMax = -1000000;

        for (int i = 0; i < leftSide[currentIndex].Count; i++)
        {
            float tempZ = worldPosition[leftSide[currentIndex][i]].z;
            if (tempZ < zMin)
            {
                zMin = tempZ;
            }
            if (tempZ > zMax)
            {
                zMax = tempZ;
            }
        }
        middleIndextest = leftSide[currentIndex][leftSide[currentIndex].Count / 2];
        zMax           += MeshManager.Instance.pivotTransform.lossyScale.z;
        zMin           -= MeshManager.Instance.pivotTransform.lossyScale.z;
        ////Debug.Log(startVertexIndex);
        ////Debug.Log(endVertexIndex);
        ////Debug.Log(leftSide[currentIndex][leftSide[currentIndex].Count - 1]);
        ////Debug.Log(rightSide[currentIndex][rightSide[currentIndex].Count - 1]);

        ////int[] leftSideTemptest = CGAL.ExtractCircleByBFS_Test(startVertexIndex, endVertexIndex, leftSide[currentIndex][leftSide[currentIndex].Count - 3]);
        ////int[] rightSideTemptest = CGAL.ExtractCircleByBFS_Test(startVertexIndex, endVertexIndex, rightSide[currentIndex][rightSide[currentIndex].Count - 3]);

        ////foreach (var item in rightSideTemptest)
        ////{
        ////    GameObject v_test1 = new GameObject();
        ////    v_test1 = GameObject.CreatePrimitive(PrimitiveType.Cube);
        ////    v_test1.transform.position = worldPosition[item];
        ////}

        ////foreach (var item in leftSideTemptest)
        ////{
        ////    GameObject v_test1 = new GameObject();
        ////    v_test1 = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
        ////    v_test1.transform.position = worldPosition[item];
        ////}

        ////int[] leftSideTemp = CGAL.ExtractCircleByBFS(startVertexIndex, endVertexIndex, leftSide[currentIndex][leftSide[currentIndex].Count - 1]);
        ////int[] rightSideTemp = CGAL.ExtractCircleByBFS(startVertexIndex, endVertexIndex, rightSide[currentIndex][rightSide[currentIndex].Count - 1]);

        ////leftSide[currentIndex].Clear();
        ////rightSide[currentIndex].Clear();

        ////leftSide[currentIndex] = leftSideTemp.ToList();
        ////rightSide[currentIndex] = rightSideTemp.ToList();

        List <int> leftItems  = BFS.Circle(leftSide[currentIndex][leftSide[currentIndex].Count - 1], startVertexPosition, endVertexPosition, zMin, zMax, currentIndex, firstOuterVertexIndex, lastOuterVertexIndex);
        List <int> rightItems = BFS.Circle(rightSide[currentIndex][rightSide[currentIndex].Count - 1], startVertexPosition, endVertexPosition, zMin, zMax, currentIndex, firstOuterVertexIndex, lastOuterVertexIndex);

        if (leftItems.Count > 0 && rightItems.Count > 0)
        {
            foreach (int item in leftItems)
            {
                leftSide[currentIndex].Add(item);
            }
            foreach (int item in rightItems)
            {
                rightSide[currentIndex].Add(item);
            }
        }



        startPointIndices.Add(newTriangles.Values.First());
        endPointIndices.Add(worldPosition.Count - 1);

        ////Vector3 normalVector = worldPosition[startPointIndices[currentIndex]] + MeshManager.Instance.mesh.normals[newTriangles.Values.First()];

        Transform objTransform = MeshManager.Instance.pivotTransform;

        ////여기에다가 안쪽면인지 바깥면인지를 판단 필요.
        Vector2 rightVector = Vector2.zero;
        Vector2 leftVector  = Vector2.zero;

        if (worldPosition[endPointIndices[currentIndex]].z - MeshManager.Instance.objTransform.TransformPoint(MeshManager.Instance.mesh.normals[endPointIndices[currentIndex]] + MeshManager.Instance.mesh.vertices[endPointIndices[currentIndex]]).z < 0)
        {
            rightVector = Vector2.Perpendicular(worldPosition[endPointIndices[currentIndex]] - worldPosition[startPointIndices[currentIndex]]);
            leftVector  = Vector2.Perpendicular(worldPosition[startPointIndices[currentIndex]] - worldPosition[endPointIndices[currentIndex]]);
        }
        else
        {
            leftVector  = Vector2.Perpendicular(worldPosition[endPointIndices[currentIndex]] - worldPosition[startPointIndices[currentIndex]]);
            rightVector = Vector2.Perpendicular(worldPosition[startPointIndices[currentIndex]] - worldPosition[endPointIndices[currentIndex]]);
        }

        leftVectorObject.Add(new GameObject("Left Vector" + currentIndex + 1));
        rightVectorObject.Add(new GameObject("Right Vector" + currentIndex + 1));

        leftVectorObject[currentIndex].transform.position  = new Vector3(leftVector.x + worldPosition[startPointIndices[currentIndex]].x, leftVector.y + worldPosition[startPointIndices[currentIndex]].y, worldPosition[startPointIndices[currentIndex]].z);
        rightVectorObject[currentIndex].transform.position = new Vector3(rightVector.x + worldPosition[startPointIndices[currentIndex]].x, rightVector.y + worldPosition[startPointIndices[currentIndex]].y, worldPosition[startPointIndices[currentIndex]].z);

        leftVectorObject[currentIndex].transform.SetParent(MeshManager.Instance.pivotTransform);
        rightVectorObject[currentIndex].transform.SetParent(MeshManager.Instance.pivotTransform);

        Vector3 center = Vector3.Lerp(worldPosition[startPointIndices[currentIndex]], worldPosition[endPointIndices[currentIndex]], 0.5f);
        double  radius = Vector2.Distance(center, worldPosition[endPointIndices[currentIndex]]);

        foreach (int item in leftSide[currentIndex])
        {
            double t    = Algorithms.QuadraticEquation(worldPosition[item].x - center.x, worldPosition[item].y - center.y, leftVector.x, leftVector.y, radius);
            float  temp = Convert.ToSingle(t);
            leftSideWeight[currentIndex].Add(temp);
        }
        foreach (int item in rightSide[currentIndex])
        {
            double t    = Algorithms.QuadraticEquation(worldPosition[item].x - center.x, worldPosition[item].y - center.y, rightVector.x, rightVector.y, radius);
            float  temp = Convert.ToSingle(t);
            rightSideWeight[currentIndex].Add(temp);
        }
        MeshManager.Instance.mesh.vertices = vertices;
    }
 public static void LoadSettings(BFS bfsManager)
 {
     LoadFromXML();
     bfsManager.SetSettings(settings);
 }
Exemple #26
0
        static void Main(string[] args)
        {
            List <List <int> > puz    = new List <List <int> >();
            List <List <int> > puz2   = new List <List <int> >();
            List <List <int> > goalP2 = new List <List <int> >();

            /*
             * int n = 3;
             * Console.WriteLine("Initial");
             * for (int i = 0; i < n; i++)
             * {
             *  List<int> temp = new List<int>();
             *  Console.WriteLine("Linie");
             *  for (int j = 0; j < n; j++)
             *  {
             *      Console.WriteLine("Da valoare ");
             *      int val= int.Parse(Console.ReadLine());
             *
             *
             *  }
             *  puz2.Add(temp);
             * }
             * Console.WriteLine("Goal");
             * for (int i = 0; i < n; i++)
             * {
             *  List<int> temp = new List<int>();
             *  Console.WriteLine("Linie");
             *  for (int j = 0; j < n; j++)
             *  {
             *      Console.WriteLine("Da valoare ");
             *      int val = int.Parse(Console.ReadLine());
             *
             *
             *  }
             *  goalP2.Add(temp);
             *  Console.WriteLine("Goal");
             *  }
             */
            List <int> arg = new List <int>();

            arg.Add(3);
            // arg.Add(7);
            arg.Add(4);
            List <int> arg2 = new List <int>();

            arg2.Add(1);
            arg2.Add(0);//5
            //arg2.Add(8);
            List <int> arg3 = new List <int>();

            arg3.Add(6);
            arg3.Add(2);
            arg3.Add(0);
            puz.Add(arg);
            puz.Add(arg2);
            // puz.Add(arg3);
            List <List <int> > goal = new List <List <int> >();
            List <int>         argG = new List <int>();

            argG.Add(0);
            argG.Add(1);
            //argG.Add(2);
            List <int> argG2 = new List <int>();

            argG2.Add(3);
            argG2.Add(4);
            // argG2.Add(5);
            List <int> argG3 = new List <int>();

            argG3.Add(6);
            argG3.Add(7);
            argG3.Add(8);
            goal.Add(argG);
            goal.Add(argG2);
            // goal.Add(argG3);
            Puzzle     puzzle     = new Puzzle(puz, new Pair <int, int>(1, 1)); //2 2
            Puzzle     pGoal      = new Puzzle(goal, new Pair <int, int>(0, 0));
            List <int> listI      = new List <int>();
            RepoPuzzle repoPuzzle = new RepoPuzzle(puzzle, pGoal);

            Console.WriteLine(puzzle);
            Console.WriteLine(pGoal);
            Console.WriteLine("1.BFS");
            Console.WriteLine("2.GBFS");
            Console.WriteLine("Alege o optiune");
            int opt = int.Parse(Console.ReadLine());

            if (opt == 1)
            {
                SearchMethod bFS = new BFS(repoPuzzle);
                var          e   = bFS.search(puzzle);
                //var e = bFS.searchFromAnInstance(puzzle);
                if (e == null)
                {
                    Console.WriteLine("Nu s a gasit!");
                }
                else
                {
                    foreach (var element in e)
                    {
                        Console.WriteLine(element);
                    }
                    Console.WriteLine(e.Count);
                }
            }
            if (opt == 2)
            {
                SearchMethod gbFS = new GBFS(repoPuzzle);
                var          e    = gbFS.search(puzzle);
                //var e = gbFS.searchFromAnInstance(puzzle);
                if (e == null)
                {
                    Console.WriteLine("Nu s a gasit!");
                }
                else
                {
                    foreach (var element in e)
                    {
                        Console.WriteLine(element);
                    }
                    Console.WriteLine(e.Count);
                }
            }

            Console.Read();
        }
    /// <summary>
    /// Determine the best move towards attacking range of unit
    /// </summary>
    /// <param name="movingUnitController">the unit that will be moving</param>
    /// <param name="targetUnitController">the unit to move towards</param>
    private void MoveTowardsUnit(UnitController movingUnitController, UnitController targetUnitController)
    {
        Transform movingUnitTransform = movingUnitController.GetComponent <Transform>(); //transform of moving unit
        Coords    movingUnitCoords    = movingUnitController.GetUnitCoords();
        Coords    targetUnitCoords    = targetUnitController.GetUnitCoords();
        int       attackRange         = movingUnitController.GetAttackRange();
        int       moveRange           = movingUnitController.GetMoveRange();

        //Determine best coordinates to move to to be within attack range
        //we will get a couple of coords and then check to see which one is shortest distance from moving unit

        //check the spaces next to target for best space eligibility
        List <Coords> coordsToCheck = new List <Coords>(); //a list of coords to check for best space eligibility

        //look at spaces left of target
        //move from furthest space attackable from to closer to target unit
        for (int x = targetUnitCoords.X - attackRange; x < targetUnitCoords.X; x += 2) //increment by two because if a space isn't good then the next one won't be either
        {
            Coords testCoords = new Coords(x, targetUnitCoords.Y);
            if (targetUnitController.HasDirectPath(testCoords))
            {
                //coords close to target and has direct path, add them to list of coords to check
                coordsToCheck.Add(testCoords);
            }
        }
        //spaces right of target
        for (int x = targetUnitCoords.X + attackRange; x > targetUnitCoords.X; x -= 2)
        {
            Coords testCoords = new Coords(x, targetUnitCoords.Y);
            if (targetUnitController.HasDirectPath(testCoords))
            {
                //coords close to target and has direct path, add them to list of coords to check
                coordsToCheck.Add(testCoords);
            }
        }
        //spaces above target
        for (int y = targetUnitCoords.Y + attackRange; y > targetUnitCoords.Y; y -= 2)
        {
            Coords testCoords = new Coords(targetUnitCoords.X, y);
            if (targetUnitController.HasDirectPath(testCoords))
            {
                //coords close to target and has direct path, add them to list of coords to check
                coordsToCheck.Add(testCoords);
            }
        }
        //spaces below target
        for (int y = targetUnitCoords.Y - attackRange; y < targetUnitCoords.Y; y += 2)
        {
            Coords testCoords = new Coords(targetUnitCoords.X, y);
            if (targetUnitController.HasDirectPath(testCoords))
            {
                //coords close to target and has direct path, add them to list of coords to check
                coordsToCheck.Add(testCoords);
            }
        }

        //evaluate coords that were added to list
        //look for the one with the shortest path from moving unit
        int shortestPathLength = int.MaxValue; //the length of the path to the coords that have the shortest path from moving to target
        BFS shortestPathBFS    = new BFS();    //the bfs of the shortest path to coords

        foreach (var coords in coordsToCheck)
        {
            BFS bfs = new BFS();
            if (movingUnitController.HasPath(coords, ref bfs))
            {
                int solutionLength = bfs.GetSolutionLength();
                if (solutionLength < shortestPathLength)
                {
                    shortestPathLength = solutionLength;
                    shortestPathBFS    = bfs;
                }
            }
        }

        //Move (partially or fully)
        //traverse through bfs
        int    stepsTaken     = 0;                //the number of space moved already
        Coords coordsToMoveTo = movingUnitCoords; //the coords to move to (within moveRange)

        shortestPathBFS.Reset();

        while (stepsTaken < moveRange && shortestPathBFS.HasNext())
        {
            //step along path to destination
            coordsToMoveTo = coordsToMoveTo.Get(shortestPathBFS.Next());

            stepsTaken++; //unit has moved 1 space
        }

        //set new position for moving unit
        movingUnitTransform.position = Grid.CoordsToWorldSpace(coordsToMoveTo);

        //update unit location on grid
        grid.SetGridArray(coordsToMoveTo, movingUnitController.gameObject);
        grid.SetGridArray(movingUnitCoords, null);
    }
Exemple #28
0
 public void BFS_SeparationCount_GivenTwoNonConnectedVertices_ShouldReturnNegativeOne()
 {
     Assert.AreEqual(-1, BFS.SeparationCount(new BFSVertex(), new BFSVertex()));
 }
    public bool AutomaticallyRemoveTriangles()
    {
        //저 버텍스 두개를 index로 갖는 edge로 좌우 버텍스의
        int firstIndex = removeBoundaryVertices[3];
        int secondIndex = removeBoundaryVertices[4];
        int tri1 = 0, tri2 = 0;

        AdjacencyList.Instance.ListUpdate();
        List <Edge>    edgeList      = AdjacencyList.Instance.edgeList;
        List <Vector3> worldVertices = AdjacencyList.Instance.worldPositionVertices;

        int[] triangles = MeshManager.Instance.mesh.triangles;

        for (int i = 0; i < edgeList.Count; i += 3)
        {
            if ((edgeList[i].vtx1 == firstIndex && edgeList[i].vtx2 == secondIndex) || (edgeList[i].vtx2 == firstIndex && edgeList[i].vtx1 == secondIndex))
            {
                tri1 = edgeList[i].tri1;
                tri2 = edgeList[i].tri2;
                break;
            }
            else if ((edgeList[i + 1].vtx1 == firstIndex && edgeList[i + 1].vtx2 == secondIndex) || (edgeList[i + 1].vtx2 == firstIndex && edgeList[i + 1].vtx1 == secondIndex))
            {
                tri1 = edgeList[i + 1].tri1;
                tri2 = edgeList[i + 1].tri2;
                break;
            }
            else if ((edgeList[i + 2].vtx1 == firstIndex && edgeList[i + 2].vtx2 == secondIndex) || (edgeList[i + 2].vtx2 == firstIndex && edgeList[i + 2].vtx1 == secondIndex))
            {
                tri1 = edgeList[i + 2].tri1;
                tri2 = edgeList[i + 2].tri2;
                break;
            }
        }

        int bfsVtx1 = 0, bfsVtx2 = 0;

        for (int i = 0; i < 3; i++)
        {
            if (triangles[tri1 + i] != firstIndex && triangles[tri1 + i] != secondIndex)
            {
                bfsVtx1 = triangles[tri1 + i];
                break;
            }
        }

        for (int i = 0; i < 3; i++)
        {
            if (triangles[tri2 + i] != firstIndex && triangles[tri2 + i] != secondIndex)
            {
                bfsVtx2 = triangles[tri2 + i];
                break;
            }
        }


        Debug.Log(triangles.Length);

        if (!BFS.Boundary(bfsVtx1, removeBoundaryVertices))
        {
            if (!BFS.Boundary(bfsVtx2, removeBoundaryVertices))
            {
                return(false);
            }
        }
        return(true);
    }
Exemple #30
0
        /// <summary>
        /// DFS, BFS and traverse
        /// </summary>
        public static void TreeBasedAlgo()
        {
            Tree t = new Tree();

            t.Root = new TreeNode {
                Id = 1, NodeName = "root", NodeValue = 1
            };
            TreeNode n2 = new TreeNode {
                Id = 2, NodeName = "2", NodeValue = 2
            };
            TreeNode n3 = new TreeNode {
                Id = 3, NodeName = "3", NodeValue = 3
            };
            TreeNode n4 = new TreeNode {
                Id = 4, NodeName = "4", NodeValue = 4
            };



            TreeNode n5 = new TreeNode {
                Id = 5, NodeName = "5", NodeValue = 8
            };
            TreeNode n6 = new TreeNode {
                Id = 6, NodeName = "6", NodeValue = 9
            };
            TreeNode n7 = new TreeNode {
                Id = 7, NodeName = "7", NodeValue = 8
            };

            TreeNode n8 = new TreeNode {
                Id = 8, NodeName = "8", NodeValue = 2
            };
            TreeNode n9 = new TreeNode {
                Id = 9, NodeName = "9", NodeValue = 3
            };
            TreeNode n10 = new TreeNode {
                Id = 10, NodeName = "10", NodeValue = 4
            };


            n6.Children.Add(n8);
            n7.Children.Add(n9);
            n7.Children.Add(n10);

            n2.Children.Add(n5);
            n3.Children.Add(n6);
            n4.Children.Add(n7);

            t.Root.Children.Add(n2);
            t.Root.Children.Add(n3);
            t.Root.Children.Add(n4);

            var bfsAlgo = new BFS();
            var dfsAlgo = new DFS();
            var bfsNode = bfsAlgo.Search(t, 2);
            var dfsNode = dfsAlgo.RecursiveSearch(t.Root, 4);

            if (bfsNode != null)
            {
                Console.WriteLine("BFS:{0} - name:{1} - value:{2}", bfsNode.Id, bfsNode.NodeName, bfsNode.NodeValue);
            }
            else
            {
                Console.WriteLine("BFS: 8 not found");
            }

            if (dfsNode != null)
            {
                Console.WriteLine("DFS:{0} - name:{1} - value:{2}", dfsNode.Id, dfsNode.NodeName, dfsNode.NodeValue);
            }
            else
            {
                Console.WriteLine("DFS: 2 not found");
            }

            Console.WriteLine("DFS traverse");
            dfsAlgo.RecursiveTraverse(t, t.Root);

            Console.WriteLine("BFS traverse");
            bfsAlgo.NonRecursiveTraverse(t, t.Root);

            //Console.ReadLine();
        }
Exemple #31
0
 public void Setup()
 {
     bfs   = new BFS <TileNode>();
     tests = new PathfinderTests();
 }
Exemple #32
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Flody

            Stopwatch sh = new Stopwatch();

            sh.Start();
            Flody fl = new Flody();

            fl.Main();
            TimeSpan tsFlody = sh.Elapsed;

            listBox1.Items.Add("Flody             : " + tsFlody.TotalMilliseconds + "ms");
            sh.Reset();
            sh.Start();
            chart1.Series["Süre"].Points.AddXY("Flody", tsFlody.TotalMilliseconds);



            //Dijkstra

            Stopwatch st = new Stopwatch();

            st.Start();
            Dijkstra dj = new Dijkstra();

            dj.Main();
            TimeSpan tsDijkstra = st.Elapsed;

            listBox1.Items.Add("Dijkstra          : " + tsDijkstra.TotalMilliseconds + "ms");
            st.Reset();

            st.Start();

            chart1.Series["Süre"].Points.AddXY("Dijkstra", tsDijkstra.TotalMilliseconds);



            //Kruskal
            Stopwatch spw = new Stopwatch();

            spw.Start();
            KruskalAlgorithm kr = new KruskalAlgorithm();

            kr.Main();
            TimeSpan tsKruskalAlgorithm = spw.Elapsed;

            listBox1.Items.Add("Kruskal          : " + tsKruskalAlgorithm.TotalMilliseconds + "ms");
            spw.Reset();
            spw.Start();
            chart1.Series["Süre"].Points.AddXY("Kruskal", tsKruskalAlgorithm.TotalMilliseconds);


            //FloydWarshall

            Stopwatch wh = new Stopwatch();

            wh.Start();
            FloydWarshallAlgo fw = new FloydWarshallAlgo();

            fw.Main();
            TimeSpan tsFloydWarshallAlgo = wh.Elapsed;

            listBox1.Items.Add("FloydWarshall: " + tsFloydWarshallAlgo.TotalMilliseconds + "ms");
            wh.Reset();
            wh.Start();
            chart1.Series["Süre"].Points.AddXY("FloydWarshall", tsFloydWarshallAlgo.TotalMilliseconds);

            //BFS

            Stopwatch wt = new Stopwatch();

            wt.Start();
            BFS bs = new BFS();

            bs.Main();
            TimeSpan tsBFS = wh.Elapsed;

            listBox1.Items.Add("BreadthFirst  : " + tsBFS.TotalMilliseconds + "ms");
            wt.Reset();
            wt.Start();
            chart1.Series["Süre"].Points.AddXY("BFS", tsBFS.TotalMilliseconds);

            //DFS

            Stopwatch sp = new Stopwatch();

            sp.Start();
            DFS ds = new DFS();

            ds.Main();
            TimeSpan tsDFS = wh.Elapsed;

            listBox1.Items.Add("DepthFirst     : " + tsDFS.TotalMilliseconds + "ms");
            sp.Reset();
            sp.Start();
            chart1.Series["Süre"].Points.AddXY("DFS", tsDFS.TotalMilliseconds);

            chart1.Series["Süre"].Color = Color.Purple;

            //PriorityQueue

            Stopwatch so = new Stopwatch();

            so.Start();
            PriorityQueue pq = new PriorityQueue();

            pq.heapSort();
            TimeSpan tsPriorityQueue = so.Elapsed;

            listBox1.Items.Add("PriorityQueue: " + tsPriorityQueue.TotalMilliseconds + "ms");
            so.Reset();
            so.Start();
            chart1.Series["Süre"].Points.AddXY("PriorityQueue", tsPriorityQueue.TotalMilliseconds);



            //BellmanFord
            Stopwatch sw = new Stopwatch();

            sw.Start();
            BellmanFord bf = new BellmanFord();

            bf.Main();
            TimeSpan tsBellmanFord = sw.Elapsed;

            listBox1.Items.Add("Bellman Ford: " + tsBellmanFord.TotalMilliseconds + " ms");
            sw.Reset();

            sw.Start();


            chart1.Series["Süre"].Points.AddXY("Bellman Ford", tsBellmanFord.TotalMilliseconds);
            chart1.Series["Süre"].Color = Color.DarkMagenta;
        }
    public void GenerateIncisionList(int MeshIndex)
    {
        MultiMeshAdjacencyList.Instance.WorldPositionUpdate();

        Vector3[]      vertices      = MultiMeshManager.Instance.Meshes[MeshIndex].vertices;
        List <Vector3> worldPosition = MultiMeshAdjacencyList.Instance.WorldPositionVertices[MeshIndex];

        leftSideWeight.Add(new List <float>());
        rightSideWeight.Add(new List <float>());

        float zMin = 1000000;
        float zMax = -1000000;

        for (int i = 0; i < leftSide[currentIndex].Count; i++)
        {
            float tempZ = worldPosition[leftSide[currentIndex][i]].z;

            if (tempZ < zMin)
            {
                zMin = tempZ;
            }
            if (tempZ > zMax)
            {
                zMax = tempZ;
            }
        }

        middleIndextest = leftSide[currentIndex][leftSide[currentIndex].Count / 2];

        zMax += MultiMeshManager.Instance.PivotTransform.lossyScale.z;
        zMin -= MultiMeshManager.Instance.PivotTransform.lossyScale.z;

        List <int> leftItems  = BFS.Circle(leftSide[currentIndex][leftSide[currentIndex].Count - 1], startVertexPosition, endVertexPosition, zMin, zMax, currentIndex, firstVertexIndex, lastVertexIndex, MeshIndex);
        List <int> rightItems = BFS.Circle(rightSide[currentIndex][rightSide[currentIndex].Count - 1], startVertexPosition, endVertexPosition, zMin, zMax, currentIndex, firstVertexIndex, lastVertexIndex, MeshIndex);

        if (leftItems.Count > 0 && rightItems.Count > 0)
        {
            foreach (int item in leftItems)
            {
                leftSide[currentIndex].Add(item);
            }
            foreach (int item in rightItems)
            {
                rightSide[currentIndex].Add(item);
            }
        }

        startPointIndices.Add(newTriangles.Values.First());
        endPointIndices.Add(worldPosition.Count - 1);

        Transform objTransform = MultiMeshManager.Instance.PivotTransform;

        // 안쪽, 바깥쪽 판단 필요함.
        Vector2 rightVector = Vector2.zero;
        Vector2 leftVector  = Vector2.zero;

        if (worldPosition[endPointIndices[currentIndex]].z - MultiMeshManager.Instance.Transforms[MeshIndex].TransformPoint(MultiMeshManager.Instance.Meshes[MeshIndex].normals[endPointIndices[currentIndex]] + MultiMeshManager.Instance.Meshes[MeshIndex].vertices[endPointIndices[currentIndex]]).z < 0)
        {
            rightVector = Vector2.Perpendicular(worldPosition[endPointIndices[currentIndex]] - worldPosition[startPointIndices[currentIndex]]);
            leftVector  = Vector2.Perpendicular(worldPosition[startPointIndices[currentIndex]] - worldPosition[endPointIndices[currentIndex]]);
        }
        else
        {
            leftVector  = Vector2.Perpendicular(worldPosition[endPointIndices[currentIndex]] - worldPosition[startPointIndices[currentIndex]]);
            rightVector = Vector2.Perpendicular(worldPosition[startPointIndices[currentIndex]] - worldPosition[endPointIndices[currentIndex]]);
        }

        leftVectorObject.Add(new GameObject("Left Vector" + currentIndex + 1));
        rightVectorObject.Add(new GameObject("Right Vector" + currentIndex + 1));

        leftVectorObject[currentIndex].transform.position  = new Vector3(leftVector.x + worldPosition[startPointIndices[currentIndex]].x, leftVector.y + worldPosition[startPointIndices[currentIndex]].y, worldPosition[startPointIndices[currentIndex]].z);
        rightVectorObject[currentIndex].transform.position = new Vector3(rightVector.x + worldPosition[startPointIndices[currentIndex]].x, rightVector.y + worldPosition[startPointIndices[currentIndex]].y, worldPosition[startPointIndices[currentIndex]].z);

        leftVectorObject[currentIndex].transform.SetParent(MultiMeshManager.Instance.PivotTransform);
        rightVectorObject[currentIndex].transform.SetParent(MultiMeshManager.Instance.PivotTransform);

        Vector3 center = Vector3.Lerp(worldPosition[startPointIndices[currentIndex]], worldPosition[endPointIndices[currentIndex]], 0.5f);
        double  radius = Vector2.Distance(center, worldPosition[endPointIndices[currentIndex]]);

        foreach (int item in leftSide[currentIndex])
        {
            double t    = Algorithms.QuadraticEquation(worldPosition[item].x - center.x, worldPosition[item].y - center.y, leftVector.x, leftVector.y, radius);
            float  temp = Convert.ToSingle(t);
            leftSideWeight[currentIndex].Add(temp);
        }
        foreach (int item in rightSide[currentIndex])
        {
            double t    = Algorithms.QuadraticEquation(worldPosition[item].x - center.x, worldPosition[item].y - center.y, rightVector.x, rightVector.y, radius);
            float  temp = Convert.ToSingle(t);
            rightSideWeight[currentIndex].Add(temp);
        }

        MultiMeshManager.Instance.Meshes[MeshIndex].vertices = vertices;
    }