Sokoban
|
Abstract class representing general map (ancestor for two player and single player map) and its api. More...
#include <Map.h>
Public Member Functions | |
virtual bool | complete ()=0 |
Checks if map is completed (all barrels are on targets). More... | |
virtual void | restart ()=0 |
Restarts level. More... | |
virtual | ~Map () |
Virtual destructor. More... | |
int | get_width () const |
Gets with of map (horizontal number of cells). More... | |
int | get_height () const |
Gets with of map (vertical number of cells). More... | |
virtual bool | solve ()=0 |
Tries to solve map using backtracking. More... | |
virtual bool | play_solution_next ()=0 |
If map is solved do next step in solution. More... | |
virtual element | get_field_type (int x, int y)=0 |
Gets type of cell. More... | |
virtual bool | is_dead_position ()=0 |
Determines if in actual state of game is possible to move with all barrels. More... | |
virtual void | right_move ()=0 |
virtual void | left_move ()=0 |
virtual void | up_move ()=0 |
virtual void | down_move ()=0 |
virtual void | right_move_second ()=0 |
virtual void | left_move_second ()=0 |
virtual void | up_move_second ()=0 |
virtual void | down_move_second ()=0 |
Static Public Attributes | |
static const char | NUMBER_OF_FIELDS = 10 |
static const int | MAX_STEPS = 1000 |
static const char | EOM = 'x' |
Constants which represents the number of game elements. They use easy arithmetics which is used in engine. | |
ground + barrel = barrel | |
static const element | GROUND = 0 |
static const element | TARGET = 1 |
static const element | BARREL = 2 |
static const element | BARREL_TARGET = 3 |
static const element | SOKOBAN = 4 |
static const element | SOKOBAN_TARGET = 5 |
static const element | WALL = 6 |
static const element | GRASS = 7 |
static const element | SOKOBAN_2 = 8 |
static const element | SOKOBAN_2_TARGET = 9 |
Protected Member Functions | |
Map (std::ifstream &map_stream) | |
Constructor. More... | |
bool | is_valid_position (int x, int y) |
Checks if position (x,y) is in map grid. More... | |
Protected Attributes | |
std::vector< std::vector< char > > | game_grid |
int | number_of_barrels |
int | width |
int | height |
TwoPlayerGameState | init_state |
Game state which is used by the constructor for general map including a position of sokoban and position of barrels. More... | |
Abstract class representing general map (ancestor for two player and single player map) and its api.
|
inlinevirtual |
Virtual destructor.
|
protected |
Constructor.
Creates general map from the input stream.
map_stream | Input stream which the map is made from. |
|
pure virtual |
Checks if map is completed (all barrels are on targets).
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Moves the first sokoban down if it is possible.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Moves the second sokoban down if it is possible.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Gets type of cell.
x | The coordinate x of cell. |
y | The coordinate y of cell. |
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
inline |
Gets with of map (vertical number of cells).
|
inline |
Gets with of map (horizontal number of cells).
|
pure virtual |
Determines if in actual state of game is possible to move with all barrels.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
inlineprotected |
Checks if position (x,y) is in map grid.
x | First position coordinate. |
y | Second position coordinate. |
|
pure virtual |
Moves the first sokoban to the left if it is possible.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Moves the second sokoban to the left if it is possible.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
If map is solved do next step in solution.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Restarts level.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Moves the first sokoban to the right if it is possible.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Moves the second sokoban to the right if it is possible.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Tries to solve map using backtracking.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Moves the first sokoban up if it is possible.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
pure virtual |
Moves the second sokoban up if it is possible.
Implemented in TwoPlayerMap, and SinglePlayerMap.
|
static |
|
static |
|
static |
|
protected |
Array which represents game grid.
|
static |
|
static |
|
protected |
Number of vertical fields of the map.
|
protected |
Game state which is used by the constructor for general map including a position of sokoban and position of barrels.
It is not used in concrete map. Information from it is copied to another variables
|
static |
Maximal number of steps in backtracking.
|
protected |
Number of barrels in the map.
|
static |
Number of game elements.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
protected |
Number of horizontal cells of the map.