|
Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
A class defining EightPuzzle/15-Puzzle game. More...
Public Member Functions | |
| uint32_t | get (size_t i, size_t j) const |
| get the value from i units from right and j units from left side of the board More... | |
| std::array< std::array< uint32_t, N >, N > | get_state () |
| Returns the current state of the board. More... | |
| size_t | get_size () const |
| returns the size of the EightPuzzle (number of row / column) More... | |
| EightPuzzle () | |
| Default constructor for EightPuzzle. More... | |
| EightPuzzle (const std::array< std::array< uint32_t, N >, N > &init) | |
| Parameterized Constructor for EightPuzzle. More... | |
| EightPuzzle (const EightPuzzle< N > &A) | |
| Copy constructor. More... | |
| EightPuzzle (const EightPuzzle< N > &&A) noexcept | |
| Move constructor. More... | |
| ~EightPuzzle ()=default | |
| Destructor of EightPuzzle. | |
| EightPuzzle & | operator= (const EightPuzzle &A) |
| Copy assignment operator. More... | |
| EightPuzzle & | operator= (EightPuzzle &&A) noexcept |
| Move assignment operator. More... | |
| std::vector< EightPuzzle< N > > | generate_possible_moves () |
| Find all possible states after processing all possible moves, given the current state of the puzzle. More... | |
| bool | operator== (const EightPuzzle< N > &check) const |
| check whether two boards are equal More... | |
| bool | operator< (const EightPuzzle< N > &check) const |
| check whether one board is lexicographically smaller More... | |
| bool | operator<= (const EightPuzzle< N > &check) const |
| check whether one board is lexicographically smaller or equal More... | |
Private Member Functions | |
| std::pair< uint32_t, uint32_t > | find_zero () |
| A helper array to evaluate the next state from current state;. More... | |
| bool | in_range (const uint32_t value) const |
| check whether the index value is bounded within the puzzle area More... | |
Private Attributes | |
| std::array< std::array< uint32_t, N >, N > | board |
| std::vector< std::pair< int8_t, int8_t > > | moves |
| N x N array to store the current state of the Puzzle. More... | |
Friends | |
| std::ostream & | operator<< (std::ostream &op, const EightPuzzle< N > &SomeState) |
| friend operator to display EightPuzzle<> More... | |
A class defining EightPuzzle/15-Puzzle game.
A well known 3 x 3 puzzle of the form ` 1 2 3 4 5 6 7 8 0 where0` represents an empty space in the puzzle Given any random state, the goal is to achieve the above configuration (or any other configuration if possible)
| N | size of the square Puzzle, default is set to 3 (since it is EightPuzzle) |
|
inline |
Default constructor for EightPuzzle.
|
inlineexplicit |
Parameterized Constructor for EightPuzzle.
| init | a 2-dimensional array denoting a puzzle configuration |
|
inline |
|
inlinenoexcept |
Move constructor.
| A | a reference of an EightPuzzle |
|
inlineprivate |
A helper array to evaluate the next state from current state;.
Finds an empty space in puzzle (in this case; a zero)
|
inline |
Find all possible states after processing all possible moves, given the current state of the puzzle.
|
inline |
get the value from i units from right and j units from left side of the board
| i | integer denoting ith row |
| j | integer denoting column |
|
inline |
|
inline |
Returns the current state of the board.
|
inlineprivate |
check whether the index value is bounded within the puzzle area
| value | index for the current board |
true if index is within the board, else false
|
inline |
check whether one board is lexicographically smaller
true if this->state is lexicographically smaller than check.state, else false
|
inline |
check whether one board is lexicographically smaller or equal
true if this->state is lexicographically smaller than check.state or same, else false
|
inline |
Copy assignment operator.
| A | a reference of an EightPuzzle |
|
inlinenoexcept |
Move assignment operator.
| A | a reference of an EightPuzzle |
|
inline |
check whether two boards are equal
true if check.state is equal to this->state, else false
|
friend |
|
private |
N x N array to store the current state of the Puzzle.