Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Need Code for A star path finding


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
16 replies to this topic

#1 Altaf   Members   -  Reputation: 122

Like
0Likes
Like

Posted 08 December 2006 - 08:37 PM

Hi guys, Can any body send me A star ( A* ) path finding code in C++ for DirectX. Thanks in advance.

Sponsor:

#2 Nik02   Crossbones+   -  Reputation: 2926

Like
0Likes
Like

Posted 08 December 2006 - 09:12 PM

A* pathfinding has exactly nothing to do with DirectX.

I googled for "a star pathfinding" and the first result leads you to a very accurate description of the algorithm. If you know C++ to begin with, it is a quite simple task to write an implementation of your own.

Niko Suni


#3 Altaf   Members   -  Reputation: 122

Like
0Likes
Like

Posted 08 December 2006 - 09:45 PM

I specified DirectX because I googled for A* code & i found some source code which was either complete C code or a C++ code made using some library which I don't have. I am working on building my own code. Hopefully I`ll finish it soon, but I need a working code for reference.

#4 jollyjeffers   Crossbones+   -  Reputation: 1542

Like
0Likes
Like

Posted 08 December 2006 - 11:49 PM

As Nik02 pointed out - searching and pathfinding algorithms such as A* are independent of a multimedia technology such as DirectX. Or, more specifically, there is nothing in the DirectX suite that is directly related to A* implementations therefore this thread is better served by another forum - I'm moving this to AI [smile].

Also, I strongly suggest that you do some more research into example code - path finding is a very thoroughly covered subject. There are a huge number of books devoted to the subject and I've got several gaming-specific books on my shelf that discuss A* and related topics.

Cheers,
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

#5 StratBoy61   Members   -  Reputation: 232

Like
0Likes
Like

Posted 08 December 2006 - 11:52 PM

Quote:
Original post by Altaf
I am working on building my own code. Hopefully I`ll finish it soon, but I need a working code for reference.

You can check out this link. It has binary and source code (chapter5 is about path finding).
I find "Programming Game AI by Example" to be a pretty good book, and I would recommend you to buy it if you want to learn further AI techniques.
Cheers
StratBoy61

#6 Altaf   Members   -  Reputation: 122

Like
0Likes
Like

Posted 08 December 2006 - 11:54 PM

Thanks a lot guys....

#7 wodinoneeye   Members   -  Reputation: 878

Like
0Likes
Like

Posted 09 December 2006 - 05:58 PM

Quote:
Original post by StratBoy61
Quote:
Original post by Altaf
I am working on building my own code. Hopefully I`ll finish it soon, but I need a working code for reference.

You can check out this link. It has binary and source code (chapter5 is about path finding).
I find "Programming Game AI by Example" to be a pretty good book, and I would recommend you to buy it if you want to learn further AI techniques.
Cheers
StratBoy61




Amazing that they have all that soutce online ....


This one also looks like it has A* source code
http://www.wordware.com/files/games/


#8 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 12 December 2006 - 04:23 AM

http://www.google.com

or

http://www.please-do-my-homework-assignment.for.me.com

#9 Asbestos   Members   -  Reputation: 169

Like
0Likes
Like

Posted 12 December 2006 - 05:22 AM

Quote:
Original post by Anonymous Poster
http://www.please-do-my-homework-assignment.for.me.com

There's no need to assume bad faith. Someone working in DirectX is far more likely to be making a game than taking an AI class.



#10 Steadtler   Members   -  Reputation: 220

Like
0Likes
Like

Posted 12 December 2006 - 05:56 AM

Quote:
Original post by Anonymous Poster
http://www.please-do-my-homework-assignment.for.me.com


Amazingly, that website *is* valid, altough its the same as just www.me.com.


#11 ursus   Members   -  Reputation: 205

Like
0Likes
Like

Posted 14 December 2006 - 08:53 AM

Hi,

I was trying to work out the A* alghoritm not too long ago myself.

Please check this thread:


http://www.gamedev.net/community/forums/topic.asp?topic_id=420517


At my last post I attached something I invented that day. It's far from perfect as it lacks saving final path, 'no path vavailable' check, no boundaries check etc. but it is working fine.

Hope that helps a bit

#12 Palidine   Members   -  Reputation: 1281

Like
0Likes
Like

Posted 14 December 2006 - 09:08 AM

Quote:
Original post by Altaf
Thanks a lot guys....


They did actually give you quite a bit of help, you know. Programming is not about copy-pasting tutorials and piecing a game together. It's about understanding algorithms and being able to code them yourself. You've gotten to the point in your game (if you're looking for A* code) where you can't copy-paste tutorials anymore. Everything from this point forward is going to be writing code that works with your engine. So... read the algorithm descriptions and write it. It'll take you a few days, but it's really not that hard.

And as mentioned DirectX is zero-percent related to A*. DirectX is rendering. A* is game-logic. Game logic should never be dependant on rendering. i.e. you can write A* code for a game that uses DirectX and then switch the engine to openGL and not have to touch a single line of code in your A* code.

The format of the A* grid, for instance, is going to be dependent on how your level geometry works.

Anyway, did you have questions specifically about how the A* algorithm works? Are there parts you don't understand that are preventing you from coding it?

-me

#13 Altaf   Members   -  Reputation: 122

Like
0Likes
Like

Posted 14 December 2006 - 08:05 PM

I wrote a working code. My problem is the returned path is correct but not the shortest path. I guess my parent list has a problem.

#14 Exab   Members   -  Reputation: 148

Like
0Likes
Like

Posted 15 December 2006 - 10:15 AM

Or your heuristic is not correct, if your heuristic is too high or too low you won't get the best results. If you always set your heuristic to 0, do you get the shortest path?

Try not to compute your heuristic, so that the A* formula F = G + H is F = G, that way your algorithm will become Djisktra's, it will search alot more nodes, but it should give you the shortest path. If it doesn't, check your parents, etc.. if you do get the shortest path.. make sure your heuristic is good.

#15 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 30 December 2006 - 05:02 AM

http://www.cs.ualberta.ca/~games/pathfind/libpathfind/0.1.0/doc/index.html

This is exactly what you need. I use it and it's great!

#16 Altaf   Members   -  Reputation: 122

Like
0Likes
Like

Posted 02 January 2007 - 12:09 PM

Thanks a lot .....

#17 0&1   Members   -  Reputation: 99

Like
-1Likes
Like

Posted 15 April 2011 - 01:46 PM

Developing Games in Java by Laurence Vanhelswue will definitely help you getting to learn many AI techniques.
Also I will create a C++ version of A Star path finding on my site http://www.01fes.com/




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS