Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Triangular grid for pathfinding

Author
Message
Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 22nd Nov 2011 18:17 Edited at: 22nd Nov 2011 18:20
I am trying to make triangular grid for pathfinding but it is kinda difficult to generate it.

What I have is:

1) Node


2) not working properly grid generator



3)pathfinding algorithm



Algorithm works like this:
1) start node is put into search list
2) while search list isn't empty, limit og steps isn't reached or end node wasn't found
every nodes in search list every connection is checked and if not already searched and walkable it is added into search list (stack)
3) if end node reached, from it algorithm traces previuos nodes back to start node and puts into queue.

problem is that I can't calculate connections. I though at first my nodes are placed in shifted lines

1 2 3 4
_5 6 7 8
9...

but it came out that they are placed in two rows

1 3 5
_2 4 6
7 9 11
_8 10 ...

It took long time to write algorithm to connect nodes in shifted rows... I don't know if it is possible to write it for rows of two shifted rows Looks like a hard candy. Anyone will help with that?
Any advice appreciated

PS If You try running program:
select unit/make it move with mouse
move camera with arrows/wasd
rotate camera- hold middle mouse button and move around
red nodes are obstacled or already checked
green are in earch list
You will need to press any key to advance because I put some stop functions to see step by step process of pathfinding
sms(string) and smsf(float) prints text and waits key
because connections are set not to adjacent nodes, random nodes are added into search list. Green nodes should spread like a ring around unit.

Join The dark Side! We have cookies
Kiaurutis
15
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 1st Dec 2011 14:23
Haven't anyone tried to make triangular grid?
Forever alone.....

Join The dark Side! We have cookies
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 1st Dec 2011 14:57
I have an algorithm in C that does exaclty that. I haven't looked to convert it to DBpro. If no one has answered by this afternoon... (when I wake up... I work overnights) I'll post a conversion.

~ZENassem

Login to post a reply

Server time is: 2026-07-10 03:59:32
Your offset time is: 2026-07-10 03:59:32