Knight-Path 1.0.D018
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions

solver Class Reference

#include <solver.h>

Inheritance diagram for solver:
solver_brute_force solver_maze solver_taxi

List of all members.

Public Types

typedef boost::shared_ptr< solverpointer
typedef std::list< positionlist_t

Public Member Functions

virtual ~solver ()
virtual list_t solve (const position &from, const position &to)=0

Static Public Member Functions

static pointer factory (const char *name)
static void list_algorithms (void)

Protected Member Functions

 solver ()

Private Member Functions

 solver (const solver &rhs)
solveroperator= (const solver &rhs)

Detailed Description

The solver abstract base class is used to represent an unspecified algorithm to solve the knight path problem in as few moves as possible.

Definition at line 31 of file solver.h.


Member Typedef Documentation

typedef std::list<position> solver::list_t

Definition at line 37 of file solver.h.

typedef boost::shared_ptr<solver> solver::pointer

Definition at line 35 of file solver.h.


Constructor & Destructor Documentation

solver::~solver ( ) [virtual]

The destructor.

Definition at line 22 of file solver.cc.

solver::solver ( ) [protected]

The default constructor. For use by derived classes only.

Definition at line 27 of file solver.cc.

solver::solver ( const solver rhs) [private]

The copy constructor. Do not use.

Parameters:
rhsThe right hand side of the initialization.

Member Function Documentation

solver::pointer solver::factory ( const char *  name) [static]

The factory class method is used to create new dynamically allocated instances of the named solver class.

Parameters:
nameThe name of the solver to be used.
Returns:
A pointer to a solver object.
Note:
If an unknown name is presented, a fatal error will be issued, and this class method will not return.

Definition at line 46 of file factory.cc.

void solver::list_algorithms ( void  ) [static]

The list_algorithms class method may be used to list the known algorithm names. This allows the user to choose an algorithm name to pass to the "-a" option.

Definition at line 61 of file factory.cc.

solver& solver::operator= ( const solver rhs) [private]

The assignment operator. Do not use.

Parameters:
rhsThe right hand side of the assignment.
virtual list_t solver::solve ( const position from,
const position to 
) [pure virtual]

The solve method is used to calculate the shortest path a knight piece must take between two given positions on a chess board. There are often several equally short paths, the first one found will be returned.

Parameters:
fromThe position at the start of the path.
toThe position at the end of the path.
Returns:
On success, a list of board positions will be returned; it will be a list of squares through which the Knight passes, the list will include the ending position, but will exclude the starting position (unless from == to). On error, (i.e. when no path is possible) an empty list will be returned.
Note:
Behaviour is undefined if either position is not valid.

Implemented in solver_brute_force, solver_maze, and solver_taxi.


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