Soon after joining the 2048 craze, I was able to consistently reach the 2048 tile and was ready to begin my pursuit of the 4096 tile to truly prove my skill. However, I quickly grew tired of the tedious task of quickly and repeatedly selecting the right direction and got frustrated with my flawed mushy human brain slipping up. Having never done any kind of game A.I., I decided 2048 would be the perfect game to try my hand at it, so I downloaded the source code and got cracking.
Pathfinding is an integral part of many top-down games, especially RTS games like Starcraft or Age of Empires, in which you tell a unit where to go, and it figures out the best way to get there itself, navigating around obstacles and unwalkable spaces. A proven way of doing efficient and accurate pathfinding is using the A* search algorithm. After doing some tutorials on C++ and SDL, I thought I’d give it a shot. After getting some free-to-use art from http://opengameart.org/, I came up with the following: