Example #1
0
    public StateData[] StartAlgorithm()
    {
        //maze = new int[,]{
        //    { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 },
        //    { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
        //    { 1, 1, 1, 0, 0, 0, 0, 0, 0, 1 },
        //    { 1, 1, 1, 0, 0, 0, 1, 1, 1, 1 },
        //    { 1, 1, 1, 0, 0, 0, 1, 1, 1, 1 },
        //    { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 },
        //    { 1, 1, 1, 0, 0, 0, 0, 1, 1, 1 },
        //    { 1, 1, 1, 0, 1, 1, 0, 1, 1, 1 },
        //    { 1, 1, 1, 0, 1, 1, 0, 1, 1, 1 },
        //    { 1, 1, 1, 1, 1, 1, 0, 0, 0, 1 }
        //};

        maze = new int[, ] {
            { 1, 1, 1, 1, 1 },
            { 1, 1, 0, 1, 1 },
            { 1, 0, 1, 0, 1 },
            { 1, 1, 1, 0, 1 },
            { 1, 1, 1, 0, 1 }
        };

        N = maze.GetLength(1);
        Debug.Log(N);
        stateDataList        = new List <StateData>();
        visualMazeController = this.GetComponent <VisualMazeController>();
        visualMazeController.InitializeData(maze, N);
        SolveMaze(maze);
        return(stateDataList.ToArray());
    }
Example #2
0
    // Update is called once per frame

    public DataByStep[] StartAlgorithm()
    {
        mov_col    = new int[4];
        mov_fil    = new int[4];
        mov_fil[0] = 1; mov_col[0] = 0;     /*SUR*/
        mov_fil[1] = 0; mov_col[1] = 1;     /*ESTE*/
        mov_fil[2] = 0; mov_col[2] = -1;    /*OESTE*/
        mov_fil[3] = -1; mov_col[3] = 0;    /*NORTE*/

        maze = new int[, ] {
            { 1, 1, 1, 1, 1 },
            { 1, 1, 0, 0, 1 },
            { 1, 0, 0, 1, 1 },
            { 1, 1, 0, 1, 0 },
            { 1, 1, 0, 1, 1 }
        };

        N              = maze.GetLength(1);
        lab            = new int[N, N];
        stateDataList  = new List <FullStateData>();
        dataByStepList = new List <DataByStep>();
        Laberinto(1, 0, 0, phase);

        visualMazeController = this.GetComponent <VisualMazeController>();
        visualMazeController.InitializeData(maze, N);

        Debug.Log("Solucion");
        string solution = "";

        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                solution = solution + " " + lab[i, j];
            }
            solution += "\n";
        }
        Debug.Log(solution);

        Debug.Log("TAMAÑO LISTA: " + dataByStepList.Count);



        return(dataByStepList.ToArray());
    }
    // Start is called before the first frame update
    void Start()
    {
        algthm            = GetComponent <Backtracking>();
        vslMazeCtrll      = GetComponent <VisualMazeController>();
        controlDataList   = new List <ControlData>();
        controlPhasesList = new List <ControlPhases>();
        if (sectionImages.Length == 0)
        {
            sectionImages = new GameObject[steps];

            for (int i = 0; i < steps; i++)
            {
                sectionImages[i] = GameObject.Find(SECTION + (i + 1));
                sectionImages[i].SetActive(false);
            }
        }

        SolveMaze();
    }