Hi,
I read and learn to implement a* algorithm in AGK2. Maybe someone want to learn or make the code better and more efficient.But for now its works!
For the tiles, the number on the centre of tiles is the tile id. Top left corner is the F Value, Bottom left is G and Bottom right is H.
The pink tile is the source, the yellow is the destination, the blue is on openlist, orange on closedlist and green is traceback path.
But this code have limitation and need optimization/better code as:
1.I calculate the H value, the distance between the tiles to the destination once the map load
2.The code only check left,right,up,down but it also easy to add diagnol check
3.I use spriteraycast to check neighbour tiles
Maybe the code can be enhanced to when can have dynamic source and destination for testing? Any better way on checking neighbouring tiles?
Thanks and hope this can help to start learning a*. Forgive me for the poor coding structure.