Can Stencyl create a pathfinder algorithm like A* with blocks ?

Usernoob

  • Posts: 24
Hi, it's me, the one who never end its projects. Now i have the idea/challenge of create a pathfinder algorithm like the A* but, because im  retard i like challenges i will try to make only whit stencyl blocks. Ah, in real time, not  in steps

It is possible ?

Im tryin creatin a "clever tiles" but it consume so munch memory.

Each tile every 0.05 seconds set a atribute to 9999, if the player is too close to one tile the tile set this atribute to 1

then if the tile is not an obstacle the tile check if the nearest tiles have a movecost (the atribute) smaller than his movecost, if is smaller then change her own atribute to the smaller +1

So i have in each tile the number of "steps" to the  player

Enemyes instead going to the player check the nearest tiles and go to the smaller atribute tile.

But is so slow...

I know Stencyl have extensions whit the A* algorithm and IA, but i like to know how is made.


merrak

  • *
  • Posts: 2478
I don't see why it wouldn't be possible. While I certainly appreciate a challenge, there's a good reason not to do this if your goal is efficiency. A*'s speed is, in part, achieved by using the correct data structures. Stencyl blocks use a lot of Dynamic types (particularly--in lists and maps) and there is a penalty for doing so. See the Haxe entry for more detail on that. It won't be noticed for most tasks, but if you're going to be using A* to search large graphs every frame, it's worth paying attention to data types.

Usernoob

  • Posts: 24
The  Haxe site have a Trojan (Malwarebytes say it) so i cant see the  link

So, for a real game its better downlod the A* Extension or another similar ?

I like more if im making the things by myself, but, thinking about it, im making this with stencyl, if really i like all "maked by my" i should programing by code, no ?

merrak

  • *
  • Posts: 2478
The  Haxe site have a Trojan (Malwarebytes say it) so i cant see the  link

So, for a real game its better downlod the A* Extension or another similar ?

I like more if im making the things by myself, but, thinking about it, im making this with stencyl, if really i like all "maked by my" i should programing by code, no ?

Here's the part that's relevant:

Quote
While Haxe has a static type system, this type system can, in effect, be turned off by using the Dynamic type. A dynamic value can be assigned to anything; and anything can be assigned to it. This has several drawbacks:

The compiler can no longer type-check assignments, function calls and other constructs where specific types are expected.
Certain optimizations, in particular when compiling to static targets, can no longer be employed.
Some common errors, e.g. a typo in a field access, can not be caught at compile-time and likely cause an error at runtime.
Dead Code Elimination cannot detect used fields if they are used through Dynamic.
...
Use of Dynamic should be minimized as there are better options in many situations but sometimes it is just practical to use it. Parts of the Haxe Reflection API use it and it is sometimes the best option when dealing with custom data structures that are not known at compile-time.

If you want to implement A* yourself, I'd recommend writing your own extension, like I did, or using Stencyl's code editor.

I don't know how literal you want to take "making by yourself". Stencyl code blocks are just macros for different strings of code. Blocks are just another way to visualize looking up functions in an API reference. If you want to make a game from scratch, you really shouldn't use any engine--but even then you'll probably be using libraries. I suppose you could write your game using Assembly... but even then aren't you using hardware routines already provided by the designers?

If you want to really start from scratch, I'd look into building your own computer. There are some good guides on doing this out there.

Usernoob

  • Posts: 24
Ok i will install a stencyl extension with pathfinder. 

What of this extensions have pathfinding ?

http://www.stencyl.com/developers/market/

PD: For the next version of Stencyl put some kind of pathfinding, Gamemaker for example has it.


merrak

  • *
  • Posts: 2478
Interestingly, I don't see either of them on the market. The two I'm aware of are:

1. Mine, of course: http://community.stencyl.com/index.php/topic,45313.0.html
2. jihem's, marked 'Abandoned': http://community.stencyl.com/index.php/topic,15343.0.html

Since jihem's is marked abandoned, I'm not sure if it is compatible with newer versions of Stencyl.  I get the sense mine is harder to use, but it's designed to solve a wider variety of problems. jihem's is probably faster, but is designed to solve a smaller set of problems.

You could also use them as examples for writing your own extension. I don't know about jihem's, but I don't claim any copyright on mine--do what you want with it.

Usernoob

  • Posts: 24
Thank you merrak, in the end if I give up and I can not create it from the examples I will use one of those 2.

Now I have a new idea for a pathfinder, I will try to explain it (then if I have time I will try to try it in a game)

The idea is to create a "chain" like an enemy type "worm" made of several objects that are stuck but with freedom to move.

This chain would be "tied" to the object that has to follow the path at one end and the other would try to go to the destination, but as it would be tied would be something like a "Chain Chomp" of Super mario.

Now, this chain could "collide" with the obstacles, so it would be altered and could form curves.

The object to be guided would move in direction to the end of the nearest chain (that is tied to it) when this link moves to follow the next link  the position change and the object to guide have new direction to follow.

What do you think?

merrak

  • *
  • Posts: 2478
It sounds interesting, but I don't think it's going to be simple to determine where to make the bend. It's easy to visualize it bending around one corner--but less so solving something like a maze.

Usernoob

  • Posts: 24
The "chain" dont works, because the links can collide the obstacles and the chain "tangles" in the obstacles.