void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            control.snapshotStatus.text = "Running Greedy Best-First-Search pathfinding algorithm...";
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            List <Node> path = greedy.FindPath(startX, startY, startZ, goalX, goalY, goalZ);
            stopwatch.Stop();
            control.snapshotStatus.text = "Pathfinding complete!";

            long timeToComplete     = stopwatch.ElapsedMilliseconds;
            int  pathedNodes        = path.Count;
            int  openListSize       = greedy.openList.Count;
            int  closedListSize     = greedy.closedList.Count;
            int  totalNodesSearched = openListSize + closedListSize;
            int  totalMoveCost      = path[path.Count - 1].g;

            UnityEngine.Debug.Log($"Time taken to complete: {timeToComplete}ms");
            UnityEngine.Debug.Log($"Number of pathed nodes: {pathedNodes}");
            UnityEngine.Debug.Log($"Total nodes searched: {totalNodesSearched}");
            UnityEngine.Debug.Log($"Open list size: {openListSize}");
            UnityEngine.Debug.Log($"Closed list size: {closedListSize}");
            UnityEngine.Debug.Log($"Total move cost of path (g): {totalMoveCost}");

            control.consoleText.text = "RESULTS\n\n"
                                       + "Time to complete: " + timeToComplete + "ms\n"
                                       + "Number of pathed nodes: " + pathedNodes + "\n"
                                       + "Total nodes searched: " + totalNodesSearched + "\n"
                                       + "Open list size: " + openListSize + "\n"
                                       + "Closed list size: " + closedListSize + "\n"
                                       + "Total move cost of path (g): " + totalMoveCost;

            // Create file at "Results/path_name/DDMMYYYY"
            string       scene      = SceneManager.GetActiveScene().name;
            string       time       = System.DateTimeOffset.Now.ToString("yyyyMMdd");
            string       pathString = $"Results/{scene}/{time}.csv";
            StreamWriter writer     = new StreamWriter(pathString, true);

            // Write test results to file
            writer.WriteLine("'algorithm', 'Time to complete (ms)', 'Number of pathed nodes', 'Total nodes searched', 'Open list size', 'Closed list size', 'Total move cost (g)'");
            writer.WriteLine($"Greedy, {timeToComplete}, {pathedNodes}, {totalNodesSearched}, {openListSize}, {closedListSize}, {totalMoveCost}");
            writer.Close();
            UnityEngine.Debug.Log($"Results written to: {pathString}");
        }
    }
    void Update()
    {
        // Greedy
        if (Input.GetKeyDown(KeyCode.Space) && currentAlgorithm == "greedy")
        {
            currentAlgorithm = null;

            control.snapshotStatus.text = "Running Greedy Best-First-Search pathfinding algorithm...";
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            List <Node> path = greedy.FindPath(startX, startY, startZ, goalX, goalY, goalZ);
            stopwatch.Stop();
            control.snapshotStatus.text = "Press ENTER to move to next algorithm\nPathfinding complete!";

            long timeToComplete     = stopwatch.ElapsedMilliseconds;
            int  pathedNodes        = path.Count;
            int  openListSize       = greedy.openList.Count;
            int  closedListSize     = greedy.closedList.Count;
            int  totalNodesSearched = openListSize + closedListSize;
            int  totalMoveCost      = path[path.Count - 1].g;

            UnityEngine.Debug.Log($"Time taken to complete: {timeToComplete}ms");
            UnityEngine.Debug.Log($"Number of pathed nodes: {pathedNodes}");
            UnityEngine.Debug.Log($"Total nodes searched: {totalNodesSearched}");
            UnityEngine.Debug.Log($"Open list size: {openListSize}");
            UnityEngine.Debug.Log($"Closed list size: {closedListSize}");
            UnityEngine.Debug.Log($"Total move cost of path (g): {totalMoveCost}");

            control.consoleText.text = "Greedy results\n\n"
                                       + "Time to complete: " + timeToComplete + "ms\n"
                                       + "Number of pathed nodes: " + pathedNodes + "\n"
                                       + "Total nodes searched: " + totalNodesSearched + "\n"
                                       + "Open list size: " + openListSize + "\n"
                                       + "Closed list size: " + closedListSize + "\n"
                                       + "Total move cost of path (g): " + totalMoveCost;

            // Write test results to file
            writer.WriteLine($"Greedy, {timeToComplete}, {pathedNodes}, {totalNodesSearched}, {openListSize}, {closedListSize}, {totalMoveCost}");
            writer.Close();

            UnityEngine.Debug.Log($"Results written to: {pathString}");

            currentAlgorithm = "greedyDone";
        }
    }