mp_puzzle
Perplexing Puzzles
|
Implementation of puzzle class. More...
Classes | |
class | PuzzleState |
Functions | |
std::vector< PuzzleState > | solveBFS (const PuzzleState &startState, const PuzzleState &desiredState, size_t *iterations=NULL) |
Solves the puzzle using BFS. More... | |
std::vector< PuzzleState > | solveAstar (const PuzzleState &startState, const PuzzleState &desiredState, size_t *iterations=NULL) |
Solves the puzzle using A* with manhattan distance as a heuristic. More... | |
std::ostream & | operator<< (std::ostream &os, const PuzzleState &puzzle) |
Overloaded operator<< for the puzzle state, you can use this to print the puzzle. More... | |
Implementation of puzzle class.
|
inline |
Overloaded operator<< for the puzzle state, you can use this to print the puzzle.
std::vector< PuzzleState > solveAstar | ( | const PuzzleState & | startState, |
const PuzzleState & | desiredState, | ||
size_t * | iterations = NULL |
||
) |
Solves the puzzle using A* with manhattan distance as a heuristic.
startState | The starting state of the puzzle |
desiredState | The final goal state of the puzzle after solving |
iterations | The number of iterations it took to solve the puzzle. An iteration is defined as the number of times a state is popped from the data structure (NOTE: this should include the start and desired states, but not any states that are immediately discarded, if applicable). We will use the value stored at this pointer to evaluate efficiency. Ignore if NULL. |
std::vector< PuzzleState > solveBFS | ( | const PuzzleState & | startState, |
const PuzzleState & | desiredState, | ||
size_t * | iterations = NULL |
||
) |
Solves the puzzle using BFS.
startState | The starting state of the puzzle |
desiredState | The final goal state of the puzzle after solving |
iterations | The number of iterations it took to solve the puzzle. An iteration is defined as the number of times a state is popped from the data structure (NOTE: this should include the start and desired states, but not any states that are immediately discarded, if applicable). We will use the value stored at this pointer to evaluate efficiency. Ignore if NULL. |