Jamie Slowgrove - AI Assignment 1
Line of Sight & A* path-finding
 All Classes Namespaces Files Functions Variables
Public Member Functions | Private Member Functions | Private Attributes | List of all members
AStar Class Reference

Creates an object for A* path finding Made using help from http://www.policyalmanac.org/games/aStarTutorial.htm. More...

#include <aStar.h>

Collaboration diagram for AStar:
Collaboration graph

Public Member Functions

 AStar (int xNodes, int yNodes)
 
 ~AStar ()
 
void setDangerNode (int nodeXIndex, int nodeYIndex)
 
void findNewPath (int startX, int startY, int endX, int endY)
 
Vec2 getNextPathNode ()
 
void drawLists (SDL_Renderer *renderer)
 

Private Member Functions

void checkNodes (int parentX, int parentY)
 
void nodeTest (int parentX, int parentY, int testX, int testY, int cost)
 
void findNextNode ()
 
void findBestPath ()
 

Private Attributes

std::vector< std::vector< Node * > > nodes
 
std::vector< NodeopenList
 
std::vector< NodeclosedList
 
std::vector< NodebestPath
 
int xNodes
 
int yNodes
 
int currentX
 
int currentY
 
int endX
 
int endY
 
int startX
 
int startY
 

Detailed Description

Creates an object for A* path finding Made using help from http://www.policyalmanac.org/games/aStarTutorial.htm.

Constructor & Destructor Documentation

AStar::AStar ( int  xNodes,
int  yNodes 
)

Constructs an AStar object

Parameters
intThe number of nodes in a row
intThe number of rows in the map
AStar::~AStar ( )

Destructs an AStar object

Member Function Documentation

void AStar::checkNodes ( int  parentX,
int  parentY 
)
private

Check the surrounding nodes

Parameters
intThe parent node x index value
intThe parent node y index value

Here is the call graph for this function:

Here is the caller graph for this function:

void AStar::drawLists ( SDL_Renderer *  renderer)

Displays the open and closed lists

Parameters
SDL_Renderer*A pointer to the renderer

Here is the caller graph for this function:

void AStar::findBestPath ( )
private

Find the best path

Here is the call graph for this function:

Here is the caller graph for this function:

void AStar::findNewPath ( int  startX,
int  startY,
int  endX,
int  endY 
)

Finds a new path to follow

Parameters
intThe start x index value
intThe start y index value
intThe end x index value
intThe end y index value

Here is the call graph for this function:

Here is the caller graph for this function:

void AStar::findNextNode ( )
private

Find the next node

Here is the caller graph for this function:

Vec2 AStar::getNextPathNode ( )

Returns the position of the next node in the path

Returns
Vec2 Node position

Here is the caller graph for this function:

void AStar::nodeTest ( int  parentX,
int  parentY,
int  testX,
int  testY,
int  cost 
)
private

Test the node for the open list setup

Parameters
intThe parent x index value
intThe parent y index value
intThe test x index value
intThe test y index value
intThe cost to add to the node

Here is the call graph for this function:

Here is the caller graph for this function:

void AStar::setDangerNode ( int  nodeXIndex,
int  nodeYIndex 
)

Here is the caller graph for this function:

Member Data Documentation

std::vector<Node> AStar::bestPath
private
std::vector<Node> AStar::closedList
private
int AStar::currentX
private

The current node index

int AStar::currentY
private
int AStar::endX
private

The end node index

int AStar::endY
private
std::vector<std::vector<Node*> > AStar::nodes
private

The arrays of Nodes

std::vector<Node> AStar::openList
private
int AStar::startX
private

The start node index

int AStar::startY
private
int AStar::xNodes
private

The number of nodes

int AStar::yNodes
private

The documentation for this class was generated from the following files: