ref: cd0a928d7782f41736f5d1cd2dafdf950da5b6b4
dir: /engine.h/
enum
{
	/* difficulty levels (how many circles are initially occupied) */
	DEasy,	/* 10≤x<15 */
	DMed,	/* 5≤x<10 */
	DHard,	/* 1≤x<5 */
	DImp, /* 0 */
	/* dynamic? original game has a fixed grid size, but we don't need to abide by it */
	SzX = 11,
	SzY = 11,
	/* movement directions */
	NE,
	E,
	SE,
	SW,
	W,
	NW,
	/* player types */
	Human = 0,
	Computer,
	Net,
	PTrapper = 0,	
	PGlenda,
	PRandom,
	/* game states */
	STATE_CONNECT = 0,
	STATE_INIT, /* setting up the map */
	STATE_START,
	STATE_PLAYING,
	STATE_WON,	
	STATE_LOST,
	STATE_FINISHED, /* for server */
	PIECE_PREV = 100, /* technically a empty block, but often avoided so glenda wont look silly */
	PIECE_WALL = 999,
	PIECE_GLENDA = 1000,
	Err = 0,
	Ok,
};
typedef struct Game
{
	/* engine.c */
	int difficulty;
	int state;
	int turn;
	int ptype[2]; /* Human or Computer? */
	
	int grid[SzX][SzY];
	int pgrid[SzX][SzY]; /* for undo */
	int ogrid[SzX][SzY]; /* so we can restart levels */
	
	/* net.c */
	/* we maybe be able to merge all this into one bit-array */
	int waitbit; /* 0 is go, 1 is wait */
	int networked; /* 0 is local, 1 is networked */
}Game;
/* client code */
int debug;
int pside; /* Trapper, Glenda */
/* engine code */
void initlevel(Game *game);
Point pointdir(int dir, Point p);
int finddir(Point src, Point dst);
Point findglenda(Game *game);
int domove(Game *game, int dir);
int doput(Game *game, Point p);
int score1(Game *game, Point p);
void calc(Game *game);
void nextglenda(Game *game);
int findmin(Game *game, Point p);
int checkstate(Game *game);
int isplaying(Game *game);
void restart(Game *game);
void undo(Game *game);