Exemplo n.º 1
0
 public DStarLiteAlgorithm(GridMarkerController gridMarkerController, IVertexOperations positionResolver, IHeuristicEstimate heuristicEstimate, float timeDelay = 1.0f, float moveTimeDelay = 1.0f)
 {
     this.gridMarkerController = gridMarkerController;
     this.heuristicEstimate    = heuristicEstimate;
     this.positionResolver     = positionResolver;
     this.timeDelay            = timeDelay;
     this.moveTimeDelay        = moveTimeDelay;
 }
    public void StratPathFindinAlgorithm()
    {
        pathFind.interactable         = false;
        resetCurrentPath.interactable = true;
        clearAll.interactable         = true;
        gridController.PathGridState  = PathGridState.PathFind;
        gridController.InitGraf();
        Vector2Int goalPosition  = new Vector2Int(gridController.GoalPos.x, gridController.GoalPos.y);
        Vector2Int startPosition = new Vector2Int(gridController.StartPos.x, gridController.StartPos.y);

        IHeuristicEstimate heuristic = HeuristicFactory.СreateHeuristic(heuristicType, breakerType, startPosition, float.Parse(heuristicCoeffField.text));
        float          timeDelay     = float.Parse(delayBeforeSteps.text);
        AStarAlgorithm algorithm     = new AStarAlgorithm(gridMarkerController, heuristic, timeDelay);

        pathFindingAlgorithmCoroutine = StartCoroutine(algorithm.FindPath(gridController.GetStartVertex(), gridController.GetGoalVertex()));
    }
    public void StratPathFindinAlgorithm()
    {
        OnPathSearchState();
        gridController.InitGraf();
        Vector2Int goalPosition  = new Vector2Int(gridController.GoalPos.x, gridController.GoalPos.y);
        Vector2Int startPosition = new Vector2Int(gridController.StartPos.x, gridController.StartPos.y);

        IHeuristicEstimate heuristic = HeuristicFactory.СreateHeuristic(HeuristicType.Manhattan, TieBreakerType.None, startPosition, 1);
        float timeDelay     = float.Parse(delayBeforeSteps.text);
        float moveTimeDelay = float.Parse(delayBeforeMove.text);

        DStarLiteAlgorithm algorithm = new DStarLiteAlgorithm(gridMarkerController, gridController.Graph, heuristic, timeDelay);

        gridController.OnVerteciesUpdate = (vertecies) => { vertecies.ForEach(v => algorithm.UpdatePath(v)); };

        pathFindingAlgorithmCoroutine = StartCoroutine(algorithm.MoveByPath(gridController.GetStartVertex(), gridController.GetGoalVertex(), OnPathSearchState, OnStartMove));
    }
Exemplo n.º 4
0
 public AStarAlgorithm(GridMarkerController gridMarkerController, IHeuristicEstimate heuristic, float sleepTime = 0.1f)
 {
     this.gridMarkerController = gridMarkerController;
     this.sleepTime            = sleepTime;
     this.heuristic            = heuristic;
 }