Class which represents single player map.
More...
#include <SinglePlayerMap.h>
|
int | move_sokoban (int v_x, int v_y) |
| General method for sokoban movement. More...
|
|
bool | solve (int steps) |
| Tries to solve puzzle (backtracking) with at most MAX_STEPS. More...
|
|
Class which represents single player map.
◆ SinglePlayerMap()
SinglePlayerMap::SinglePlayerMap |
( |
std::ifstream & |
map_stream | ) |
|
Constructor.
Creates the sigle player map from the input file. It uses the constructor from ancestor to reach it.
- See also
- Map::Map()
- Exceptions
-
- Parameters
-
map_stream | Input stream which the map is made from. |
◆ complete()
bool SinglePlayerMap::complete |
( |
| ) |
|
|
inlineoverridevirtual |
Checks if map is completed (all barrels are on targets).
- Returns
- Bool value which determines if map is completed.
Implements Map.
◆ down_move()
void SinglePlayerMap::down_move |
( |
| ) |
|
|
inlineoverridevirtual |
Moves the sokoban down if it is possible.
Implements Map.
◆ down_move_second()
void SinglePlayerMap::down_move_second |
( |
| ) |
|
|
inlineoverridevirtual |
This method does nothing. There is no second sokoban
Implements Map.
◆ get_field_type()
element SinglePlayerMap::get_field_type |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
|
inlineoverridevirtual |
Gets type of cell.
- Parameters
-
x | The coordinate x of cell. |
y | The coordinate y of cell. |
- Returns
- Byte number which represents field type according to the constants.
Implements Map.
◆ is_dead_position()
bool SinglePlayerMap::is_dead_position |
( |
| ) |
|
|
overridevirtual |
Determines if in actual state of game is possible to move with all barrels.
- Returns
- Bool value which determines if in actual state of game is possible to move with all barrels.
Implements Map.
◆ left_move()
void SinglePlayerMap::left_move |
( |
| ) |
|
|
inlineoverridevirtual |
Moves the sokoban to the left if it is possible.
Implements Map.
◆ left_move_second()
void SinglePlayerMap::left_move_second |
( |
| ) |
|
|
inlineoverridevirtual |
This method does nothing. There is no second sokoban
Implements Map.
◆ move_sokoban()
int SinglePlayerMap::move_sokoban |
( |
int |
v_x, |
|
|
int |
v_y |
|
) |
| |
|
private |
General method for sokoban movement.
The direction is defined by vector. Tries to move sokoban in defined direction
- Parameters
-
v_x | The part x of vector which represents move direction of Sokoban. It may be -1,0 or 1. |
v_y | The part x of vector which represents move direction of Sokoban. It may be -1,0 or 1. |
- Returns
- 0 if Sokoban was moved, -1 if Sokoban cannot be moved
◆ play_solution_next()
bool SinglePlayerMap::play_solution_next |
( |
| ) |
|
|
inlineoverridevirtual |
If map is solved do next step in solution.
- Returns
- True if map is sloved and steps is done, false if map is not solved yet.
Implements Map.
◆ restart()
void SinglePlayerMap::restart |
( |
| ) |
|
|
inlineoverridevirtual |
Restarts level.
Implements Map.
◆ right_move()
void SinglePlayerMap::right_move |
( |
| ) |
|
|
inlineoverridevirtual |
Moves the sokoban to the right if it is possible.
Implements Map.
◆ right_move_second()
void SinglePlayerMap::right_move_second |
( |
| ) |
|
|
inlineoverridevirtual |
This method does nothing. There is no second sokoban
Implements Map.
◆ solve() [1/2]
bool SinglePlayerMap::solve |
( |
| ) |
|
|
inlineoverridevirtual |
Tries to solve map using backtracking.
- Returns
- Bool value which determines if map was solved.
Implements Map.
◆ solve() [2/2]
bool SinglePlayerMap::solve |
( |
int |
steps | ) |
|
|
private |
Tries to solve puzzle (backtracking) with at most MAX_STEPS.
The solution is in vector solution.
- Parameters
-
steps | Number of steps from previous recursion step. |
- Returns
- if solving succeed
◆ up_move()
void SinglePlayerMap::up_move |
( |
| ) |
|
|
inlineoverridevirtual |
Moves the sokoban up if it is possible.
Implements Map.
◆ up_move_second()
void SinglePlayerMap::up_move_second |
( |
| ) |
|
|
inlineoverridevirtual |
This method does nothing. There is no second sokoban
Implements Map.
◆ play_position
int SinglePlayerMap::play_position |
|
private |
Variable determining which step from solution should be made while solution is playing.
◆ solution
std::vector<std::tuple<int, int> > SinglePlayerMap::solution |
|
private |
A sequence of steps defined by vector for solving puzzle
◆ start_state
Default state of game - for restart.
◆ state
State of game including a position of sokoban and position of barrels.
◆ visited
std::map<std::string, int> SinglePlayerMap::visited |
|
private |
The list of visited states (and number of steps which are visited in) for backtracking.
The documentation for this class was generated from the following file: