Jump to content


Photo

Astardll - Quick A* Algorithm Pathfinding


  • Please log in to reply
207 replies to this topic

#1 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 28 March 2007 - 01:34 AM

AStarDLL (V3)
Works in GM6 and GM7.

New Version, check the features below.

AStarDLL is a quick and easy to use pathfinding DLL that uses the A* Algorithm. It has the following features:

-Can place obstacles
-Can block off cells from certain directions (8-dir blocking)
-Can set the "costs" for moving diagonally and non-diagonally
-Can set "cost" for moving into a specific cell
-Can set "cost" for moving into a specific cell from a specific direction
-Can set whether to allow diagonal movement or not
-Can set whether to allow cutting edges of obstacles when moving diagonally or not
-Has a function that centers the object in the cells when following a path
*NEW*-Has functions to return whether a cell is an obstacle, whether a cell is blocked from a certain direction, the individual cost of a cell, and the individual cost of a cell from a certain direction.
-Request your ideas!

This DLL can get anywhere in this maze as well as anything you create:
Posted Image

The download comes with a GM6 Example (Works in GM7), AStarDLL.dll, ReadMe, and the Scripts needed. To understand the scripts and how to use them check out the ReadMe.

IF YOU ENCOUNTER A PROBLEM, TAKE A SCREENSHOT

Download AStarDLL (Reply Please :blink: )


If you encounter any errors that say "Variable astarR_anything does not exist." even though you have initialized the DLL, it is because the initialization is happening after you call those events. To prevent this, do not call anything related to the DLL in the creation events of other objects, make them on an Alarm set to 1.

If you download or use source please reply asking permission.

DELPHI SOURCE CODE: CLICK ME

Thank you for downloading!
HomebrewPC

Edited by homebrewpc, 25 September 2007 - 11:39 PM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#2 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 899 posts
  • Version:GM:Studio

Posted 28 March 2007 - 01:47 AM

In the creation code of the obstacle, you need to add this piece of code after aligning it to the grid:
astar_setobstacle(x,y);

Oh, and this needs to go in the Left click event:
astar_setfree(x,y);
instance_destroy();

Thank you so much for making this, hopefully, it will speed up detection a lot.
-DF81

Edited by DFortun81, 28 March 2007 - 01:54 AM.

  • 0

dia_rpg_builder.png
Navigate to my personal website by clicking the image above.


#3 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 28 March 2007 - 01:57 AM

Yeah, thanks for mentioning that obstacle thing, just realized that when I checked. Re upload in a minute.

Thanks and Your Welcome,
HomebrewPC

EDIT: Re-uploaded, but I have to go now, will check tomorrow.

Edited by homebrewpc, 28 March 2007 - 01:59 AM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#4 Ansgar

Ansgar

    OM Studios

  • New Member
  • 333 posts

Posted 28 March 2007 - 04:54 PM

Thanks for making this, I was also waiting for this, as I said in DFortun81's topic.
Great job.

However, when I played the example, I noticed that it freezes every time the engine takes a wrong way searching and has to return one step back (in other words: when a node is returned from the closed list to the open list). This is an example screenshot of the frozen game; the yellow cross marks the cell I clicked at.
Posted Image

By the way, I'm working on my own attempt on implementing A* Algorithm into GM, using plain GML (despite what I wrote in DF81's topic). I'll post it if it works out well.
I may be naive, but so far it doesn't seem too slow. DFortun81, did you use objects in the engine? (I use maps.)

EDIT: Holy cow, I'm almost done and it doesn't lag at all!
At the moment I've got it working in a totally unpolished user-unfriendly version, but I can still upload it if you'd like to see it. :blink:

Edited by Ansgar, 28 March 2007 - 06:37 PM.

  • 0

#5 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 899 posts
  • Version:GM:Studio

Posted 28 March 2007 - 08:02 PM

I use data structures, the only objects in the level are a controller object and the player.

I am also receiving the same error as Ansgar. It will randomly freeze when there is a path to the location that I could see, but the DLL could not.

Another small bug: When computing a path, it ignores diagonals when there are obstacles on the two cells next to the diagonal for the most part. Rather than taking the diagonal path, it goes all the way around the wall to get to the destination.
Here is an image showing this:
Posted Image
The X indicates the starting location and the circle represents the end location.

