Mosaic
Enumerations
game_ext.h File Reference

Extended Game Functions. More...

#include <stdbool.h>
#include "game.h"

Go to the source code of this file.

Enumerations

enum  neighbourhood { FULL , ORTHO , FULL_EXCLUDE , ORTHO_EXCLUDE }
 The different kind of neighbourhood. More...
 

Functions

Extended Functions
game game_new_ext (uint nb_rows, uint nb_cols, constraint *constraints, color *colors, bool wrapping, neighbourhood neigh)
 Creates a new game with extended options and initializes it. More...
 
game game_new_empty_ext (uint nb_rows, uint nb_cols, bool wrapping, neighbourhood neigh)
 Creates a new empty game with extended options. More...
 
uint game_nb_rows (cgame g)
 Gets the number of rows (or height). More...
 
uint game_nb_cols (cgame g)
 Gets the number of columns (or width). More...
 
bool game_is_wrapping (cgame g)
 Checks if the game has the wrapping option. More...
 
neighbourhood game_get_neighbourhood (cgame g)
 Gets the neighbourhood option. More...
 
void game_undo (game g)
 Undoes the last move. More...
 
void game_redo (game g)
 Redoes the last move. More...
 

Detailed Description

Extended Game Functions.

See Mosaic for further details.

Enumeration Type Documentation

◆ neighbourhood

The different kind of neighbourhood.

Enumerator
FULL 

All neighbours are considered.

ORTHO 

Only the orthogonal neighbours are considered.

FULL_EXCLUDE 

All neighbours are considered, except for the central square.

ORTHO_EXCLUDE 

Only the orthogonal neighbours are considered, except for the central square.

Function Documentation

◆ game_get_neighbourhood()

neighbourhood game_get_neighbourhood ( cgame  g)

Gets the neighbourhood option.

Returns
the neighbourhood option
Precondition
g is a valid pointer toward a cgame structure

◆ game_is_wrapping()

bool game_is_wrapping ( cgame  g)

Checks if the game has the wrapping option.

Returns
true, if wrapping option is enabled, false otherwise
Precondition
g is a valid pointer toward a cgame structure

◆ game_nb_cols()

uint game_nb_cols ( cgame  g)

Gets the number of columns (or width).

Parameters
gthe game
Returns
the the number of columns on this game
Precondition
g is a valid pointer toward a cgame structure

◆ game_nb_rows()

uint game_nb_rows ( cgame  g)

Gets the number of rows (or height).

Parameters
gthe game
Returns
the number of rows on this game
Precondition
g is a valid pointer toward a cgame structure

◆ game_new_empty_ext()

game game_new_empty_ext ( uint  nb_rows,
uint  nb_cols,
bool  wrapping,
neighbourhood  neigh 
)

Creates a new empty game with extended options.

All squares are initialized with empty squares.

Parameters
nb_rowsnumber of rows in game
nb_colsnumber of columns in game
wrappingwrapping option
neighneighbourhood option
Returns
the created game

◆ game_new_ext()

game game_new_ext ( uint  nb_rows,
uint  nb_cols,
constraint constraints,
color colors,
bool  wrapping,
neighbourhood  neigh 
)

Creates a new game with extended options and initializes it.

Parameters
nb_rowsnumber of rows in game
nb_colsnumber of columns in game
constraintsan array describing the initial constraint of each square using row-major storage (of size nb_rows*nb_cols)
colorsan array describing the initial color of each square using row-major storage (of size nb_rows*nb_cols) or NULL to set all colors as EMPTY
wrappingwrapping option
neighneighbourhood option
Precondition
constraints must be an initialized array of default size squared
colors must be an initialized array of default size squared or NULL
Returns
the created game

◆ game_redo()

void game_redo ( game  g)

Redoes the last move.

Searches in the history the last cancelled move (by calling game_undo), and replays it. If there are no more moves to be replayed, this function does nothing. After playing a new move with game_play_move, it is no longer possible to redo an old cancelled move.

Parameters
gthe game
Precondition
g is a valid pointer toward a cgame structure

◆ game_undo()

void game_undo ( game  g)

Undoes the last move.

Searches in the history the last move played (by calling game_play_move or game_redo), and restores the state of the game before that move. If no moves have been played, this function does nothing. The game_restart function clears the history.

Parameters
gthe game
Precondition
g is a valid pointer toward a cgame structure