I'm developing an A* path router in C++ for an academic project. The router reads a netlist from a netlist.cpp file, finds paths on a 2D grid using A* (Manhattan heuristic, 4‑directional moves), and marks the paths on the grid.
What I have so far:
-
RoteadorAstarclass with a working A* algorithm. -
Netlist loading via
#include "netlist.cpp". -
Multi‑net routing with grid updates.
-
Console printing of the final grid.
The next step (second part of the assignment):
I need to generate a textual output file (e.g., .txt) that records all routed paths. The suggested format by my professor is:
start_x,start_y, "movement_string"
where the movement string uses:
-
^= up (decrease x) -
v= down (increase x) -
<= left (decrease y) -
>= right (increase y)
For example, a path from (2,2) that goes up twice and then right 8 steps would be written as:
2,2, "^^>>>>>>>>"
I need to compute the direction between consecutive points and then group consecutive identical moves into a count (or just repeat the character). A naïve repetition is fine.
Any code snippets or design suggestions for generating this textual output would be greatly appreciated. Thank you!