pathfinding crashes

Member
Posts: 196
Joined: 2002.04
Post: #1
I need some help. I've been stumped on this code for a week now. I'm trying to create pathfinding for multiple objects moving at one time on a 2d grid. The problem is the moving objects run through each other or crash the app for no reason. Here's the code:
http://www.solarfusionsoftware.com/developer/grid.zip

Movement is the class that has all of the pathfinding stuff is in.

The - (void)findAPath searches for the path and seems to do fine.
The - (void)updateMovement: (int)objectPath tries to figure out if the object can move. If the object runs into another object it stops and tries to create a new path.

Use the mouse to select the arrow objects and hold down the z key while clicking to have multiple arrow objects selected. To make the objects move click a tile on the grid.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
Ive got it so that while the commanders are moving around they sometimes put an imaginary block infront of them and walk round it, all I need to do is make it do is change it so instead of randomly it does it when theres another commander in the way.

But I feel odd working with that strange code and ive not slept in ages so im going to play EV for a bit and have another look in a minute Wacko .

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #3
Ok I thought I had it but im confused, I got it so that if two commander come into contact in during thier movement across thier paths one would stop and the other would find a new path. The problem though is that it didnt find a new path to where it was going to to where to mouse currently is.

The method im trying to implement is to place a block where the 'collision' has occured and then they both pathfind round it, it seems to work if I only knew how the methods youve written worked slightly better, its quite interesting working "in the dark" though so ill have another look in 2 mins.

Grin

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #4

http://www.geocities.com/ed72678954/Movement.zip

Ok why dont you have a look at how ive defaced your program so far, try putting one commander in the top right and one in the bottom right. Move the top one down about 20 squares and then select the bottom one and move it up so that it will end up on the path that the other commander is following, They will travel towards each other and when they hit, one will stop and one will find a new path to where it was going (unless youve moved the mouse in which case it goes there).

Theres a commented out bit that starts (rand()%10 ==0) that was me testing to see how you would make a commander find a new path.

Hope this helps in some way....
I didnt manage yet Cry .

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 196
Joined: 2002.04
Post: #5
Thanks I got it working. Now I just need to optimize it a whole lot. Pathfinding is really slow for even medium range paths.
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #6
Heuristics (educated guessing kind of) speed up pathfinding, Lookup A-star (A*).

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  pathfinding for skating game in VC tenpenny 1 4,323 Sep 2, 2011 09:31 PM
Last Post: PoseMotion
  Maps Pathfinding Nodes jigzat 10 4,738 Jun 17, 2008 02:58 PM
Last Post: jigzat
  pathfinding, special case... blazer 8 4,814 Sep 27, 2005 12:40 PM
Last Post: GoodDoug
  I'm going CRAZY!!! Random crashes without reason akb825 3 3,603 Aug 18, 2005 03:46 PM
Last Post: akb825
  My game crashes on quit... hangt5 17 8,451 Jan 30, 2005 09:38 PM
Last Post: hangt5