# Mermaid test ```mermaid flowchart TB %% ---------- Top-level initialisation ---------- A((Start)) B[Init] C[Run] A --> B --> C %% ---------- Main loop ---------- D{Is program running?} C --> D D -- No --> E((Quit)) %% ---------- User-interaction decisions ---------- D -- Yes --> F{User select another map?} %% --- Branch 1 : new map --- F -- Yes --> F1[is_solution_running = false] F1 --> F2[is_search_visualizing = false] F2 --> F3[Update current state =\ninitial state from selected map] F3 --> SR %% --- Branch 2 : new algorithm --- F -- No --> G{User select another algorithm?} G -- Yes --> G1[is_solution_running = false] G1 --> G2[is_search_visualizing = false] G2 --> G3[Reset current state =\ninitial state and get selected algorithm] G3 --> SR %% --- Branch 3 : find solution --- G -- No --> H{User choose to find solution?} H -- Yes --> H1[is_solution_running = true] H1 --> H2[is_search_visualizing = false] H2 --> H3[Reset current state =\ninitial state and find new solution] H3 --> SR %% --- Branch 4 : visualise search --- H -- No --> I{User choose to visualise\nsearch process?} I -- Yes --> I1[is_search_visualizing = true] I1 --> I2[is_solution_running = false] I2 --> I3[Reset current state =\ninitial state and load search process] I3 --> SR %% If none of the four “Yes” branches fire, fall through to status checks I -- No --> SR %% ---------- Status-driven execution ---------- SR{is_solution_running == true} %% -- Solution playback -- SR -- Yes --> SC{Is the solution complete?} SC -- No --> S1[Update current state =\nnext state from solution] --> R SC -- Yes --> R %% -- Search-process playback -- SR -- No --> SV{is_search_visualizing == true} SV -- Yes --> SPC{Is the search process complete?} SPC -- No --> S2[Update current state =\nnext state from search process] --> R SPC -- Yes --> R SV -- No --> R %% ---------- Rendering & loop-back ---------- R[Render current state and GUI elements] R --> D %% loop back to “Is program running?” ```