Search Wiki:

New Release!

I added a slightly improved version to the archive here. Not a huge improvement, but improvements in many arenas. You can now adjust paths by adding or removing walls anywhere.

Pathfinding C#

This is a resource page for a simple implementation of a pathfinding algorithm in C#. It uses enumerators and objects to find the shortest distance between two points on a field. It is very simple and not very powerful right now.

The program also contains a way to add walls and save and open different maps. I intend to add more features and enhancements to the app, but I think it would be best to release an early version.

Requirements

It works well in Visual Studio 2008 and I hope the code is easy to understand. It will require .NET 3.5 but you doubtless have that if you are using Visual Studio 2008.

Screenshots

Here are a couple screenshots. The first one shows a simple map, with the path being blue and the two points being red. The two points can be thought of as a monster and a hero.

minotaur1.png

Here is another example. Note that you can click on a square to add a wall, which will cause the path to move.

Minotaur2.png

Notes

Maps are stored in plain text. Currently things are very simple but the algorithm works reliably. There is a detailed write up at http://dotnetperls.com/Content/Pathfinding.aspx that you definitely should read if you are interested in this project.

The algorithm uses enumerators on 2D arrays. I have written a good explanation of this in my article http://dotnetperls.com/Content/2D-Foreach-Yield.aspx that might be useful.

Important Links

This is not intended to become a huge blockbuster game! I just want to show the algorithm and maybe encourage some programmers to start a new project similar to this. I think you can have fun working with this stuff and I hope you do.

This is .NET 3.5 C# code. There are many more articles at my site http://dotnetperls.com/, although not any others on this exact topic. Finally my site has more code at http://code.google.com/p/dotnetperls-controls/.
Last edited May 17 at 12:09 AM  by smallenucd, version 14
Comments
smallenucd wrote  May 15 at 1:59 AM  
Made the page organized better

smallenucd wrote  May 17 at 12:06 AM  
New release!

smallenucd wrote  May 17 at 12:07 AM  
Formatting fixes

Updating...
Page view tracker