Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,369 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 12 1 2 3 4 11 12
Re: ez_path -- for alpha testing! Simple Pathfind [Re: mk_1] #44591
04/19/05 17:47
04/19/05 17:47
Joined: Mar 2002
Posts: 580
San Francisco
clone45 Offline OP
User
clone45  Offline OP
User

Joined: Mar 2002
Posts: 580
San Francisco

Hello!

Bird, the location of the next node in the path is placed in the following skill slots:

// my._PF_NEXT_NODE_X = x coordinate of the next node to follow
// my._PF_NEXT_NODE_Y = y coordinate of the next node to follow
// my._PF_NEXT_NODE_Z = z coordinate of the next node to follow

(these are defined as...)

DEFINE _PF_NEXT_NODE_X, skill91;
DEFINE _PF_NEXT_NODE_Y, skill92;
DEFINE _PF_NEXT_NODE_Z, skill93;

Also, I haven't tested out the speed of my algorithm, but it should be fast.
Here's the C++ code that traverses the nodes. (This is my own code.)

Code:

// This function contains a recursive call, which makes it particulary
// difficult to document. However, the general idea is to visit each node,
// all the while keeping track of the distance travelled. If the destination
// node is found, then that distance is returned. Otherwise, max distance
// is returned.

// while the nodes are being traversed, their "visited" flag is set so that
// nodes are not traversed twice (which would result in an infinite recursion)


int pf_next_node_ex(pf_node *node, pf_node *end_node, int dist)
{
pf_node *neighbor;
int path_length;
int shortest_path_length = 1000;
int t;

if (node == end_node) { return(dist); }
if (node->visited_flag == 1) { return(1000); }

node->visited_flag = 1;
dist++;

// Foreach path available from this node, find the path's length. Store
// the shortest length.

for (t=0; t<4; t++)
{
neighbor = node->pfp_neighbors[t];

if (neighbor != NULL)
{
path_length = pf_next_node_ex(neighbor, end_node, dist);

// A path length of 0 indicates that there's no route to the
// destination.

if ((path_length > 0) && (path_length < shortest_path_length))
{
shortest_path_length = path_length;
}
}
}

node->visited_flag = 0;

return (shortest_path_length);
}



But in all honesty, it's not the pathfinding that's going to slow you down... it's the helper code that you write that's involved in walking the path. It can get pretty tricky. My code handles a lot of that irritating code, like choosing the proper "first node" to take, behind the scenes. Hopefully that extra code didn't slow things down too much!

- Bret

Re: ez_path -- for alpha testing! Simple Pathfind [Re: clone45] #44592
04/19/05 18:03
04/19/05 18:03
Joined: Dec 2000
Posts: 4,608
mk_1 Offline

Expert
mk_1  Offline

Expert

Joined: Dec 2000
Posts: 4,608
Looks like Dijkstra's algorithm.
However it is completely different to my pf.


Follow me on twitter
Re: ez_path -- for alpha testing! Simple Pathfind [Re: mk_1] #44593
04/19/05 18:53
04/19/05 18:53
Joined: Oct 2003
Posts: 2,628
IL,US
FeiHongJr Offline
Expert
FeiHongJr  Offline
Expert

Joined: Oct 2003
Posts: 2,628
IL,US
Very Nice great job. Looked over the documentation breifly seems to be very well explained as well. I have a quick question . Would it be possible to have different target entitys for differnt models? ex.. I would like to be able to have Guy A go to point A and Guy B to point B. Then could i change that during runtime? so guy A goes to B and vice versa? also is it possible to use this to make two seperate paths included into one level? So for example one path set for vehicles and another path for pedestrians. Sorry for all the questions just curious. It really looks good . Thanks alot.


http://www.freewebs.com/otama_syndicate/index.htm - Each master to his own technique.

- Not me said the bee, Nor I said the fly.
Re: ez_path -- for alpha testing! Simple Pathfind [Re: FeiHongJr] #44594
04/19/05 20:11
04/19/05 20:11
Joined: Mar 2002
Posts: 580
San Francisco
clone45 Offline OP
User
clone45  Offline OP
User

Joined: Mar 2002
Posts: 580
San Francisco
FeiHongJr,

It should be possible to have 10 entities with 10 different targets... some of which can be the other entities! I haven't tested that yet, and if anyone wants to give it a shot, be my guest! You can change targets at runtime, no problem.

The future version should allow you to move to a target position instead of an entity. The future version should also allow you to put a cap on the maximum path distance, in case your level contains a lot of nodes.

Let me give some thought to the "multiple paths" problem. It sounds possible, but it's not currently supported by the code.

Thanks for the feedback!
- Bret

Re: ez_path -- for alpha testing! Simple Pathfind [Re: clone45] #44595
04/19/05 20:58
04/19/05 20:58
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline
Expert
Rhuarc  Offline
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Might wanna give it an A* version, would add even more to the performance and make it ideal for huge maps, although the dijikstra method you do here works too ; A* just has the hueristic in it. Any chance you'll release the full source? it would be good grounds to develop more onto.

-Rhuarc


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Re: ez_path -- for alpha testing! Simple Pathfind [Re: Michael_Schwarz] #44596
04/19/05 21:13
04/19/05 21:13
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
Quote:

Could you make anothher version of the DLL that works with A5?




could you answer that question?


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: ez_path -- for alpha testing! Simple Pathfind [Re: Rhuarc] #44597
04/19/05 21:15
04/19/05 21:15
Joined: Mar 2002
Posts: 580
San Francisco
clone45 Offline OP
User
clone45  Offline OP
User

Joined: Mar 2002
Posts: 580
San Francisco

Hi Rhuarc,

I'm considering having a free, fully functional "lite" version, and a more full featured version for $10. Because of that, I probably won't be releasing the full source. However, if there are sections of it that would be helpful to other people, I'd be happy to share!

- Bret

Re: ez_path -- for alpha testing! Simple Pathfind [Re: clone45] #44598
04/19/05 21:24
04/19/05 21:24
Joined: Mar 2003
Posts: 4,264
Wellington
Nems Offline

.
Nems  Offline

.

Joined: Mar 2003
Posts: 4,264
Wellington
Cany check it out, it keeps telling me "no valid acknex dll."
Any idea whats happening here ?

Re: ez_path -- for alpha testing! Simple Pathfind [Re: Nems] #44599
04/19/05 21:36
04/19/05 21:36
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
Quote:

Cany check it out, it keeps telling me "no valid acknex dll."
Any idea whats happening here ?




thats what i also get with A5 (A5 com 5.52)

could you, clone45, please answer my question too?


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: ez_path -- for alpha testing! Simple Pathfind [Re: Michael_Schwarz] #44600
04/19/05 21:54
04/19/05 21:54
Joined: Mar 2002
Posts: 580
San Francisco
clone45 Offline OP
User
clone45  Offline OP
User

Joined: Mar 2002
Posts: 580
San Francisco
Quote:

"Could you make anothher version of the DLL that works with A5?"




I'll see what I can do! If it means I need to regress back to the old API... it'll be a while before I can do it. Sorry for the slowness in my responses. I'm still being punished for going out drinking last night. ... ooo my head...

Page 2 of 12 1 2 3 4 11 12

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1