### A* Pathfinding

This is in my header file
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647`` ``````#pragma once #include #include #include "Enemy.h" #include "Vector2D.h" #define TILE_SIZE 20 #define MAP_WIDTH 800/TILE_SIZE #define MAP_HEIGHT 600/TILE_SIZE //http://www.policyalmanac.org/games/aStarTutorial.htm using namespace std; struct CGrid { Vector2D Position; bool Empty; // Heuristic values int F; int G,H; }; class CPathfinder { public: CPathfinder(void); ~CPathfinder(void); CGrid World_Map[MAP_WIDTH][MAP_HEIGHT]; CGrid End_Point_Grid; void Process (void); // find out which grid to go void MoveToGrid (CEnemy Enemy_Obj); // go to grid // open list is a list for nodes to be considered vector Open_List; // closed list is the list where the nodes are thrown into after being considered in open list vector Closed_List; private: Vector2D EndPoint; };``````

So I'm having problem in how to calculate which grid to go to. Cause once i have a list of Positions to go to, i dont think i should have a problem.

So I was just wondering if anyone know of any links that is useful in helping me to do pathfinding algorithm because the links I found were either too vague or too hard for me to understand. Or is anyone willing to give me the algorithm.

NOTE: These is the only the link that I used and found useful:
http://www.policyalmanac.org/games/aStarTutorial.htm
while wikipedia confused the hell out of me (http://en.wikipedia.org/wiki/A*_search_algorithm)

Thanks in advanced! :) Any help is appreciated! :D
Last edited on
The first node to consider is the one you're standing on. When that doesn't work, close it and open all of its neighbors you haven't considered yet. Always consider the open node with least cost+heuristic. Note that you shouldn't use Vector2D for nodes - how will you know which way you came from, once you find the target?
Topic archived. No new replies allowed.