general.h
changeset 12 a2c334a71a6b
parent 10 9148590f009d
child 17 7c1e68c17c0e
--- a/general.h	Sun May 07 01:30:29 2006 +0200
+++ b/general.h	Sun May 07 01:31:50 2006 +0200
@@ -8,7 +8,7 @@
 #define CORNER '-'
 #define MANCANMOVE '+'
 
-/* #define DEBUG */
+/*#define DEBUG */
 
 enum
 {
@@ -21,11 +21,12 @@
 };
 
 
-enum logic
+enum eBool
 {
-	TRUE=1,
+	TRUE=!0,
 	FALSE=0
 };
+typedef enum eBool Bool;
 
 struct Position
 {
@@ -33,34 +34,55 @@
 	int y;
 };
 
+#define add_position2(a, b) {a.x += b.x; a.y += b.y;}
+#define add_position3(dest, a, b) {(dest).x = (a).x + (b).x; \
+				   (dest).y = (a).y + (b).y;}
+
+enum box_freedom
+{
+	FREE=-1,
+	BLOCKED=-2
+};
+
+struct tbox_free
+{
+	/* -1, without dependency in that direction. */
+	/* -2, without dependency in that direction. */
+	enum box_freedom dep_dir[4];
+};
+
 struct Map
 {
-	char Cells[MAX_Y][MAX_X];
-	char cells_boxes[MAX_Y][MAX_X];
-	char man_moves[MAX_Y][MAX_X];
+	char Cells[MAX_Y][MAX_X]; /* Stores WALLs and PLATFORMs */
+	char cells_boxes[MAX_Y][MAX_X]; /* Stores the box number in that cell */
+					/* -1 is NO BOX there */
+	char man_moves[MAX_Y][MAX_X]; /* Stores boxes, walls, MANCANMOVEs */
+/*	int boxes[MAX_Y][MAX_X]; */
 	int SizeX, SizeY;
 	struct Position Man;
-	int NumPlatforms;
-	int NumBoxesInPlatform;
-	struct Position Box[MAX_BOXES];
+	int NumPlatforms;	/* This and the next determine when the game */
+	int NumBoxesInPlatform;	/* finished */
 	int NumBoxes;
+	struct Position Box[MAX_BOXES];	/* The box positions */
+	struct tbox_free box_deps[MAX_BOXES];	/* The dependencies for each
+						box*/
 };
 
 
-
 enum e_direction
 {
-	DIR_LEFT,
+	DIR_DOWN,
 	DIR_RIGHT,
-	DIR_DOWN,
-	DIR_UP
+	DIR_UP,
+	DIR_LEFT
 };
 
 static const struct Position move_vectors[4] = {
 	{0, 1},
+	{1, 0},
 	{0, -1},
-	{1, 0},
 	{-1, 0}};
+#define OPPOSITE_DIR(a) ((a+2)%4)
 
 struct BoxMove
 {
@@ -80,6 +102,7 @@
 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 */