-DF81

Edited by DFortun81, 28 March 2007 - 08:03 PM.

  • 0

dia_rpg_builder.png
Navigate to my personal website by clicking the image above.


#6 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 28 March 2007 - 08:10 PM

Ansgar: I am working on that, I think it will be a simple fix. I can't do it at the moment though.

DF81: Its supposed to go all the way around. If it goes straight through the blue ball will intersect with the obstacles. I did that on purpose. I'll make this an option in the grid set script if you want.

Thanks for the comments!
HomebrewPC

Edited by homebrewpc, 28 March 2007 - 08:31 PM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#7 Ansgar

Ansgar

    OM Studios

  • New Member
  • 333 posts

Posted 28 March 2007 - 08:38 PM

OK, here is what I've put together so far: My A-Star
It's based on a Java algorithm I found somewhere on the net. It was too generic, so I first made a particular pathfinding implementation of it in Java (just for my learning purposes - I'm a Java novice) and then converted it for Game Maker. It has just 4 directions at the moment, but it's a matter of minute(s) to add the other four (by modifying the AStar_getEstimatedCost and AStar_getNeighbors scripts).

Enjoy. :)

EDIT: I updated the engine (or example or whatever you want to call it), and I'll soon probably make a new topic for it.

EDIT 2: Done. Link in my signature. :D

Edited by Ansgar, 29 March 2007 - 10:13 AM.

  • 0

#8 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 899 posts
  • Version:GM:Studio

Posted 28 March 2007 - 09:30 PM

That's a pretty cool, but the DLL supports directional checking for each cell rather than just blocked/unblocked. Good job though.

-DF81
  • 0

dia_rpg_builder.png
Navigate to my personal website by clicking the image above.


#9 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 29 March 2007 - 12:27 AM

And if you have massive grids with tiny cells, that is probably going to slow down.

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#10 9_6

9_6

    Guest

  • GMC Member
  • 3627 posts

Posted 29 March 2007 - 04:47 AM

Yet it's still better than something that keeps freezing the program because it actually works in most cases (it sometimes slips through solid blocks though).
  • 0

#11 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 29 March 2007 - 04:09 PM

Yet it's still better than something that keeps freezing the program because it actually works in most cases (it sometimes slips through solid blocks though).

<{POST_SNAPBACK}>


I know how to fix it, I haven't had the time. I will update it tonight or tomorrow.

Thanks,
HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#12 coolsmile

coolsmile

    Programmer

  • New Member
  • 1346 posts

Posted 29 March 2007 - 04:22 PM

Yeah, it did that to me also :D
I remember the first version...
  • 0

#13 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 29 March 2007 - 04:33 PM

This is the first version...what are you talking about?

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#14 Daniel-Dane

Daniel-Dane

    GMC Member

  • New Member
  • 3581 posts

Posted 29 March 2007 - 04:38 PM

The script version DF81 made :D.
  • 0

#15 Ansgar

Ansgar

    OM Studios

  • New Member
  • 333 posts

Posted 29 March 2007 - 05:40 PM

Huh, someone is definitely mixing up something here, but I'm not sure who and what... :D

By the way, homebrewpc, do you mind I used the same example layout as you in my AStar engine? If you do, I'll change it, I was just lazy. ;)
  • 0

#16 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 899 posts
  • Version:GM:Studio

Posted 29 March 2007 - 06:55 PM

The script version DF81 made ;).

<{POST_SNAPBACK}>

Yeah, it was a really slow script in my DIA RPG Engine.

Huh, someone is definitely mixing up something here, but I'm not sure who and what... :D

<{POST_SNAPBACK}>

Well not really, I made a topic a while back asking for a DLL that did A* calculations with 8 directional checking because I was tired of my path finding algorithm going extremely slow. I haven't updated the engine to include either of the new methods yet, so you can still view its horribleness if you download it.

But yeah, when you clear up the freezing bug, let me know.
-DF81
  • 0

dia_rpg_builder.png
Navigate to my personal website by clicking the image above.


#17 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 29 March 2007 - 08:11 PM

