general.h
author viric@llimona
Sat, 17 Feb 2007 15:14:30 +0100
changeset 28 cd27cb410375
parent 26 95fccfcbd04c
permissions -rw-r--r--
Recursivity changed into a loop. Now the state is loaded on boot, and saved on TERM.
viric@4
     1
#define BOX '$'
viric@4
     2
#define WALL '#'
viric@4
     3
#define MAN '@'
viric@4
     4
#define PLATFORM '.'
viric@4
     5
#define BOXINPLATFORM '*'
viric@4
     6
#define MANINPLATFORM 'E'
viric@4
     7
#define BLANK ' '
viric@4
     8
#define CORNER '-'
viric@4
     9
#define MANCANMOVE '+'
viric@4
    10
viric@8
    11
/* #define DEBUG */
viric@4
    12
viric@4
    13
enum
viric@4
    14
{
viric@4
    15
	ALARM_SECONDS=1,
viric@28
    16
	MAX_X=13,
viric@28
    17
	MAX_Y=13,
viric@28
    18
	MAX_MOVES=10,
viric@4
    19
	MAX_STEPS=50,
viric@28
    20
	MAX_BOXES=10
viric@4
    21
};
viric@4
    22
viric@4
    23
viric@4
    24
enum logic
viric@4
    25
{
viric@4
    26
	TRUE=1,
viric@8
    27
	FALSE=0
viric@4
    28
};
viric@4
    29
viric@4
    30
struct Position
viric@4
    31
{
viric@4
    32
	int x;
viric@4
    33
	int y;
viric@4
    34
};
viric@4
    35
viric@4
    36
struct Map
viric@4
    37
{
viric@4
    38
	char Cells[MAX_Y][MAX_X];
viric@4
    39
	char cells_boxes[MAX_Y][MAX_X];
viric@4
    40
	char man_moves[MAX_Y][MAX_X];
viric@4
    41
	int SizeX, SizeY;
viric@4
    42
	struct Position Man;
viric@4
    43
	int NumPlatforms;
viric@4
    44
	int NumBoxesInPlatform;
viric@4
    45
	struct Position Box[MAX_BOXES];
viric@4
    46
	int NumBoxes;
viric@4
    47
};
viric@4
    48
viric@4
    49
viric@4
    50
viric@4
    51
enum e_direction
viric@4
    52
{
viric@4
    53
	DIR_LEFT,
viric@4
    54
	DIR_RIGHT,
viric@4
    55
	DIR_DOWN,
viric@4
    56
	DIR_UP
viric@4
    57
};
viric@4
    58
viric@4
    59
static const struct Position move_vectors[4] = {
viric@4
    60
	{0, 1},
viric@4
    61
	{0, -1},
viric@4
    62
	{1, 0},
viric@4
    63
	{-1, 0}};
viric@4
    64
viric@4
    65
struct BoxMove
viric@4
    66
{
viric@4
    67
	int box;
viric@4
    68
	struct Position dir;
viric@4
    69
};
viric@4
    70
viric@4
    71
viric@9
    72
/* Prototypes for map managing
viric@9
    73
 * map.c */
viric@4
    74
void CopyMap (struct Map *Mdest, const struct Map *Morig);
viric@10
    75
int is_new_map(const struct Map maps[], const int depth);
viric@6
    76
viric@9
    77
/* Prototypes for unix i/o, processes
viric@9
    78
 * os.c */
viric@4
    79
void ReadMap(struct Map *M, char *FileName);
viric@4
    80
void ShowMap (const struct Map *M);
viric@6
    81
void init_os();
viric@28
    82
void PrintMoves(const struct BoxMove *b, const int *steps, const int depth);
viric@25
    83
void show_percent_and_map();
viric@28
    84
void save_state();
viric@28
    85
int load_state();
viric@28
    86
void show_tries(const int d);
viric@6
    87
viric@9
    88
/* Functions related to map solution
viric@9
    89
 * algorithm.c */
viric@26
    90
int solve_map(const struct Map *origin);