A* pathfinding examples

Hey everyone, im trying to learn the A* pathfinding algoritm, which is simple enough when using winforms or console applications, but for various reasons im having dificulty making it work with monogame, im too stubborn to quit however :stuck_out_tongue: Do any of you know any monogame examples of pathfinding algoritms? (That does not use a custom made library. which all the examples i could find did). I would help alot to see how everyone else implements this stuff in monogame :slight_smile:


I use a self-made (but butt-ugly :slight_smile: ) implementation.

Here are some helpful links in general:

Here is a nice introduction to A*:

This here is helpful as well (you maybe found this yourself):

Sorry that I cannot give you a nice implementation though.
If you have specific questions about the implementation, feel free to PM me.


what is different from monogame to a console or winform application? What is giving you trouble?

The good old Xbox Live XNA demos: http://xbox.create.msdn.com/en-US/education/catalog/sample/pathfinding

1 Like

You can also get the samples from the new XNAGameStudio GitHub archive project.


I have done A* for a game I never finished with vanilla monogame…

It was going to be a complete heroes 3 clone, using all the original sprites and my own expansions… But I only ever finished the terrain editor and hero movement…

So you click somewhere on the scrolling map grid, and it plots a course from the current heroes tile, around obstacles like impassable terrain, to the clicked tile.
Each tile on this course, has its grid-address, or instance, added to a list, and for each (item on that list), a green X is drawn on the map screen, so you can preview the route…

Click again, and the hero sprite moves along the path, one list-item at a time, or until the player interrupts…

To start with, you need a grid to move across, like a tile grid of some kind, where each tile is an instance of a class that contains a variable to store that individual tiles pass-ability. Like tiles with walls would be marked as impassable…

If you can set that up, then I think I can take you through the rest based on my old code… If you want.

1 Like

Some really awsome stuff there, pretty sure this was what i was looking for :smiley: thx alot!

Np. That’s what it’s there for.
Feel free to extend it btw.