Huh, someone is definitely mixing up something here, but I'm not sure who and what... :D

By the way, homebrewpc, do you mind I used the same example layout as you in my AStar engine? If you do, I'll change it, I was just lazy. ;)

<{POST_SNAPBACK}>


Let's put it this way, if my topic turns into people talking about your script, I'm going to be mad.

I'm going to work on that freeze error now, probably won't take that long.

HomebrewPC

EDIT: Fixed all known problems, in the process of uploading.

Edited by homebrewpc, 29 March 2007 - 09:13 PM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#18 novaz

novaz

    GMC Member

  • GMC Member
  • 592 posts
  • Version:Unknown

Posted 29 March 2007 - 09:27 PM

hi, when you click with left button there's an error for global left
pressed. But the programs works :D

Edited by novaz, 29 March 2007 - 09:28 PM.

  • 0

#19 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 29 March 2007 - 09:30 PM

Crap...that's not an error. That is what the DLL returned, I was just showing it as an error so the text would not get cut off. I was using that to find where the freeze bug was happening. Ill fix that.

HomebrewPC

EDIT: Re-uploaded

Edited by homebrewpc, 29 March 2007 - 09:32 PM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#20 novaz

novaz

    GMC Member

  • GMC Member
  • 592 posts
  • Version:Unknown

Posted 29 March 2007 - 09:43 PM

thanks for the work. Unfortunately the program still freezes after some
pathfinding, if you create a little maze. Maybe there's some bug in
the example, not in the dll.
  • 0

#21 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 29 March 2007 - 09:45 PM

There is no way AStar can get though a maze, but does it freeze other than when in a maze? And if so when?

I think Im going to add some freeze security and so after width*height*2 loops go by that it stops and returns an empty string.

Thanks,
HomebrewPC

Edited by homebrewpc, 29 March 2007 - 09:45 PM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#22 novaz

novaz

    GMC Member

  • GMC Member
  • 592 posts
  • Version:Unknown

Posted 29 March 2007 - 09:47 PM

i mean a "little" maze, not a big one. But it freezes also when there
are few obstacles, i dont know why.
  • 0

#23 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 29 March 2007 - 09:53 PM

It doesn't freeze for me if I have little obstacles, a little maze, or a ton of obstacles. Uploaded a new version with that freeze protection idea though.

HomebrewPC

EDIT: Take a screenshot of one time it freezes please Novaz.

Edited by homebrewpc, 29 March 2007 - 09:54 PM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#24 novaz

novaz

    GMC Member

  • GMC Member
  • 592 posts
  • Version:Unknown

Posted 29 March 2007 - 09:55 PM

in this picture, it freezes everytime you click on a wall. I tried 3 times.
Posted Image
  • 0

#25 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 29 March 2007 - 09:56 PM

...Hmm, the DLL wouldn't do that. It checks if the End point is an obstacle and then stops. I don't know if that is the program then or not.

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#26 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 899 posts
  • Version:GM:Studio

Posted 29 March 2007 - 11:12 PM

It still freezes for me, too. I'm going to try something... I'll reply a little later with my result.

EDIT1:
Alright, I've isolated the error. It involves your internal obstacle system...

EDIT2:
Okay, I changed 2 of your scripts to function ONLY with the 8 Direction rather than obstacles.

Replace your script, astar_setobstacle, with this code:
//astar_setobstacle(x,y)
var ar0,ar1,i;
ar0=floor(argument0/global.astarR_cellwidth)
ar1=floor(argument1/global.astarR_cellheight)
//external_call(global.astarR_setobstacle,ar0,ar1)
for(i = 0;i < 8;i += 1;)external_call(global.astarR_setdirblocked,ar0,ar1,i,1);

Replace your script, astar_setfree, with this code:
//astar_setfree(x,y)
var ar0,ar1,i;
ar0=floor(argument0/global.astarR_cellwidth)
ar1=floor(argument1/global.astarR_cellheight)
//external_call(global.astarR_setfree,ar0,ar1)
for(i = 0;i < 8;i += 1;)external_call(global.astarR_setdirblocked,ar0,ar1,i,0);

It will no longer freeze. :]

-DF81

