An A* Visualization

racketvizaoc

In the latest Advent of Code there was a pathfinding puzzle. I'd never written an A* before, so I decided to go with the, maybe a bit overkill, algorithm as the solution. Things are also better with graphics, so I added visualization.

GUI Performance

I had to do some optimizations to have it run at a reasonable speed, which came as a bit of a surprise. I believe most of the stuff is on CPU, using the platforms native rendering frameworks, which aren't that performant to begin with. I started by rendering the background grid once to a texture, since that doesn't change. Once the algorithm had chugged along for awhile, things started slowing down significantly. This was due to the squares marking visited tiles. I rendered those to a texture as well, and only drew the ones that had been added in that cycle.

Algorithm

As you can see the heuristic doesn't do too good of a job in the not-going-everywhere-before-the-goal department, but that is alright. There should be some room to choose more aggressive heuristics, but I didn't go into figuring that out.

Code for my day 12 solution