Dynamic A* Pathfinding 3.2
- Rook Zimbabwe
- Addict
- Posts: 4326
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
-
- Enthusiast
- Posts: 480
- Joined: Thu Jul 27, 2006 4:06 am
Question: why did you use .c (character) instead of .b for the speed field on the player structure? you also seem to use .c for a lot of things, know that if I compile as unicode those characters will be 2 bytes long and not 1 byte as .b is. I know they're unsigned but what's wrong with using .b? If it's due to the debugging "issue" then do & $FF and it should debug just fine, shouldn't it?.
Aside from that I loved the updated code - I just wanted to point that out though
Oh, another question: is it faster or slower than before?. I remember you were using PB arrays before the dynamic code, any possibility of a benchmark?
Aside from that I loved the updated code - I just wanted to point that out though
Code: Select all
Macro DebugB(_var_) : Debug _var_ & $FF : EndMacro
Define.b var = 231
Debug var
DebugB(var)
should I bash the keyboard and give up?
There isn't too much of a speed difference in the newest version, if anything, it will be slightly faster because of some small optimizations I made, this was mostly a bug fix update. I'll remove most of the chars, I don't remember why I used them, besides the priority array which I wanted to be from 0-255.
I love Purebasic.
- zxtunes.com
- Enthusiast
- Posts: 375
- Joined: Wed Apr 23, 2008 7:51 am
- Location: Saint-Petersburg, Russia
- Contact:
Yes of course, you can technically use it in any environment, I meant that there's no support for the Z axis. Although, adding the third axis in the form of 2d 'layers' or 'floors' should be fairly trivial. I'll probably end up adding that in the future since the game I've been making with this will need it eventually.Inner wrote:It could work in 3d you'd just lose your Z axis, which you could fake by having the object detect ground level on the Z axis, or am I over reaching here?Heathen wrote:This engine is 2d only.inner wrote: how would this work in 3D?
I love Purebasic.
- Rook Zimbabwe
- Addict
- Posts: 4326
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Re: Dynamic A* Pathfinding 3.2
Also decided to try this method, but in the example of a lot of unnecessary.
Wrote a simple example, for myself, to see how it works. Maybe someone will need it.
Wrote a simple example, for myself, to see how it works. Maybe someone will need it.
Code: Select all
InitSprite()
XIncludeFile "pathfinding.pbi"
#tilesize = 20: #width = 35: #height = 30
Global Dim blocked.c(#width-1,#height-1): For i=1 To 200: blocked(Random(#width-1),Random(#height-1))=1: Next
pathfind.pathfinding_structure
pathfind\Width = #width: pathfind\height = #height: pathfind\blocked = @blocked()
mnstrX=0: mnstrY=0: blocked(mnstrX,mnstrY)=0
plrX=20: plrY=15: blocked(plrX,plrY)=0
path=get_path(mnstrX,mnstrY,plrX,plrY,pathfind): pathsize = path_get_size(path)
OpenWindow(0,0,0,640,480,"Example",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0),WindowHeight(0),0,0,0)
Repeat: StartDrawing(ScreenOutput()): DrawingMode(4)
For i=0 To #height-1: For j=0 To #width-1: If blocked(j,i)=1: col=#White: Else: col=#Gray: EndIf
Box(j*#tilesize,i*#tilesize,#tilesize,#tilesize,col): Next: Next
For i=0 To pathsize-1: Box(path_get_x(path,i)*#tilesize,path_get_y(path,i)*#tilesize,#tilesize,#tilesize,#Red): Next
Box(mnstrX*#tilesize,mnstrY*#tilesize,#tilesize,#tilesize,#Yellow): Box(plrX*#tilesize,plrY*#tilesize,#tilesize,#tilesize,#Green)
StopDrawing()
FlipBuffers()
event = WaitWindowEvent(1)
Until event = #PB_Event_CloseWindow
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
Re: Dynamic A* Pathfinding 3.2
Hi,
Could you explain what you mean by "dynamic" ?
thx
Could you explain what you mean by "dynamic" ?
thx
There are 2 methods to program bugless.
But only the third works fine.
Win10, Pb x64 5.71 LTS
But only the third works fine.
Win10, Pb x64 5.71 LTS
Re: Dynamic A* Pathfinding 3.2
Is anybody can answer my question please ?
Does your dynamic pathfinding means you use a reservation table for cooperative pathfinding of multi-agents to prevent collisions ?
Does your dynamic pathfinding means you use a reservation table for cooperative pathfinding of multi-agents to prevent collisions ?
There are 2 methods to program bugless.
But only the third works fine.
Win10, Pb x64 5.71 LTS
But only the third works fine.
Win10, Pb x64 5.71 LTS