Edited by DFortun81, 29 March 2007 - 11:17 PM.

  • 0

dia_rpg_builder.png
Navigate to my personal website by clicking the image above.


#27 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 30 March 2007 - 12:23 AM

Thanks a ton, I think I know exactly where the error is. I will edit/reply/update when I fix it.

Does it work for your purpose now then?

Thanks,
HomebrewPC

EDIT: Can you take a screeny of what the grid looks like when there is an error please?

EDIT2: Ohhhhh...I get it...your just setting all eight positions as non-enterable...that would be smart. Screw fixing the error, Ill just change those and upload it.

Edited by homebrewpc, 30 March 2007 - 12:53 AM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#28 DFortun81

DFortun81

    The Fortunate One

  • GMC Member
  • 899 posts
  • Version:GM:Studio

Posted 30 March 2007 - 12:55 AM

Thanks a ton, I think I know exactly where the error is. I will edit/reply/update when I fix it.

No Problem.

Does it work for your purpose now then?

<{POST_SNAPBACK}>

It does, but it doesn't find the fastest path to a particular location.

In some cases, it wont even get past easy to find cells...
Posted Image
-Red Squares are the obstacles.
-Blue circle is the player.
-Yellow Squares are the cells that I have clicked.
Of all of the yellow squares, only the top 2 work. (Where the player is and the cell above it.)

I don't understand how the 3rd cell didn't work, but you get the picture.
-DF81
  • 0

dia_rpg_builder.png
Navigate to my personal website by clicking the image above.


#29 hughman

hughman

    GMC Member

  • GMC Member
  • 568 posts

Posted 30 March 2007 - 12:59 AM

sounds great... doesn't seem to be true A* in that I would think A* would go across a diagonal instead of only cutting off one corner and other than that going left/right/up/down
  • 0

#30 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 30 March 2007 - 01:34 AM

Ok, I made it so it goes more diagonal for you hughman. It will go diagonal at the same value as left, right, up, and down now.

Also, as for our obstacle problem, try the one I uploaded and tell me if it works for you...works for me...

It still cannot get through your grid though, but sometimes it does depending on where the blue dot is.

As far as making a normal non-maze game though, I think this would work.

Thanks,
HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#31 Ansgar

Ansgar

    OM Studios

  • New Member
  • 333 posts

Posted 30 March 2007 - 03:30 PM

It's strange that you have problems with the maze. I created an identical one in my AStar example and it got to each of the yellow squares without problems. I suspect there's some problem in the inner mechanics of your AStar algorithm...

There is no way AStar can get though a maze

<{POST_SNAPBACK}>

You don't mean this for A* in general, do you? Because finding a path through a maze is a common use of the algorithm.

Edited by Ansgar, 30 March 2007 - 07:48 PM.

  • 0

#32 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 30 March 2007 - 03:42 PM

I'll check it out soon, Im at school right now.

HomebrewPC

EDIT: All problems have been fixed. Uploaded a new version. I ran into several problems that I thought would have nothing to do with the DLL returning the path...but they are all fixed now.

Edited by homebrewpc, 02 April 2007 - 10:54 PM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#33 Jugado

Jugado

    GMC Member

  • New Member
  • 38 posts

Posted 04 April 2007 - 07:01 PM

Sorry for the newbie question: this works with GM7?

Thanks
  • 0

#34 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 04 April 2007 - 08:09 PM

Yes, it will work with any version...I think.

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#35 Jugado

Jugado

    GMC Member

  • New Member
  • 38 posts

Posted 04 April 2007 - 08:47 PM

Homebrewpc,

I am playing with your Dll (btw thanks for it) and I am getting this error in the script of the obstacle.

___________________________________________
ERROR in
action number 1
of Create Event
for object obj_wall1:

In script astar_setobstacle:
Error in code at line 1:
   //astar_setobstacle(x,y)var ar0,ar1,i;ar0=floor(argument0/global.astarR_cellwidth)ar1=floor(argument1/global.astarR_cellheight)external_call(global.astarR_setobstacle,ar0,ar1);

at position 68: Unknown variable astarR_cellwidth


In my example, there is not an option to add obstacle with the mouse, all obstacle are fixed. Any clue what I am doing wrong?

