This week I was contacted by Roman Kazakov (fourfor[AT]hotmail.com). He had a look at my previous A* articles and came up with a number of ways to speed up my latest version even more! Unfortunately he doesn’t have a blog, so he asked me to publish his enhancements here, so that everyone can use them. So I’ll forego the rest of this introduction and let the man speak.
(Note: the following quote is the last unedited part of an e-mail of Roman Kazakov).
Hi Roy, my name is Roman Kazakov and I am Russian guy, but live in Latin America. My Spanish is perfect, but my English is "so so", I hope you understand me. :) I am not a professional programmer. This is just my hobby from university. And as "free lancer" I work with VS 2008 C# + DevXpress + SQL Server 2008.
I would like to present you my optimization for you program AStar. Oh, by the way, my game is 2D, and this example is in 2D dimension, but this version will by work and 3D too and more faster.
Here is code of FindPathReversed:
Look in my screenshots which i made it for you. For looking performance I used ANTS Performance Profiler 5.2. This is a great "stuff"!
Also you can use your benchmark. Check the file zip attached. There is all source and information for compiled.
Comments about code:
The general "thing" in programming in C# is do not use Obj Class and etc. where really dont need to use that! The best performance is just "Value type" and List<>
Array, maybe Struct.
In my optimized code I deleting class MinHeap where T : IComparable. Why?! Because is really slow, and I dont know why. Also use class Point2D just for 2(3) types X and Y( and Z), it was a bad idea. And many thing more. Looked my code and you understand which changes I made it. I hope this is help you. And please put this optimization on you wonderful web page http://roy-t.nl, as New Optimized Version A*.
When we made the games, we looking for more faster algorithm and code. This article will be help a many people as us.
We made the games of our dreams...