Hi,

I'm coding an RPD and I'm having a lot of difficulties to find an easy pathfinding algorithm. I have a uint8_t array for the map, and I would like to be able to know which direction an enemy in (x0,y0) should take to go to (x1,y1). Any idea? Any link?

I'm looking for a way that doesn't take to much memory. A lot of algorithm I've found use dynamic memory allocation (Queue, list, vectors...), so I need a plain C code, whithout malloc (preallocated arrays).

A* with Jump Point Fist seems the best way to go but... How to implement it?

Thanks in advance in any help!

PS: animation of multiple algorithm

One option is to find some C code that implements the type of search you want, and simply rewrite it using preallocated arrays.

I have a uint8_t array for the map

What size (x/y) is the map ?

The size of the map is 32x64 tiles. There is a second map which is used as a collision mask, the same size. This is like a cost matrix I guess : 0 is no collision, 1 is collision.

**EDIT :**

I've tried a Flood Pathfinding Algorithm (Lee's algorithm), but it is really to slow if the player and the enemy are to far away. (Jump from 20fps to 10 fps at a distance of 12 tiles ...).

I think I have to implement a simpler method :

```
if E.x > P.x and left move is possible then move left
if E.x < P.x and right move is possible then move right
if E.y > P.y and up move is possible then move up
if E.y > P.y and down move is possible then move down
```

The problem with this algorithm is that the enemy could be stuck :

#############

#
E

#
####

#
P

#############

Here, the enemy (E) will be stuck.

It is even worse if the enemy is in a boxed wall :

#############

#
+

#
## ##

#
# #

#
# E #

#
######

#
P

#############

Here the Enemy will be stuck as long as the player is not going at the location marked with a '+'.

How can I solve this?