Mosaic
game.h
Go to the documentation of this file.
1
8#ifndef __GAME_H__
9#define __GAME_H__
10
11#include <stdbool.h>
12
16typedef unsigned int uint;
17
21#define DEFAULT_SIZE 5
22
24typedef enum
25{
28 BLACK
30
42typedef enum
43{
48
65typedef enum
66{
71
76typedef enum
77{
78 HERE,
79 UP,
80 DOWN,
81 LEFT,
82 RIGHT,
83 UP_LEFT,
84 UP_RIGHT,
85 DOWN_LEFT,
86 DOWN_RIGHT
87} direction;
88
92typedef struct game_s *game;
93
99typedef const struct game_s *cgame;
100
113game game_new(constraint *constraints, color *colors);
114
123
132
142bool game_equal(cgame g1, cgame g2);
143
150
166
182
195
208
222bool game_get_next_square(cgame g, uint i, uint j, direction dir, uint *pi_next, uint *pj_next);
223
233
250
264
277
287
288#endif // __GAME_H__
status
Definition: game.h:66
@ SATISFIED
Definition: game.h:69
@ ERROR
Definition: game.h:67
@ UNSATISFIED
Definition: game.h:68
bool game_won(cgame g)
Checks if the game is won.
bool game_equal(cgame g1, cgame g2)
Tests if two games are equal.
game game_copy(cgame g)
Duplicates a game.
color game_get_color(cgame g, uint i, uint j)
Gets the color of a given square.
color
Definition: game.h:25
@ WHITE
Definition: game.h:27
@ EMPTY
Definition: game.h:26
@ BLACK
Definition: game.h:28
void game_restart(game g)
Restarts a game.
void game_play_move(game g, uint i, uint j, color c)
Plays a move in a given square.
game game_new(constraint *constraints, color *colors)
Creates a new game with default size and initializes it.
struct game_s * game
The structure pointer that stores the game state.
Definition: game.h:92
bool game_get_next_square(cgame g, uint i, uint j, direction dir, uint *pi_next, uint *pj_next)
Gets the coordinate of the next square in a given direction.
constraint game_get_constraint(cgame g, uint i, uint j)
Gets the constraint of a given square.
unsigned int uint
Standard unsigned integer type.
Definition: game.h:16
direction
All possible directions in the game grid to explore the neighbourhood of a given square.
Definition: game.h:77
const struct game_s * cgame
The structure constant pointer that stores the game state.
Definition: game.h:99
constraint
Definition: game.h:43
@ MIN_CONSTRAINT
Definition: game.h:45
@ UNCONSTRAINED
Definition: game.h:44
@ MAX_CONSTRAINT
Definition: game.h:46
int game_nb_neighbors(cgame g, uint i, uint j, color c)
Returns the number of neighbors of the same color.
void game_set_color(game g, uint i, uint j, color c)
Sets the color of a given square.
void game_delete(game g)
Deletes the game and frees the allocated memory.
status game_get_status(cgame g, uint i, uint j)
Gets the square status.
game game_new_empty(void)
Creates a new empty game with defaut size.
void game_set_constraint(game g, uint i, uint j, constraint n)
Sets the constraint of a given square.