Public Member Functions | Protected Member Functions | List of all members
ime::DFS Class Reference

Finds a path in a Grid2D using the Depth First Search algorithm. More...

#include <DFS.h>

Inheritance diagram for ime::DFS:
ime::IPathFinderStrategy

Public Member Functions

 DFS (const Vector2u &gridSize)
 Initialize the algorithm. More...
 
std::stack< IndexfindPath (const Grid2D &grid, const Index &sourceTile, const Index &targetTile) override
 Generate a path from a source tile to a target tile in a grid. More...
 
std::string getType () const override
 Get the type of path finding algorithm. More...
 

Protected Member Functions

std::stack< Indexbacktrack (const std::vector< Node > &exploredNodes, const Index &target)
 Generate path from the source to the target. More...
 

Detailed Description

Finds a path in a Grid2D using the Depth First Search algorithm.

Definition at line 36 of file DFS.h.

Constructor & Destructor Documentation

◆ DFS()

ime::DFS::DFS ( const Vector2u gridSize)
explicit

Initialize the algorithm.

Parameters
gridSizeSize of the grid in tiles

Member Function Documentation

◆ backtrack()

std::stack< Index > ime::IPathFinderStrategy::backtrack ( const std::vector< Node > &  exploredNodes,
const Index target 
)
protectedinherited

Generate path from the source to the target.

Parameters
exploredNodesNodes explored after algorithm termination
targetThe index of the target tile in the grid
Returns
The path from the source to the target tile if found, otherwise an empty path

◆ findPath()

std::stack< Index > ime::DFS::findPath ( const Grid2D grid,
const Index sourceTile,
const Index targetTile 
)
overridevirtual

Generate a path from a source tile to a target tile in a grid.

Parameters
gridGrid to find path in
sourceTileThe position of the starting position in tiles
targetTileThe position of the destination in tiles
Returns
The path from the source to the destination if reachable, otherwise an empty path

Implements ime::IPathFinderStrategy.

◆ getType()

std::string ime::DFS::getType ( ) const
overridevirtual

Get the type of path finding algorithm.

Returns
The type of the path finding algorithm

Implements ime::IPathFinderStrategy.


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