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.

AppGameKit Classic Chat / Pathfinding in Tier 1

Author
Message
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 5th Jun 2012 19:20
Over my morning coffee decided to add some debug info (the Mouse Debug Info) so that it would show the ParentX and ParentY to be sure everything was correct. Funny thing was all the Parent Info was set correctly.

Decided it had something to do with tracing the path.

Changed this when tracing the path.


Works great now, some sort of offset bug going on. May have something to do with the screen percentage system. (One of the reasons I like using SetVirtualResolution, so I can work in pixels.)

I have also attached the version I was working with, Changed things around a bit, but the part that should be useful is how the OpenList was implemented. That way you do not need to search the entire map for the best F score. On my Android Tablet, getting and average of 0.05 seconds to find a path. Can get upto 0.20 seconds in certain areas, such as to the right of the right most building.

Attachments

Login to view attachments
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 5th Jun 2012 20:20
Hmm, that almost worked, But there is one "small" problem with it. If the path goes next to a closed tile, the tile won't have a parent and it gives me the subscript out of bounds error.

Oh and thank you for the help as allways!
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 5th Jun 2012 20:27
Yeah, was getting that also...try changing this.

ELSE
CurrentY = Nodes[CurrentX+1, CurrentY].ParentY
ENDIF

to,

ELSE
CurrentY = Nodes[CurrentX, CurrentY].ParentY
ENDIF


That was the way I expected it to work, but for me I had to do that the first way and stopped getting the subscript error. If it still does not work, see if the version I posted and was working with does it also.
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 5th Jun 2012 20:49
Nope, I already tried it, and it didn't help.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Jun 2012 20:54
You probably need a check to see if ParentY (or ParentX) has a valid value before copying it.

When you create the Nodes, what to you put in Parent<x/y> for when a node is next to a closed one?

Cheers,
Ancient Lady
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 5th Jun 2012 22:15 Edited at: 5th Jun 2012 22:18
This is very odd. The only way I can get a subscript out of bounds error is by clicking somewhere on one of the buildings. Can click a spot right next to the building and follows the perimeter and then straight to the start.

The only thing that comes to mind is that something is being calculated with the Display Aspect Ratio which is causing issues based on screen size. This is what it seems like, could be something else entirley.

EDIT:

Try SetDisplayAspect(4.0/3.0) and then in your setup.agc set the window size to 800 x 600. See if you still get the subscript error.
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 5th Jun 2012 22:57
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 5th Jun 2012 23:00
Quote: "The only way I can get a subscript out of bounds error is by clicking somewhere on one of the buildings. "


That's caused by me not checking if the node in the building is walkable I think.

Try placing one of the buildings in the top right corner and find a path from the right side of it... That's the problem im having
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 5th Jun 2012 23:16
Ok, are you talking about this...




or something like this...

The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 5th Jun 2012 23:34
No, leave some space in the corner

Replace the spriteloading code with this
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 6th Jun 2012 01:03
I see now. Once again this is something with the path trace. The Parent Information is correct and doing what it did befor. Need a conditional statment if the path CurrentY is above or below the start (or middle of screen). I am very sure it has something to do with the display aspect being miscalculated somewhere.

Since all the parent information is correct. There is no reason why it should not be able to trace the path the original way you had it. Something is off somewhere.
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 6th Jun 2012 16:59
Heres a version with SetVirtualResolution and using fixed values for everything, working good this way. I think it was something with the SetSpriteScale and Display Aspect not giving whole numbers back when they were rounded would give + or - 1 causing problems.

Attachments

Login to view attachments
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Jun 2012 18:08
That looks pretty cool.

Cheers,
Ancient Lady
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 6th Jun 2012 20:49 Edited at: 6th Jun 2012 20:53
Wow, you realy rewrote a lot of the code, seems to work perfect now and it seems to be 10 times quicker now! Unless you try to find a path to behind the second building, it's quick enough to be used on android. Now I just have to make a way to save the path. Luckily. School ends this friday so I'll have more time to work on this.

Thank you so much for the help!

Login to post a reply

Server time is: 2024-11-23 15:26:14
Your offset time is: 2024-11-23 15:26:14