PathFinder

Started by JpSoft, Mon 20/04/2009 13:05:27

Previous topic - Next topic

JpSoft

I want know if there is a limitation in the size of one room in order to the build-in pathfinder works properly. I hace a large room (2400x1700) where the pathfinder looks like is working unproperly. I checked al the walkable areas and the script and everything is ok (actually, the game works perfect in a big room with all the room area selected as walkable area) Its possible that it is an AGS BUG?

I also created a function to change the view of NPCs when they enters into a region, but when they change, the player starts to move very fast. The view is exactly than the previos one, so i dont understand why, specially because there are another function to change the views when you select them.

Any ideas?

Jp

SSH

I think you need to give some more detail. "Working unproperly" is too vague. Do you have any narrow walkable areas? What goes wrong, when?

Also, the speed of walking can be affected by the number of frames/animation speed of a view.
12

GarageGothic

#2
According to the AGS Tidbits & Snippets (whether they're up to date or not, I don't know), the pathfinder uses an array of 1400 rows, so the maximum room height is 1400 pixels (2800 in hi-res rooms, I don't think using hi-res coordinates affects the pathfinder resolution). In theory, there's no width limit.

JpSoft

#3
I will detael the problem:

Using AGS 3.1.2 SP1, Windows XP SP2 (NET framework updated).
Game is 640x400 16 Bits color; i used hi-res coordinates until now without problems.

NPCs are in Room -1 until you move them from one city (objects) to another(is a RTS game). When you send a unit, the script checks if you can move it (you only can move 4 at the same time); if so, the new unit is placed in the center of the object you have selected and sent to the center of the target. Objects are not solid since i also had troubles with BlockingHeight and BlockingWidt as i mentioned in another post. (I dont know how to put a link here). When the unit reach their target the script place it (the character)again in room -1.

One of the rooms have more than 1400 pixels height, but since is for Random maps only (objects are positioned randomly each time) all the room is walkable and the game works perfect AFAIK.

The room where i have troubles is a predefined scenario, and walkable areas are very specific (you cant move units over the rivers, mountains...) All the walkable area have more than 5 pixels of width (i remember i read something about this some time ago). Now, everything works properly, but when i send a unit from the bottom-lef to the top-right corner (or viceversa) the game "STOPS" many seconds (around 10) and then it move the unit inmediately to the target (actualy, the NPC is never shown) AGS asumes that the unit arrives at the same time you send it  ??? I verified everything and all is ok; even, if i make all the room walkable everything works ok like in the other room  ::)

As for views: Default view of the units (NPCs) is 2. You can select one when is moving to know how many troops it contains, and then view change to 3. Now, in predefined scenarios, i created a function like this:
Code: ags

