Exemplo n.º 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());
    }
Exemplo n.º 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());
    }