I'm writing a tile-based rpg, and I need an algorithm that finds the shortest path from one tile to another. I've been looking around for many things and all I could find was stuff written in C++ that was too complicated to read.
The only type of tiles are either walkable or non-walkable, so there are no varying speeds or anything. I just want some simple VB code that works. It doesn't have to be the fastest or the best, as long as I can use it.
Any help would be appreciated, thanks!
Darkwraith: You fancy writing a flow blown procedure to find a path like he described?? By this I mean a procedure that would find the best way to get from one tile to another avoiding walls and avoiding hanging to walls, i say this because you seem the helping type and as you said before you bring up these threads to help others that might have similar problems , hey it could be fun , what you say??
Are you working on a project at the moment??
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
I could do the algorithm, but probably not the code.
I am working on a few projects to learn programming languages better. If it is VB, I could probably work on it, albeit it might take a few weeks (Project MagicBase is not working out to well. A respite from it would be nice.)
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
you mean the path finding thing, he was asking for VB he said he only found C++ soruces which were no good . if you could do the algorithm I could probably do the code.
I'm currently working on a game and its almost finished. When I say almost finished I mean the code, I have to make the levels after that which isn't gona be easy for me considering I can't draw on a PC to save my life .
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
Posts
3,051
As luck would have it, i've been doing something very similar (tile-based shortest path finding algorythm based on the A*).
I wrote it in VB, as my C++ isn't too hot, but i'd emagine it could easily be ported.
I first created the A* algorythm as it stood (no modifications - just an implimentation). My Monsters ran the algorythm each time they wanted to move. I found this to be quite CPU intensive - mainly when there was no path).
I decided to create an array, storing a direction to move in, given a source and a destination.
This means that the monster simply looked at it's position, and it's destination, and the array would give a direction to move in (based on the best possible move).
To fill the array i used the A* algorythm over and over again.
This took several minutes on a small (25x25 grid) map. Although i could save the array to a file (and did), it was still too slow.
I then decided to refine the algorythm.
I decided to calculate all the distances from the destination (for each node). Then to get a direction from a source, it's simply the direction of a node near it (with a link to it), with the shortest distance.
At present, my AI module is a bit cluttered. (failed attempts etc), but i'll try to sort it out if you like (add more comments etc).
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
I guess your write its no a moot issue .
What is a A* anyway, is it just the type of algorithm thats used for this??
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
Posts
3,051
you're just taking the piss now arn't you Darkwraith.
That link doesn't seem to be a link.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Did he mean it to be a link?? Isn't he just saying the name of the referance to add in VB??
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
Posts
3,051
Originally posted by Electroman Did he mean it to be a link?? Isn't he just saying the name of the referance to add in VB??
Oops! Quite possibly. Guess we'll just have to wait and see.
If it is a reference to add, then u'm not quite sure of it's usefulness as it is so old.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
It's an excellent reference in RTS design, not implementation. A section of it is dedicated to A* pathing, another to differences in design of tile based maps (rectangular, isometric, and hex)
Furhermore, it points out questions that you should ask yourself like how should economy be handled and gameplay issues.
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.
Oh hang on is it a book, I've just thort this because I can't imagine a VB reference would tell you all that and he never actually said if it was a VB reference, as in .dll)
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
Remember that old adage: "Give a man a fish, you feed him for a day. Teach a man to fish, you feed him for a lifetime." Well, "Give a man a coded algorithm, you help him for one programming language. Have him learn the concepts behind the code, you help him for all languages."
The code is old, but the concepts are not (especially the detailed look at A*.)
"Can't" and "shouldn't" are two totally separate things.
All questions should be answered. All answers should be true. That is why I post.