Search algorithms for the 8-puzzle solution
|
Memoryless solver that randomly searches the state space. More...
#include <MonteCarloSolver.hpp>
Public Member Functions | |
MonteCarloSolver () | |
LinkedList< GameState * > | solve (Game &game, GameState &g0) |
Explores the game tree in search of the goal state. More... | |
![]() | |
double | getSecondsToSolve () const |
int | getVisitedNodes () const |
int | getMaxDepth () const |
int | getSolutionDepth () const |
bool | isSolved () |
Solver () | |
string | to_string () |
Generates a string containing useful information from the solver run. More... | |
Private Member Functions | |
int | rnd (int max) |
Private Attributes | |
mt19937_64 | r |
Additional Inherited Members | |
![]() | |
bool | isVisited (GameState &g) |
Checks whether a node has already been visited by the solver. More... | |
LinkedList< GameState * > | visit (GameState *current) |
LinkedList< GameState * > | visit (GameState *current, bool keepVisited) |
Visit a game state, adding it to the list of visited states and returning its valid child states. More... | |
LinkedList< GameState * > | endSearch (GameState *currentGame, const clock_t start) |
End the search, generating the steps from the initial state to the goal. More... | |
![]() | |
OrderedList< GameState * > | visited = OrderedList<GameState *>(compare) |
int | visitedNodes |
int | maxDepth |
int | solutionDepth |
float | secondsToSolve |
bool | solved |
Memoryless solver that randomly searches the state space.
Definition at line 15 of file MonteCarloSolver.hpp.
|
inline |
Definition at line 24 of file MonteCarloSolver.hpp.
|
inlineprivate |
Definition at line 19 of file MonteCarloSolver.hpp.
Explores the game tree in search of the goal state.
Exploration is done by applying one of the four valid actions of the 8-puzzle to intermediate, non-goal states until the goal state is reached.
g | A description of the game. |
gs | The initial state of the game. |
Implements Solver.
Definition at line 29 of file MonteCarloSolver.hpp.
|
private |
Definition at line 17 of file MonteCarloSolver.hpp.