Beispiel #1
0
    public void solveMaze()
    {
        switch (solutionNum)
        {
        case 0: distances = SolutionAlgorithms.Dijkstra(maze, root); colorMaze(); break;

        case 1: showPath(); break;
        }
    }
Beispiel #2
0
    void showPath()
    {
        List <Cell> path = SolutionAlgorithms.Tremaux(maze, root, goal);

        foreach (Cell cur in path)
        {
            cur.transform.Find("Floor").GetComponent <Renderer>().material = material;
        }
    }
Beispiel #3
0
    void colorMaze()
    {
        List <Cell> path = SolutionAlgorithms.getLongestPath(maze, distances);

        goal = path[0]; root = path[path.Count - 1];

        Cell furthestCell = SolutionAlgorithms.getMax(maze, distances);
        int  furthestDist = distances[(int)furthestCell.y, (int)furthestCell.x];

        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                maze[y, x].transform.Find("Floor").GetComponent <Renderer>().material.color = Color.Lerp(Color.white, material.color, (float)distances[y, x] / furthestDist);
            }
        }
    }
Beispiel #4
0
    public void updateLengthText()
    {
        Cell temp = SolutionAlgorithms.getMax(mazeGenerator.maze, mazeGenerator.distances);

        lengthText.text = "Longest Path Length: " + mazeGenerator.distances[temp.y, temp.x];
    }