A* as a Stencyl extension (with basic sample) [ABANDONED]

jihem

  • *
  • Posts: 161
I got it! And... It was my fault ( again  :-[ ). In the constructor or AStar, I made a mistake in the limits of the map. Usually, I put a wall around the map so I haven't seen it before.

   public function new(smap:String)
   {
      if (AStar.cst==null)
      {
         AStar.cst=new Hash<Float>();
         AStar.setCost(".",0);
      }
      this.map=smap.split("|");
      this.mxx=map[0].length-1;  // the -1 were missing
      this.mxy=map.length-1;      // on this 2 lines.
      this.opn=new List<ANode>();
      this.cld=new List<ANode>();
   }

You can update DecisionMaking.hx from GitHub or use the attached zip.
http://n3k4.whizkids.fr/dm-astar-3/index.html has been update (for testing purpose).

Can you confirm it solve the issue for you?

Another subjet: I was working with James Prestwood (Prestwood Animation Studio UK). He need to make a break for family reasons. So, I'll be available as teammate (for a couple of weeks). In the wait, I'm working on a personal project (iPad game). If someone need somebody (or have an emergency), it's the right time.

Hu... One more thing : In the 'Level1' scene of dm-astar-3, you can add Hunters. Just edit the scene and add some 'Hunter' actors on the middle of the tiles.

« Last Edit: November 22, 2012, 01:27:37 pm by jihem »
while (!success=retry());

Ninjadoodle

  • Posts: 313
Hi Jihem

Awesome work! I've been playing with the new version and don't seem to get any crashes :) I've started implementing it into my game and it works really well.

I have one question ... if I want the hunters to react to physics (for example they get bumped/pushed by the player) they seem to go off track and loose their ability to find the path again and they just end up sitting there.

I assume this happens, because the hunters get pushed off the centre of the tile?

Is there any way of going around this?

Once again, thank you for the awesome extension!

BTW: What game are you working on?
It's all fun and games until somebody get's a shuriken in their eye!

jihem

  • *
  • Posts: 161
Hi,

> Is there any way of going around this?
The hunter make his next move once he has reached the previous target tile. If you put him out of his road, he will never reach the tile... so he will stop moving. I understand your need and have an idea about how to implement it. I'll extend the sample (or make a derivative work) in the next days.

>Once again, thank you for the awesome extension!
It's a real pleasure to help.

>What game are you working on?
My personal project is a sort of Dobble like (http://www.amazon.co.uk/Asmodee-ASMDOBB01EN-Dobble-Card-Game/dp/B0031QBHMA) The game evolves to a cross-over with tangram. The players have to build parts of the pictures to associate them (not only to find the matching parts).
while (!success=retry());

Ninjadoodle

  • Posts: 313
I thought it was something like that, thank you for explaining it.

I thought that recalculating the path on a collision with an actor would help?  If only I had an idea on how to do it, haha. I'm really looking forward to your example on how to do this!

Your game idea sound interesting, I like puzzle games. I've been making flash games for a few years, mainly using Adobe Flash. Lately, the Flash IDE has just become to slow and buggy with the tools/plugins I use. I noticed Stencyl and really liked the cross-platform exporting (I'd really like to get my games to devices).

So now that Stencyl 3.0 supports Mochi Live Updates, it's become my new tool of choice. With the help of your extension, I'm currently making my first Stencyl game :)

*EDIT* I just thought about resetting the hunters path on collision, but realized that the hunter slides after being bumped/pushed. The reset would have to be done once the hunter comes to a complete stop. I'm probably not helping much haha, just brainstorming :)

« Last Edit: November 23, 2012, 01:52:50 am by Ninjadoodle »
It's all fun and games until somebody get's a shuriken in their eye!

jihem

  • *
  • Posts: 161
I found three different ways to do what you want (see collision event in the 'hunter' actor). For me, the best is the bloc used. But the comment blocs are good too (it's depend on your real need). Don't forget to enable collision with the 'players' group in the collision properties of the 'hunters' group ('hunter' actor/properties/edit groups...).
while (!success=retry());

Ninjadoodle

  • Posts: 313
You are a legend! The latest update you've done is awesome, but there is still one problem ... I think this one might be a little hard to solve.

If the enemies don't collide, they eventually end up crossing each other over until they become one enemy (all following from the same position) ... if I make them collide with each other, they get confused and can't move.

The 3rd option "The hunter returns to his target position (same speed), then chases again"
... seems to work the best when it come to them not getting as confused, but it crashes with a few hunters.

The 1st option (You're favourite) seems to be the best for hunter logic.

If I want the hunters to collide with tiles, they also get confused. If I leave the tile collision off, they can be pushed inside the tiles.

Thank you once again for all the work you are doing and let me know if what I've detailed is doable or too complicated :)

« Last Edit: November 24, 2012, 06:47:07 pm by Ninjadoodle »
It's all fun and games until somebody get's a shuriken in their eye!

Ninjadoodle

  • Posts: 313

« Last Edit: November 24, 2012, 10:10:17 pm by Ninjadoodle »
It's all fun and games until somebody get's a shuriken in their eye!

jihem

  • *
  • Posts: 161
A legend ?! Wahahahah... Even if the cake is a lie (portal), reading this, I'm blushing like a young girl.

You're too kind. If every users of my projects and publications were like you, I could work on them full time (and didn't need boring additional jobs).

Actually the path finding isn't cooperative. Each hunter works for itself.

If think, I can improve this :

a) They can share the same map updated with their positions (a special tile code) -> mark all tiles used by their path and free the last tile after each move.

b) Make a time sliced map (with the hunter's position at each time tick) -> need to write new haxe class methods for this and may be add new stencyl blocks

The last (b) is the one described in the document links sent. The hunters won't act the same way with the two solutions. So we have to try... :)
while (!success=retry());

jihem

  • *
  • Posts: 161
Since some days, I have private exchanges with ninjadoodle. Some updates haven't been published here. To stay tuned, have a look on the github repository : http://github.com/jihem/Stencyl-DecisionMaking

Thanks again to all of you for supporting me
Regards,
jihem

« Last Edit: November 30, 2012, 10:00:06 am by jihem »
while (!success=retry());

FortySe7en

  • Posts: 304
Really amazing stuff!
Now I got to reconsider putting together a game that uses pathfinding as my next one, I felt a bit helpless when I tried to grasp Astar myself.

bonzero

  • *
  • Posts: 487
I have just tried the extension and it works really well, Im very interested in the cooperative path method since I want to have more actors on the screen, do we have to send the donation to get the new samples with the cooperative path?

One small thing I have noticed is that when using diagonals, the actor ignores the fact that there are 2 tiles blocking the path in the way because the diagonal node to the goal is not blocked, I will try to illustrate that like this: tiles X are blocked, O are open, E the enemy, G the goal

G
XOXX
XXOX
      E

The enemy reached the goal thru O although it shouldn't since there a 2 X tiles in the way
Thanks for your amazing work

datbird

  • Posts: 40
Hello all! First off thank you jihem for all your hard work on this it works very well and I love the implementation!

I'm not sure if anyone is any watching this thread any more, from the looks of bonsero's post it doesn't appear so. I managed to get this all bolted into my game and under stand how to use it pretty well now. Right now as a test I have the pathfinder working to provide paths to targets created by mouse clicks.I've got it working just fine and dandy but after sitting and clicking for 20 minutes or so I noticed some occasional oddities. I do believe what bonzero described to be an issue. You could probably make a special duplicate tile in your tile-set that is the same graphic but has a much higher cost then proceed to place that in all diagonal places but imagine that would come with its own issues.

The other issue I've seen is that it does not seem to actually take the most efficient paths a lot of the time. Is this expected behavior? I mean it takes a correct path just not the most efficient one.

Anyway hopefully jihem is still out there checking this from time to time I'd like to hear his thoughts on these two issues or any one else's for that matter.

Dom818

  • *
  • Posts: 1296
I have noticed that it will occasionally take a less efficient path. I have just accepted that this is how it is and just have ignored it. I'm not sure if there is a fix for it.

datbird

  • Posts: 40
Great I can live with that for sure. I'm more happy that it doesn't result in my implementation of the extension in some way. I kind of wrote my own method of using the extension and am only loosely using some of the ideas/code from the examples so was worried it might be some tom foolery of my own :p

Anyway, thanks for the confirmation!

FortySe7en

  • Posts: 304
I did implement it and do have some 'bad choice' issues where actor takes a path around an obstacle instead of fitting in a few tile gap across it.
I too can live with it though.
Since I plan to finish that game in the future, I might as well send some appreciation $$ down creator's way now. Good reminder :) (edit: done)

« Last Edit: June 14, 2013, 11:09:11 am by FortySe7en »