A* Pathfinding

This is in my header file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include <vector>
#include <iostream>
#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<Vector2D> Open_List; 

	// closed list is the list where the nodes are thrown into after being considered in open list
	vector<Vector2D> 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
Topic archived. No new replies allowed.