ProtoBot
Loading...
Searching...
No Matches
Path Class Reference

Class representing a path and its information (vector of positions, total distance, etc.). More...

#include <A-StarPathfinding.h>

Public Member Functions

 Path (vector< BWAPI::Position > positions, int distance)
void flip ()
 Reverses the vector of positions in the path. Used when we want to flip a path from A to B into a path from B to A.
bool operator== (const Path &other) const
Path operator+ (const Path &other)

Public Attributes

vector< BWAPI::Position > positions = vector<BWAPI::Position>()
 A vector of BWAPI::Positions representing the waypoints along the path to follow ///<.
int distance = 0
 The total distance of the path, calculated as the sum of the distances between each waypoint ///<.

Detailed Description

Class representing a path and its information (vector of positions, total distance, etc.).

Definition at line 66 of file A-StarPathfinding.h.

Constructor & Destructor Documentation

◆ Path() [1/2]

Path::Path ( vector< BWAPI::Position > positions,
int distance )
inline

Definition at line 71 of file A-StarPathfinding.h.

71 {
72 this->positions = positions;
73 this->distance = distance;
74 };
vector< BWAPI::Position > positions
A vector of BWAPI::Positions representing the waypoints along the path to follow ///<.
int distance
The total distance of the path, calculated as the sum of the distances between each waypoint ///<.

◆ Path() [2/2]

Path::Path ( )
inlinenoexcept

Definition at line 76 of file A-StarPathfinding.h.

76 {
77 this->positions = vector<BWAPI::Position>();
78 this->distance = 0;
79 };

Member Function Documentation

◆ flip()

void Path::flip ( )
inline

Reverses the vector of positions in the path. Used when we want to flip a path from A to B into a path from B to A.

Definition at line 84 of file A-StarPathfinding.h.

84 {
85 vector<BWAPI::Position> vec = this->positions;
86 reverse(vec.begin(), vec.end());
87 this->positions = vec;
88 }

◆ operator+()

Path Path::operator+ ( const Path & other)
inline

Definition at line 94 of file A-StarPathfinding.h.

94 {
95 vector<BWAPI::Position> finalPositions;
96 const int finalDist = this->distance + other.distance;
97 finalPositions.insert(finalPositions.end(), this->positions.begin(), this->positions.end());
98 finalPositions.insert(finalPositions.end(), other.positions.begin(), other.positions.end());
99 return Path(finalPositions, finalDist);
100 }

◆ operator==()

bool Path::operator== ( const Path & other) const
inline

Definition at line 90 of file A-StarPathfinding.h.

90 {
91 return this->positions == other.positions;
92 }

Member Data Documentation

◆ distance

int Path::distance = 0

The total distance of the path, calculated as the sum of the distances between each waypoint ///<.

Definition at line 69 of file A-StarPathfinding.h.

◆ positions

vector<BWAPI::Position> Path::positions = vector<BWAPI::Position>()

A vector of BWAPI::Positions representing the waypoints along the path to follow ///<.

Definition at line 68 of file A-StarPathfinding.h.


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