My grid is:
astar_grid(60,45,32,32);
My room is: 1920x 1440

Thanks for the help

Edit: the problem is, the “controller object”, which initialize the A*, is not loading after the obstacle objects. It is the same case with Ansgar script. An alarm event has to be added to the obstacle object to give some time to initialization. What do you think Homebrewpc?

Edited by Jugado, 04 April 2007 - 10:03 PM.

  • 0

#36 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 05 April 2007 - 12:11 AM

Homebrewpc,

I am playing with your Dll (btw thanks for it) and I am getting this error in the script of the obstacle.

___________________________________________
ERROR in
action number 1
of Create Event
for object obj_wall1:

In script astar_setobstacle:
Error in code at line 1:
   //astar_setobstacle(x,y)var ar0,ar1,i;ar0=floor(argument0/global.astarR_cellwidth)ar1=floor(argument1/global.astarR_cellheight)external_call(global.astarR_setobstacle,ar0,ar1);

at position 68: Unknown variable astarR_cellwidth


In my example, there is not an option to add obstacle with the mouse, all obstacle are fixed. Any clue what I am doing wrong?

My grid is:
astar_grid(60,45,32,32);
My room is: 1920x 1440

Thanks for the help

Edit: the problem is, the “controller object”, which initialize the A*, is not loading after the obstacle objects. It is the same case with Ansgar script. An alarm event has to be added to the obstacle object to give some time to initialization. What do you think Homebrewpc?

<{POST_SNAPBACK}>


If the objects are already placed within the room editor, then I would go with the alarm event. If you are instance_create()ing them then just call that after the initialize script.

If it does work with your alarm setting, then that might be the way to go.

Thanks for downloading!
HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#37 Jugado

Jugado

    GMC Member

  • New Member
  • 38 posts

Posted 06 April 2007 - 11:14 PM

homebrewpc,

I am playing with your dll and it is pretty fast and so far it is working well. The only point is, in some cases the chosen path is the limit between the blocked area and the free area. This makes,, in my example, that the object pass over the road and sidewalk at the same time (50-50). The road, free are, is 5 grids wide.

Any idea?

Thanks for your dll.
  • 0

#38 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 07 April 2007 - 12:21 AM

Your welcome, if you could post a screenshot of your problem that would be great...as I did not get a word of that.

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#39 Jugado

Jugado

    GMC Member

  • New Member
  • 38 posts

Posted 07 April 2007 - 12:53 AM

:blink: Sorry, I did not explain myself well. Let me try again using above image from DFortun81. Red squares are blocked area; gray squares are “free” area. My object is using the boundary between them to construct the path, I mean the center of my object is going on the division between red and gray squares.

The difference between my example and Dfortune is, mine has more free are (gray squares) between reds. Example: from left to right: 1 square red, three gray squares, 1 square red.

If you don’t understand please do not worry, I will continue playing!!

Thanks

Edited by Jugado, 07 April 2007 - 12:55 AM.

  • 0

#40 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 07 April 2007 - 01:28 AM

...Is what you are trying to say is that your objects origin is centered? Cause if you're not i'm completely lost...

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#41 Jugado

Jugado

    GMC Member

  • New Member
  • 38 posts

Posted 07 April 2007 - 06:13 AM

Do not worry about my previous question. I have another one.
I am not familiar with paths, so let me ask you this:

In your code:


with obj_ball{
path_end();
if instance_exists(obj_goto){with obj_goto{instance_destroy()}}
//follow path returned by AStarDLL at speed 6
temppath=astar_getpath(obj_ball.x,obj_ball.y,mouse_x,mouse_y);
if string(temppath)!=''{
myvar=floor(mouse_x/global.astarR_cellwidth)*global.astarR_cellwidth
myvar2=floor(mouse_y/global.astarR_cellheight)*global.astarR_cellheight
instance_create(myvar,myvar2,obj_goto)
path_start(temppath,8,0,true);}}


you start with path_end(). According to the manual this function just stops the process of following the path but does not erase the path, is it correct?

If so, this means, previous paths are preserved?

Sorry for my silly questions.

Thanks
  • 0

#42 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 07 April 2007 - 01:41 PM

