Pathfinding

Blitz3D Forums/Blitz3D Programming/Pathfinding

Zach3D(Posted 2006) [#1]
I need help with pathfinding in 2D and 3D



the first help i need with pathfinding is for a pacman like game

heres an example
Function UpdateGhost(G.ghost)
Select G\state
case STATE_ALIVE
G\xv = PathFindXV(G) ; I need help writing these
G\yv = PathFindYV(G) ; 2 Functions
G\x = G\x + G\xv
G\y = G\y + G\yv
Case STATE_BLUE ;Ghosts turn blue and edible
G\xv = PathFindEscapeXV(G) ; And i need help with these
G\yv = PathFindEscapeYV(G) ; two functions
G\x = G\x + G\xv
G\y = G\y + G\yv
Case STATE_DEAD
KillGhost(G)
End Select
End Function

;====================================================
Ok So for this code above I need help writing the PathFindXV and PathFindYV functions, which are supposed to tell the ghost which direction to go based on where pacman is in the game.








And for a 3D Game i would just like a short sample on how you would have a Ball and a wall just like this:
|||X
O | |
| |


And the ball is told to move to point X
like this:

Function OrderObjMove(SomeEntity,x,z)
Repeat
;Repeat moving the entity toward point X, avoiding collision
;with the wall by moving around it
Until (EntityX(SomeEntity) = X and EntityZ(SomeEntity) = Z)
End Function


How would I go about making the ball swerve around any collisions it would come upon?


I know this is long but thanks for any help.


octothorpe(Posted 2006) [#2]
[code]


Sledge(Posted 2006) [#3]
I suspect you might be asking a bit more than you realise. However, most of your needs can be met via a system that allows ghosts to move to any designated* tile - be it the one Pac-Man occupies or their "home corner" (for scattering). Personally I would ping the map: Consider a fresh "ping map" of the play tiles with all entries set to zero. Now you set the target tile to a value of one, and each pass you increment the ping value of each free adjacent tile to the ones you just filled in. Eventually you end up with a completed ping value map upon which you can trace back to the target tile from any other tile simply by looking for an adjacent entry with a lower ping value than the one you are currently on.

"Home Corner" ping maps can be pre-calculated for each ghost, obviously, and the realtime one (for tracking Pac-Man) shared between all ghosts and built up over several loops to keep the speed up. A ghost that can actually see the player doesn't even need to refer to the ping map, naturally.

That would be my approach, anyway.


*How exactly you designate a tile would depend on the personality of the ghost in question.


Zach3D(Posted 2006) [#4]
I rather have an introduction tutorial to pathfinding than the link you sent sledge.
Something thats more of an open system


Sledge(Posted 2006) [#5]
Try this, then. Followed by this.

EDIT: Oh, the images are borked in that archive. Alternatively:

Part 1
Part 2