Advertisement

A* question

Started by August 30, 2007 11:59 AM
2 comments, last by Rockoon1 17 years, 5 months ago
I found an implementation of A* shown below that someone wrote on codeproject.com that's perfect for what I need, but there's an issue: http://www.codeproject.com/cs/algorithms/seunghyopback.asp It's on a 2d grid and doesn't take diagonal movement costs into consideration, so there's a lot of sidestepping. I'm wondering where do I include this consideration. I tried putting it in the node class by changing "g" to 1.5 under certain conditions, but I get a compile error since the IComparer interface uses "g" and doesn't really like floats so I'm wondering what else I should try. In the comments at the bottom of the codeproject page someone brought this up, but his answer wasn't completely clear for me.
Rewrite the comparison function.

Or make horizontal and vertical movements cost 10 and make diagonal movements cost 14.
Advertisement
I find 2 and 3 respectively are adequate.
The civilization series of games infact uses a 1 and 1.5 (same as 2 and 3) distance metric for all game mechanics...

This topic is closed to new replies.

Advertisement