When you use the astar_getpath() function it returns the path it created. So if you do something like:

path=astar_getpath(1,1,10,10)

Then the variable path will contain the path, as long as you dont set the variable path again, this path will always contain the path for 1,1 to 10,10.

You're right path_end() ends the path the object is currently following. I called this first and so when you click a new spot and the object is still following the previous path, it starts going to the new path instead.

Your questions aren't silly, I just couldn't understand the first one.

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#43 Jugado

Jugado

    GMC Member

  • New Member
  • 38 posts

Posted 07 April 2007 - 09:13 PM

So, it is not necessary to delete a path before to create new one?
path_delete(myPath);

Thanks for your answers.
  • 0

#44 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 07 April 2007 - 10:17 PM

If you need the path later then you don't need to delete it. But if you're not going to use it anymore, you should probably delete it to free memory.

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#45 sleija

sleija

    GMC Member

  • New Member
  • 174 posts

Posted 09 April 2007 - 12:40 AM

I've heard that A* can be implemented into platform AI (can't find the topic, but it was by Potnop). Is this possible with this DLL?
  • 0

#46 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 09 April 2007 - 01:20 AM

It should work, it depends on how you want to implement it. Like if you have an enemy that needs to move across a platform to your character, then yes it would.

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#47 Jugado

Jugado

    GMC Member

  • New Member
  • 38 posts

Posted 10 April 2007 - 07:40 AM

homebrewpc,

There is something funny with your dll. Imagine a small city with some blocks(see picture). I have a car which has to travel from point A to B. If point B is in a street (right-left) everything works well but if point B is in an avenue (up-down) each time the cars pass by an intersection, it tries, just tries like one node, to take an avenue instead to go straight by the street. It seems there is an extra node in each intersection. Any clue what is happening?

Thanks


Posted Image
  • 0

#48 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 10 April 2007 - 02:04 PM

In relevance to the green block thing, is your object centered? I'm working on a simple GM script to keep the object centered in a cell when it is following a path, that might solve that problem.

As for the starting to go diagonal thing, that is probably a result of the order in which I check the points around a cell, and the fact that left/right/down/up are worth the same as diagonals. So if the DLL gets a chance to take a diagonal that seems faster it will automatically take it.

Tell you what, I will finish that center script, and then make it an option to set the value of up/down/left/right and diagonals. That will probably fix the problem, because then it will look at those diagonals and "think" "Oh, those cost more, so it's faster to go straight".

HomebrewPC
  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.

#49 Jugado

Jugado

    GMC Member

  • New Member
  • 38 posts

Posted 10 April 2007 - 06:31 PM

In relevance to the green block thing, is your object centered? I'm working on a simple GM script to keep the object centered in a cell when it is following a path, that might solve that problem.

As for the starting to go diagonal thing, that is probably a result of the order in which I check the points around a cell, and the fact that left/right/down/up are worth the same as diagonals. So if the DLL gets a chance to take a diagonal that seems faster it will automatically take it.

Tell you what, I will finish that center script, and then make it an option to set the value of up/down/left/right and diagonals. That will probably fix the problem, because then it will look at those diagonals and "think" "Oh, those cost more, so it's faster to go straight".

HomebrewPC

<{POST_SNAPBACK}>


Excellent. Thanks for taking time to add more options. About the green blocks, that is what I talked before about the center problem. I have also these brick blocks which I use for collision with the car. I have to add the green ones because I have the problem shown in the picture, the center of the car goes one the sidewalk and the bricks.

With the new option you will add, I guess the problem will be solved.

Thanks
  • 0

#50 homebrewpc

homebrewpc

    GMC Member

  • New Member
  • 651 posts

Posted 10 April 2007 - 06:45 PM

So In the next version I will add:

-Option to set values for up/down/left/right and diagonals
-Center Path script (all in GML, no DLL interaction)
-Option to allow diagonals or not
-Option to cut through corners of solid objects or not

No problem,
HomebrewPC

EDIT: Uploaded a new version with all of above.

Edited by homebrewpc, 10 April 2007 - 07:34 PM.

  • 0

GMArcade is being remade into iPlayIndie, check out our development topic for more information.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users