Im trying to implement someway to calculate the path an AI has to take through a grid/tile based system. Ive implemented a tilebased system where i can update the value that any position has, 3 and 1 for walkable tiles in my code. Ive then made a class that can retrieve set value as shown below
Im then checking for every walkable tile in the cardinal directions
While looking through ways to do this in a better way i encountered the switch() operation, and thought it would save me a couple of lines of code at best. But it seems overly redundant to type out all of the possible ways that the ai could move, since this would net me about 25 switch scenarios for all of the possible combinations. Is there a better way to do this? Since im going to let it path to deadends, and will probably have to save the last crossroads it encountered, im likely ending up with even more scenarios than that...

