os.c
changeset 12 a2c334a71a6b
parent 10 9148590f009d
child 14 086a72472196
equal deleted inserted replaced
11:dcfe4d2d4387 12:a2c334a71a6b
   121 			printf("%c", Temp.ManMoves[j][i]);
   121 			printf("%c", Temp.ManMoves[j][i]);
   122 		printf("\n");
   122 		printf("\n");
   123 	}
   123 	}
   124 #endif
   124 #endif
   125 
   125 
   126 	printf("Man is at (%i,%i)\n", Temp.Man.x, Temp.Man.y);
   126 	fprintf(stderr,"Man is at (%i,%i)\n", Temp.Man.x, Temp.Man.y);
   127 	printf("Platforms: %i, BoxesInPlatform: %i\n", Temp.NumPlatforms,
   127 	fprintf(stderr,"Platforms: %i, BoxesInPlatform: %i\n", Temp.NumPlatforms,
   128 			Temp.NumBoxesInPlatform);
   128 			Temp.NumBoxesInPlatform);
   129 
   129 
   130 }
   130 }
   131 
   131 
   132 void PrintMove(const struct BoxMove b)
   132 void PrintMove(const struct BoxMove b)
   133 {
   133 {
   134 	printf("Box: %i, Direction: {%i,%i}\n", b.box, b.dir.x, b.dir.y);
   134 	fprintf(stderr,"Box: %i, Direction: {%i,%i}\n", b.box, b.dir.x, b.dir.y);
   135 }
   135 }
   136 
   136 
   137 static void show_percent_callback(const int parameter)
   137 void show_percent_and_map()
   138 {
   138 {
   139 	fprintf(stderr, "Percent: %2.12f, depth: %i-%i\n", percent_to_show,
   139 	fprintf(stderr, "Percent: %2.12f, depth: %i-%i\n", percent_to_show,
   140 		min_depth_period, max_depth_period);
   140 		min_depth_period, max_depth_period);
   141 	ShowMap(actual_map);
   141 	ShowMap(actual_map);
   142 	fflush(stderr);
   142 	fflush(stderr);
   143 	min_depth_period = MAX_STEPS;
   143 	min_depth_period = MAX_STEPS;
   144 	max_depth_period = 0;
   144 	max_depth_period = 0;
   145 #ifndef DEBUG
   145 }
       
   146 
       
   147 static void show_percent_callback(const int parameter)
       
   148 {
       
   149 	show_percent_and_map();
   146 	alarm(ALARM_SECONDS);
   150 	alarm(ALARM_SECONDS);
   147 #endif
       
   148 }
   151 }
   149 
   152 
   150 static void program_alarm()
   153 static void program_alarm()
   151 {
   154 {
   152         struct sigaction my_action;
   155         struct sigaction my_action;
   162 	alarm(1);
   165 	alarm(1);
   163 }
   166 }
   164 
   167 
   165 void init_os()
   168 void init_os()
   166 {
   169 {
       
   170 #ifndef DEBUG
   167 	program_alarm();
   171 	program_alarm();
       
   172 #endif
   168 }
   173 }
       
   174