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

jihem

  • *
  • Posts: 161
As requested by Ninjadoodle, this is a new sample using A* with hunters to catch their target.
I hope this will help.
while (!success=retry());

Ninjadoodle

  • Posts: 313
Hi Jihem

I made a donation to your paypal account for the awesome work your doing! You should post your Paypal address here, so others have a chance to do the same :)

Thank you heaps for your new example! I'm getting a couple of problems tho ...

When I try to compile, I get these errors on the lines where you set the "code cost for . and A" ...

Events for 'Hunter' (120) -  Missing ;
Events for 'Hunter' (121) -  Missing ;

Also, when I try to remove these lines and compile, the game crashes after moving with the arrow keys.

Any idea what I might be doing wrong?

Thank you again for all your help, I really appreciate it :)
It's all fun and games until somebody get's a shuriken in their eye!

jihem

  • *
  • Posts: 161
Hi,
Many thanks for your donation. It's very kind. Thanks a lot.

You need to update to the last version of the file 'DecisionMaking.hx'. You can download the zip of the project on GitHub : https://github.com/jihem/Stencyl-DecisionMaking. The bug you describe has been corrected (see Dom818 messages). Exit Stencyl, update the "decision-making" folder and retry.

Regards,
jihem

« Last Edit: November 21, 2012, 01:06:52 pm by jihem »
while (!success=retry());

Ninjadoodle

  • Posts: 313
No problem at all, thank you for making it easier for us to make path-finding :)

I knew it was something I was doing wrong .... It now compiles and works, but the sample still crashes at times.

It seems to crash randomly after it's been running for a few seconds and also any time I enter the X tiles.

Does this happen for anyone else? (maybe I still need to update something)
It's all fun and games until somebody get's a shuriken in their eye!

jihem

  • *
  • Posts: 161
> It seems to crash randomly after it's been running for a few seconds and also any time I enter the X tiles.

Hu? Here are my binaries (mac, win) of dm-astar3. I made them with the today release of Stencyl3 beta (nov. 21). Can you try them on your system? Can you send me the message Stencyl displays (to help me find what's going wrong)? Thanks.
while (!success=retry());

Ninjadoodle

  • Posts: 313
I've updated to the latest release of Stencyl / updated with the new extension and loaded the new game file :) Here is what happens ...

TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at AStar/get()[C:\Program Files (x86)\Stencyl\plaf\haxe\extensions/decision-making/DecisionMaking.hx:112]
   at AStar/to()[C:\Program Files (x86)\Stencyl\plaf\haxe\extensions/decision-making/DecisionMaking.hx:162]
   at DecisionMaking$/getAStarPath()[C:\Program Files (x86)\Stencyl\plaf\haxe\extensions/decision-making/DecisionMaking.hx:16]
   at scripts::ActorEvents_2/Hunt()[Source/scripts/ActorEvents_2.hx:62]
   at MethodInfo-3306()[Source/scripts/ActorEvents_2.hx:131]
   at com.stencyl.behavior::TimedTask/update()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/behavior/TimedTask.hx:48]
   at com.stencyl::Engine/update()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:1990]
   at com.stencyl::Engine/postUpdate()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2287]
   at com.stencyl::Engine/onUpdate()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2280]
It's all fun and games until somebody get's a shuriken in their eye!

jihem

  • *
  • Posts: 161
Thanks. I will try to reproduce this issue.
Did my binaries work on your system?
Are you using OSX? Windows?

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

Ninjadoodle

  • Posts: 313
Using windows and yup, I used the new binaries you sent to update everything.

The windows one seems to be running no problem ... wonder if its something to do with flash, which is what I'm targeting at the moment.
It's all fun and games until somebody get's a shuriken in their eye!

jihem

  • *
  • Posts: 161
Did you use Run/Clean Project after the update ?
Are my windows binary (dm-astar-3.win/dm-atar3.exe) working on your system => Yes. Ok.
Only Flash provides the error => I'll test on my windows PC building Flash binary (within the next 72h).

« Last Edit: November 21, 2012, 02:44:20 pm by jihem »
while (!success=retry());

Ninjadoodle

  • Posts: 313
Just tried run clean project and still the same thing /:(

No problem, take your time ... I know you must be busy :) I'll keep testing to see whether I'm doing something wrong.
It's all fun and games until somebody get's a shuriken in their eye!

Ninjadoodle

  • Posts: 313
Just a little bit more info ...

I tried compiling windows, flash and html5

I played with each for about 2mins

WINDOWS - seems to work fine :)
FLASH - crashes after some time
HTML - crashes after some time
It's all fun and games until somebody get's a shuriken in their eye!

jihem

  • *
  • Posts: 161
The failure occurs in the every second loop in the hunter while trying to update the path. In the function DecisionMaking::getAStarPath, the get call (line 112) catch an exception (null object reference).
   public function get(x:Int,y:Int):String
   {
      return this.map[y].substr(x,1);
   }
So I have 2 cases to explore (x, y) can't be null (integer) :
- this is null
- this.map[y] is null

I seriously doubt that this is null, because in getAStarPath the object is just created before the call.

   public static function getAStarPath(map:String,fx:Int,fy:Int,tx:Int,ty:Int,dg:Int):String
   {
      return new AStar(map).from(fx,fy).to(tx,ty,dg).path();
   }
The line 162 is:

                     var id=get(vx,vy);
I fear 2 things:
- a context lost in the time loop (map variable is unknown)
- a round problem on vx,vy => need to add a round in the call block (path for map row/col parameters) and/or check the coordinate ranges.

My idea is that true compiled versions (C => windows, osx,...) work because of the int cast and pseudo compiled (or interpreted) (flash and javascript) doesn't because they used float. May be the add of 2 rounds in the "get path" can help. I will test this as soon as I'm up.

Don't even imagine where I was during this brainstorm... LOL (now going back to bed)

« Last Edit: November 21, 2012, 07:36:05 pm by jihem »
while (!success=retry());

jihem

  • *
  • Posts: 161
I have added the "round" trick in the hunt event (in case it could help). Try this new game version.

That make me mad is that I can't reproduce this error (but I'm a mac user).
The flash (see .swf in the archive) and HTML5 versions work as expected.
Can you try them ?

I put the HTML5 version on my web server too (so you don't need to install your own) : http://n3k4.whizkids.fr/dm-astar-3/index.html

As I said, I'll try to build all the versions using stencyl3 on a Windows 8 PC soon. If I can't reproduce this with windows, in last resort, I'll ask Jon for help (stencyl or nme issue?). Don't worry, like a tick on a dog, I just won't stop trying to latch on.
while (!success=retry());

jihem

  • *
  • Posts: 161
Yes. I finally got an  "Uncaught TypeError: Cannot call method 'substr' of undefined" in HTML5 with Chrome on a Windows 8 PC. So I have a track to follow. The same works like charm on OSX (Safari). I have to work on something else right now, but I will be back on this as soon as possible.
while (!success=retry());

Ninjadoodle

  • Posts: 313
Once again! Thank you for working on this ... it's going to make a lot of complex tasks 100x easier :)

Make sure you get some sleep tho haha!
It's all fun and games until somebody get's a shuriken in their eye!