Search algorithms for the 8-puzzle solution
Public Member Functions | Private Attributes
Game Class Reference

Class representing the rules of a game. More...

#include <Game.hpp>

Collaboration diagram for Game:

Public Member Functions

 ~Game ()
 
 Game (int dimension)
 Creates a game representation and keeps a GameState of the goal state. More...
 
GameStategetGoal () const
 

Private Attributes

GameStategoal
 

Detailed Description

Class representing the rules of a game.

Author
Douglas De Rizzo Meneghetti (dougl.nosp@m.asri.nosp@m.zzom@.nosp@m.gmai.nosp@m.l.com)
Date
2017-6-22Class representing the rules of a game. Used to generalize the search algorithms to any dimension of the 8-puzzle game.

Definition at line 15 of file Game.hpp.

Constructor & Destructor Documentation

◆ ~Game()

Game::~Game ( )
inline

Definition at line 22 of file Game.hpp.

22  {
23  delete goal;
24  }
GameState * goal
Definition: Game.hpp:18

◆ Game()

Game::Game ( int  dimension)
inlineexplicit

Creates a game representation and keeps a GameState of the goal state.

Parameters
dimensiondimensions of the puzzle board.

Definition at line 28 of file Game.hpp.

28  {
29  goal = new GameState();
30  int **representation = new int *[dimension];
31 
32  int val = 1;
33 
34  for (int x = 0; x < dimension; x ++) {
35  representation[x] = new int[dimension];
36 
37  for (int y = 0; y < dimension; y ++) {
38  representation[x][y] = val ++ % (dimension * dimension);
39  }
40  }
41 
42  goal->setRepresentation(representation);
43  }
void setRepresentation(int **representation)
Definition: GameState.hpp:328
Describes a single state in the 8-puzzle.
Definition: GameState.hpp:18
GameState * goal
Definition: Game.hpp:18
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ getGoal()

GameState* Game::getGoal ( ) const
inline

Definition at line 45 of file Game.hpp.

45  {
46  return goal;
47  }
GameState * goal
Definition: Game.hpp:18

Field Documentation

◆ goal

GameState* Game::goal
private

Definition at line 18 of file Game.hpp.


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