Пример #1
0
int* Voronoi::calculate(int player)
{
	int* result = new int[2];

	breadth(1);
	resetMark();
	breadth(3);

	getMerge(player);
	

	oneChamber = new Chamber(&(this->vor),1,grid->getPlayerOneHeadX(),grid->getPlayerOneHeadY());

	int one = oneChamber->getValue();

	twoChamber = new Chamber(&(this->vor),3,grid->getPlayerTwoHeadX(),grid->getPlayerTwoHeadY());

	int two  = twoChamber->getValue();
	
	/*
	int one_excess = abs(onered-oneblack);// meed to check thhes red black squares and whether they are actually valid
	int two_excess = abs(twored - twoblack);

	if(vor[0][0] < 0) one_spot++; else if(vor[0][0]>0) two_spot++;
	if(vor[width-1][0]<0) one_spot++; else if(vor[width-1][0]>0) two_spot++;


	if(one_excess/(float)one_spot >=0.1) // need to think this part out
		one *= (float)one_excess/one_spot;
	if(two_excess/(float)two_spot >=0.1)
		two *= (float)two_excess/two_spot;
	*/

	result[0] = one-two;
	result[1] = two-one;
	
	return result;
}
Пример #2
0
 path findPath(const T& s, const T& t) const {
     std::map<T, T> destinyMap = breadth(s);
     if (destinyMap.find(t) == destinyMap.end())
         return path();
     path p;
     T v = t;
     while(v != s) {
         p.push_back(v);
         v = destinyMap[v];
     }
     p.push_back(v);
     std::reverse(p.begin(), p.end());
     return p;
 }
Пример #3
0
int main(void)
{
	char houhou;
	int i,j;
	int a[N+1][N+1];
   
	printf("グラフを隣接行列表現で入力してください\n(i×j行列 辺(i,j)が存在すれば1,そうでなければ0)\n");
	printf("ノードは8個です\n\n");
	printf("※1行目と1列目は「0」がすでに入力されています");
	//do{
	for(i = 0; i <= N; i++) 
	{
		a[0][i] = 0;
		a[i][0] = 0;
	}
	
	
    for(i=1;i<=N;i++){
	 modoru:   printf("\n\n%dつ目のノードについて入力してください\n",i);
    for(j=1;j<=N;j++){
        a[i][j] = getche();
	    if(a[i][j] == 48) a[i][j] = 0;
	    else if(a[i][j] == 49) a[i][j] = 1;
	    else 
	    {
		 printf("入力しなおしてください"); goto modoru;
	    }
	}
	}
	
	//}while(i<N);
	printf("\n\n探索するグラフの隣接行列表現\n");
	for(i=0; i<=N; i++)
	{
		for(j = 0; j<=N;j++)
		{
			printf("%d",a[i][j]);
		}
		printf("\n");
	}
	printf("\n\n");

	printf("探索方法を選択してください(深さ:d, 幅:b):");
	scanf(" %c",&houhou);

	switch(houhou)
	{
		case 'd':
			{
				int i,start;
				printf("どのノードから探索しますか?:");
				scanf("%d",&start);
				/* 訪問フラグを初期化する */
				for(i = 1; i <= N; i++)
		     	    v[i] = 0;

				depth( start , a); // 出発点をノード 1として探索開始
			}
			break;

		case 'b':
			breadth(a);
			break;

	}
	printf("\n");
	return 0;

}
Пример #4
0
	int is_on_cuboid ( GLfloat ax, GLfloat ay )
	{
		if (ax>=centre_x && ax<=centre_x+length() && ay>=centre_y && ay<=centre_y+breadth())
			return 1;
		return 0;
	}