if (Region(GetAtRoom(character[x].X,character[x].y) == 1) character[x].changeview(7);
else character[x].changeview(2);


So view of NPCs will change to 7 when they enter into region 1. The character changes its view, but now it starts moving FAST, ignoring any delay i specify. I check the view and is identical to views 2 and 3 (working perfect) Here, i dont have idea what is going wrong.

Jp

PS: I believe that 1400 array for pathfinder was removed in a recent version.

EDIT: Each view have 7 loops (1 for dierction) and each loop have 2 frames with a delay 0. Movement delay of NPCs is 10, and uniformmovement is set to true.

Pumaman

Quote from: JpSoft on Mon 20/04/2009 15:49:55
Now, everything works properly, but when i send a unit from the bottom-lef to the top-right corner (or viceversa) the game "STOPS" many seconds (around 10) and then it move the unit inmediately to the target (actualy, the NPC is never shown) AGS asumes that the unit arrives at the same time you send it  ???

The AGS pathfinder is designed to work with normal sized rooms (eg. 640x480); since your room is 2400x1700 I'm not surprised that it's taking a long time to calculate the route. The fact that the unit is moving immediately to the target probably indicates that the pathfinder has run out of memory or given up on trying to find a route.

If you'd like to upload a game that demonstrates the problem then I can investigate it for you, but it's probably just that the room's walkable area is too large and too complex for the pathfinder.

You could consider only moving half the screen at a time, or manually providing some routes using AddWaypoint instead of using the pathfinder.

QuoteAccording to the AGS Tidbits & Snippets (whether they're up to date or not, I don't know), the pathfinder uses an array of 1400 rows, so the maximum room height is 1400 pixels

Just to clarify, that is out of date. That height limit was removed in AGS 3.1 and there is now no fixed limit (although as JpSoft has discovered, the pathfinder doesn't scale well to huge rooms).

Trent R

Since you're programming an RTS (right?), a pathfinder should probably be on your to-do list. You could probably find some tuts online for various languages, to get the gist of it.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

You could use a walkable area resized to half the size and have an invisible dummy walk it.
-On the click, divide the coords by two, send the dummy on its way non-blocking and animate/move the actual character using the dummy's coords times two.

JpSoft

QuoteSince you're programming an RTS (right?), a pathfinder should probably be on your to-do list. You could probably find some tuts online for various languages, to get the gist of it.
Yes, it can be done, but could be very useful if the build-in one works.

QuoteYou could use a walkable area resized to half the size and have an invisible dummy walk it.
-On the click, divide the coords by two, send the dummy on its way non-blocking and animate/move the actual character using the dummy's coords times two.
A very nice idea. Thanks for the sugerence. Maybe i will try with waypoints first.

Jpsoft

JpSoft

I worked a lot on this days with this issue and i could confirm that the build-in pathfinder do not work properly, even in rooms with less than 1400 pixels high if the walkable areas are complex (like highways) I get some "i could not expect that" moves, like the player moving inmediately to another position and start moving to another direcction and so.

Im creating an example game to show those malfunctions, but if anyone else had this kind of troubles too please let me know how you solved this.

JP

PS Anyway, the pathfidner works ok in every room i tried if all the room is walkable.

Pumaman

Did you resolve this in the end? Have you checked that the room edges are set correctly?

Stacy Davidson

#10
Quote from: Pumaman on Sat 08/08/2009 15:49:14
Did you resolve this in the end? Have you checked that the room edges are set correctly?

I began reading this post because I was having the same issue.  Low and behold, I read about the edges, checked my room, and sure enough the edges were set WAY off, so that essentially none of the walking area ended up within the boundaries of the edges.  After fixing them, I have not been able to repeat the bug, so that's a good sign.  I only got stuck on that room occasionally, so time will tell if it truly worked or not, but I have a very good feeling that was the problem all along.

Thanks!
-Stacy Davidson
Jack Houston and the Necronauts
Warbird Games
www.warbirdgames.com

Jim Reed

#11
I did a 640x480, non scrolling room, and the pathfinder moves the character instantly to a random place in the room, if I click it fast enough. The reason for that, I think, that I was overburdening the cpu by rendering ~4800 16x16 sprites every game loop (gamespeed(60), it ran at~15fps).
Maybe it's not about screen size?

Edit:
16bit colour, latest version of AGS.

Pumaman

Quote from: StacyDavidson on Sat 08/08/2009 19:35:42
I began reading this post because I was having the same issue.  Low and behold, I read about the edges, checked my room, and sure enough the edges were set WAY off, so that essentially none of the walking area ended up within the boundaries of the edges.  After fixing them, I have not been able to repeat the bug, so that's a good sign.  I only got stuck on that room occasionally, so time will tell if it truly worked or not, but I have a very good feeling that was the problem all along.

Glad to hear it -- since it seems like this problem is fairly widespread, I think I'll make some changes to the next version of AGS so that it doesn't rely on the edges so much for the pathfinding.

QuoteI did a 640x480, non scrolling room, and the pathfinder moves the character instantly to a random place in the room, if I click it fast enough. The reason for that, I think, that I was overburdening the cpu by rendering ~4800 16x16 sprites every game loop (gamespeed(60), it ran at~15fps).
Maybe it's not about screen size?

Were your room edges definitely set correctly? :)
It shouldn't matter how burdened the CPU is, the pathfinder should still behave the same way. If you can upload something that demonstrates this problem I can look into it.

Jim Reed

I don't know about the edges, but it doesn't matter, because I scraped the room anyways and the engine has changed, so I can't upload it either.
If I run across the same problem again, and you don't find what's wrong with the pathfinder untill then, I'll let you know. Sorry.

SMF spam blocked by CleanTalk