Sokoban
|
Class which represents map for two players. More...
#include <Map.h>
Public Member Functions | |
TwoPlayerMap (std::ifstream &map_stream) | |
Constructor. More... | |
bool | complete () override |
Checks if map is completed (all barrels are on targets). More... | |
void | restart () override |
Restarts level. More... | |
bool | solve () override |
This method does nothing. More... | |
bool | play_solution_next () override |
This method does nothing. More... | |
element | get_field_type (int x, int y) override |
Gets type of cell. More... | |
bool | is_dead_position () override |
This method does nothing. More... | |
void | right_move () override |
void | left_move () override |
void | up_move () override |
void | down_move () override |
void | right_move_second () override |
void | left_move_second () override |
void | up_move_second () override |
void | down_move_second () override |
![]() | |
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... | |
Private Member Functions | |
int | move_sokoban (int v_x, int v_y, bool first_sokoban=true) |
General method for sokoban movement. More... | |
Private Attributes | |
TwoPlayerGameState | state |
TwoPlayerGameState | start_state |
Additional Inherited Members | |
![]() | |
static const char | NUMBER_OF_FIELDS = 10 |
static const int | MAX_STEPS = 1000 |
static const char | EOM = 'x' |
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 |
![]() | |
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... | |
![]() | |
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... | |
Class which represents map for two players.
Some of the general methods which are inherrited does nothing.
TwoPlayerMap::TwoPlayerMap | ( | std::ifstream & | map_stream | ) |
Constructor.
Creates the two player map from the input file. It uses the constructor from ancestor to reach it.
map_stream | Input stream which the map is made from. |
|
inlineoverridevirtual |
Checks if map is completed (all barrels are on targets).
Implements Map.
|
inlineoverridevirtual |
Moves the first sokoban down if it is possible.
Implements Map.
|
inlineoverridevirtual |
Moves the second sokoban down if it is possible.
Implements Map.
|
inlineoverridevirtual |
Gets type of cell.
x | The coordinate x of cell. |
y | The coordinate y of cell. |
Implements Map.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Moves the first sokoban to the left if it is possible.
Implements Map.
|
inlineoverridevirtual |
Moves the second sokoban to the left if it is possible
Implements Map.
|
private |
General method for sokoban movement.
The direction is defined by vector.
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. |
first_sokoban | Determines if it is the movement of the first sokoban. |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Restarts level.
Implements Map.
|
inlineoverridevirtual |
Moves the first sokoban to the right if it is possible.
Implements Map.
|
inlineoverridevirtual |
Moves the second sokoban to the right if it is possible
Implements Map.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Moves the first sokoban up if it is possible.
Implements Map.
|
inlineoverridevirtual |
Moves the second sokoban up if it is possible.
Implements Map.
|
private |
Default state of game - for restart
|
private |
State of game including a position of sokoban and position of barrels.