Skip to content

Instantly share code, notes, and snippets.

@meric
Created March 19, 2011 10:59
Show Gist options
  • Save meric/877389 to your computer and use it in GitHub Desktop.
Save meric/877389 to your computer and use it in GitHub Desktop.
#include "util.h"
#include "vector.h"
#include "spot.h"
#ifndef MINEFIELD_H
#define MINEFIELD_H
/* define a minefield type */
typedef struct
{
size size;
spot spots[400]; /* max number of cell in minefield */
} minefield;
/* create a new minefield */
minefield minefield_new(size s);
/* get the spot of m with location loc */
spot minefield_spot(minefield m, vector loc);
/* create a copy of m with spot at loc set */
minefield minefield_spot_set(minefield m, vector loc, spot s);
/* get the flagged of spot at loc */
BOOL minefield_flagged_at(minefield m, vector loc);
/* create a copy of m with flagged of spot at loc set */
minefield minefield_flagged_at_set(minefield m, vector loc, BOOL flagged);
/* get the revealed of spot at loc */
BOOL minefield_revealed_at(minefield m, vector loc);
/* create a copy of m with revealed of spot at loc set */
minefield minefield_revealed_at_set(minefield m, vector loc, BOOL revealed);
/* get the has_mine of spot at loc */
BOOL minefield_has_mine_at(minefield m, vector loc);
/* create a copy of m with has_mine of spot at loc set */
minefield minefield_has_mine_at_set(minefield m, vector loc, BOOL has_mine);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment