Jamie Slowgrove - AI Assignment 1
Line of Sight & A* path-finding
 All Classes Namespaces Files Functions Variables
aStar.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <vector>
5 #include "node.h"
6 #include "SDL.h"
7 #include "vec2.h"
8 
13 class AStar
14 {
15 private:
17  std::vector<std::vector<Node*>> nodes;
18  std::vector<Node> openList;
19  std::vector<Node> closedList;
20  std::vector<Node> bestPath;
22  int xNodes;
23  int yNodes;
25  int currentX;
26  int currentY;
28  int endX;
29  int endY;
31  int startX;
32  int startY;
33 
39  void checkNodes(int parentX, int parentY);
40 
49  void nodeTest(int parentX, int parentY, int testX, int testY, int cost);
50 
54  void findNextNode();
55 
59  void findBestPath();
60 
61 public:
67  AStar(int xNodes, int yNodes);
68 
72  ~AStar();
73 
74  void setDangerNode(int nodeXIndex, int nodeYIndex);
75 
83  void findNewPath(int startX, int startY, int endX, int endY);
84 
90 
95  void drawLists(SDL_Renderer* renderer);
96 };
Vec2 getNextPathNode()
Definition: aStar.cpp:222
int yNodes
Definition: aStar.h:23
int currentY
Definition: aStar.h:26
void findBestPath()
Definition: aStar.cpp:237
Creates a Vec2 structure with functions Creates a Vec2 structure with overloaded operators to create ...
Definition: vec2.h:7
void nodeTest(int parentX, int parentY, int testX, int testY, int cost)
Definition: aStar.cpp:157
~AStar()
Definition: aStar.cpp:28
std::vector< std::vector< Node * > > nodes
Definition: aStar.h:17
std::vector< Node > openList
Definition: aStar.h:18
int endX
Definition: aStar.h:28
int xNodes
Definition: aStar.h:22
int startY
Definition: aStar.h:32
std::vector< Node > closedList
Definition: aStar.h:19
void findNewPath(int startX, int startY, int endX, int endY)
Definition: aStar.cpp:52
int startX
Definition: aStar.h:31
int endY
Definition: aStar.h:29
Creates an object for A* path finding Made using help from http://www.policyalmanac.org/games/aStarTutorial.htm.
Definition: aStar.h:13
int currentX
Definition: aStar.h:25
AStar(int xNodes, int yNodes)
Definition: aStar.cpp:6
void findNextNode()
Definition: aStar.cpp:193
void setDangerNode(int nodeXIndex, int nodeYIndex)
Definition: aStar.cpp:43
void drawLists(SDL_Renderer *renderer)
Definition: aStar.cpp:280
std::vector< Node > bestPath
Definition: aStar.h:20
void checkNodes(int parentX, int parentY)
Definition: aStar.cpp:127