Stencyl 3.4.0 is now out. Get it now!

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

jihem

  • *
  • Posts: 161
Done. You can update from https://github.com/jihem/Stencyl-DecisionMaking
See sample (actor event create) to know how to manage a closed path.

1°) I added a test in the method path (in the extension) to return an empty string if this.pth is null ( "".substr(1) -> "" ).

2°) Using a split block on an empty text with separator freezes stencyl... (stencyl 3 bug?) So you have to test the result before the split. If empty, the path is closed (and in the dm-astar-1 sample, the actor dies).

Sorry for the inconvenience

« Last Edit: October 20, 2012, 05:10:02 am by jihem »
while (!success=retry());

Dom818

  • *
  • Posts: 1296
Thanks for the update, I will test it out!

Dom818

  • *
  • Posts: 1296
I don't know if this would be possible to add, but is there a way to get the cost of the current path? I know A* finds the path with the lowest cost and this might be helpful in some games.

jihem

  • *
  • Posts: 161
Yes. I can add this in about fifteen days. If you have an emergency, you can send me a private message. I will revise my planning. The next days, I'm working on a core animations engine.
while (!success=retry());

Dom818

  • *
  • Posts: 1296
That's fine, add it when you have time. No hurry.

jihem

  • *
  • Posts: 161
You may be happy (I hope so...).  ;D
while (!success=retry());

Dom818

  • *
  • Posts: 1296
You may be happy (I hope so...).  ;D

Many thanks jihem! I will implement this into my game later and tell you how it works out.

jihem

  • *
  • Posts: 161
I made this during my lunch time and uploaded when I was back at home. Let me know if something goes wrong or if you need something else...  :P
while (!success=retry());

Dom818

  • *
  • Posts: 1296
Hi jihem,

I need a bit of help with the extension again. Iam trying to set the code cost of a letter in the path to a number before it makes the path so it can choose the one that is the cheapest to get to. Problem is, it either throws an error or the person does not move at all. I have modded the sample game to give you an example. Hope you can figure this out.

jihem

  • *
  • Posts: 161
It's my fault... I fixed it.

In DecisionMaking.hx, update setCost to (github has been updated) :

   public static function setCost(s:String,c:Float)
   {
      if (AStar.cst==null)
      {
         AStar.cst=new Hash<Float>();
      }
      AStar.cst.set(s,c);
   }

See the new sample dm-astar-2. Why not follow me to get the next updates ?
while (!success=retry());

Dom818

  • *
  • Posts: 1296
Thanks jihem, it works now. What do you mean by follow you, on Stencyl or somewhere else?

jihem

  • *
  • Posts: 161
> What do you mean by follow you, on Stencyl or somewhere else?
On Stencyl. "nobody follows jihem" message made me sad...
Now, I have one follower. :) And you know what? I'm happy. Thanks
while (!success=retry());

saulochina

  • Posts: 214
Finding the fun!
Squib Wars. Now complete, and avaible for free on App Store! http://bit.ly/LxJ62L
https://www.facebook.com/twoheadedgames
Twitter: @saulochina
MSN: sauloj.china@hotmail.com

jihem

  • *
  • Posts: 161
Waouh... incredible ! Thanks. Now, I'm not a poor lonesome stencyler...
while (!success=retry());

Ninjadoodle

  • Posts: 313
Hi Jihem

Thank you for an awesome extension :) I've read your guide and have been playing around with the settings but I'm having trouble applying it to my game.

Basically I would like to have a key controlled player move around and an enemy to follow them.

Is this possible with your extension? Do you have any tips on how I would go about doing this?

Thank you again!
It's all fun and games until somebody get's a shuriken in their eye!