O'Reilly logo

Lua Game Development Cookbook by Mário Kašuba

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Pathfinding for tile-based environments with obstacles

This recipe will show you how to solve the pathfinding problem in your game by using the A* algorithm. You can use this whenever you need to move from one point to another in an unknown environment. It uses heuristics to improve the search speed and efficiency. The good thing is that you can use it with any shape of tile. The most common use of the A* search algorithm can be found in strategic games, many action games, and tower defense games. Its use can be extended beyond pathfinding problems to adapt AI decisions to the environment or to make a dynamic liquid-like environment.

Getting ready

The A* searching algorithm makes extensive use of the priority queue data structure and it needs to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required