Path Finding for Advent of Code 2022 – Day 12

Day 12 of Advent of Code is a path finding problem, which is ripe for visualization. I used the A* algorithm for my solution, which should get to the closest path as fast as possible. It’s always crazy to watch these algorithms in action as they search and narrow down the solution near the end.

Searching for a path. Running up that hill.

Lessons Learned

This is the first visualization with a large amount of nodes. For just the terrain, there are 5,904 nodes. The renderer uses one giant buffer for storing constants and allows a max of 3 renders in flight at a time. This means I can only use 1/3 of the buffer per render pass. In my original implementation, I was breaking past the 3MB buffer, which at best causes artifacts, and at worst causes slow downs and lock ups. To fix this, I added:

  1. The ability to specify the buffer size at initialization.
  2. A check after a render pass to fatally crash the app if more than the maximum buffer allowance is used.

Posted

in

,

by

Tags: