general.h
author viric@llimona
Sun, 07 May 2006 13:34:25 +0200
changeset 25 b37843173279
parent 10 9148590f009d
child 26 95fccfcbd04c
permissions -rw-r--r--
Porting from sokoban/caixes the show_map changes.
Corrects possible sigsegv because of actual_map.
Better separation of sigalarm display / not-signal display.
#define BOX '$'
#define WALL '#'
#define MAN '@'
#define PLATFORM '.'
#define BOXINPLATFORM '*'
#define MANINPLATFORM 'E'
#define BLANK ' '
#define CORNER '-'
#define MANCANMOVE '+'

/* #define DEBUG */

enum
{
	ALARM_SECONDS=1,
	MAX_X=50,
	MAX_Y=50,
	MAX_MOVES=50,
	MAX_STEPS=50,
	MAX_BOXES=15
};


enum logic
{
	TRUE=1,
	FALSE=0
};

struct Position
{
	int x;
	int y;
};

struct Map
{
	char Cells[MAX_Y][MAX_X];
	char cells_boxes[MAX_Y][MAX_X];
	char man_moves[MAX_Y][MAX_X];
	int SizeX, SizeY;
	struct Position Man;
	int NumPlatforms;
	int NumBoxesInPlatform;
	struct Position Box[MAX_BOXES];
	int NumBoxes;
};



enum e_direction
{
	DIR_LEFT,
	DIR_RIGHT,
	DIR_DOWN,
	DIR_UP
};

static const struct Position move_vectors[4] = {
	{0, 1},
	{0, -1},
	{1, 0},
	{-1, 0}};

struct BoxMove
{
	int box;
	struct Position dir;
};


/* Prototypes for map managing
 * map.c */
void CopyMap (struct Map *Mdest, const struct Map *Morig);
int is_new_map(const struct Map maps[], const int depth);

/* Prototypes for unix i/o, processes
 * os.c */
void ReadMap(struct Map *M, char *FileName);
void ShowMap (const struct Map *M);
void init_os();
void PrintMove(struct BoxMove b);
void show_percent_and_map();

/* Functions related to map solution
 * algorithm.c */
int solve_map(const struct Map origin);