Esempio n. 1
0
	int ChooseBranch(const Rec *mbr, Node node)
	{
		int best = -1;
		double bestinc = -1;
		double bestfor = -1;
		for (int i = 0; i < node->count; i++)
		{
			Rec tmp = CombineRec(*mbr, ((node->branch[i]).mbr));
			double former = RecArea((node->branch[i]).mbr);
			double increment = RecArea(tmp) - former;
			if (best == -1 || isbetter(former, increment, bestinc, bestfor))
			{
				best = i;
				bestinc = increment;
				bestfor = former;
			}
		}
		return best;
	}
Esempio n. 2
0
void ws_maker(){
	//printf("%d\n",getMax());
	char *s = dictionary[getMax()];
	int len = strlen(s);
	input(MID-len/2,MID,s,DOWN);
	printf("0 %s\n",s);

	for(int i=0; i<dictSize-1-4;i++){
		int judge=0;
		s = dictionary[getMax()];

		getMaxAndMin_X_Y();
		int max=-1,x=0,y=0,d=0,sizeX = 1000, sizeY = 1000;
		for(int j=1;j<1000 ;j++){
			getWhere(j);
			int xxx,kongtime=0;      //xxx isbetter 返回
			int bd = getDirect(a[0],a[1]);
			for(int k=0; k<8; k++){

				xxx = isbetter(a[0],a[1],s,(bd+k-1)%8);

				if(xxx == -2){
					kongtime++;
					xxx = 0;
				}
				if(xxx == -1)
					continue;

				if(max_x - min_x > max_y - min_y){
					if(max_x_new <= max_x && min_x_new >= min_x){
						if(max_y_new - min_y_new < sizeY){
							x = a[0];
							y = a[1];
							d = (bd+k-1)%8;
							max = xxx;
							sizeY = max_y_new - min_y_new;
						}
						else if( max_y_new - min_y_new == sizeY ){
							if(max < xxx){
								x = a[0];
								y = a[1];
								d = (bd+k-1)%8;
								max = xxx;
							}
						}
					}

				}
				else{
					if(max_y_new <= max_y && min_y_new >= min_y){
						if(max_x_new - min_x_new < sizeX){
							x = a[0];
							y = a[1];
							d = (bd+k-1)%8;
							max = xxx;
							sizeX = max_x_new - min_x_new;
						}
						else if( max_x_new - min_x_new == sizeX ){
							if(max < xxx){
								x = a[0];
								y = a[1];
								d = (bd+k-1)%8;
								max = xxx;
							}
						}
					}
				}


				
			}
			if(kongtime == 8)
				break;
		}
		// if(debug){
		// 	printf("%d %d %d %s %d\n",i+1,x,y,s,d);
		// }
		input(x,y,s,d);
	}
}