コード例 #1
0
ファイル: pne.cpp プロジェクト: Fontenotz/Penny-Pitch-OOP
void board::generation()
{
	srand(time(0));

	if (playerone.tosses<5)
	{
		playerone.x=rand()%10;
		playerone.y=rand()%10;

		if (pitch[playerone.y][playerone.x]=='P')
		{
			generation();
		}
		else
		{
			system("cls");
			scoring();
			pitch[playerone.y][playerone.x]='P';
			playerone.tosses++;
			showboard();
			cout<<"Score for that throw "<<playerone.throwscore<<endl;
			cout<<"Number of tosses "<<playerone.tosses<<"/5"<<endl;
			wait();
			system("pause");
			generation();
		}
	}
	else
	{
		system("cls");
	}

}
コード例 #2
0
ファイル: Docking.C プロジェクト: HeyJJ/DockingProject
void Docking::NachoptimierungR(Protein* p,int score,Vector3 shift_back, System s1){

	Protein copy1(*p, true);
	Protein* copy = &copy1;
	
	TranslationProcessor translation;
	Vector3 toOrigin = shift_back*(-1);
	translation.setTranslation(toOrigin);
	
	copy->apply(translation);
		
	srand(time(NULL));
	
	Matrix4x4 randomMatrix;
	
	//nachoptimierung nur minimal da score schon gut
	
	float angle = 1 + rand() %  (10 - 1 + 1);
	
	Angle randomAngle(angle, false);
	
	//Random Vektor als rotationsaxe
	int min = -3;
	int max = 3;
	
	float x = min + rand() % (max - min +1);
	float y = min + rand() % (max - min +1);
	float z = min + rand() % (max - min +1);
	
	Vector3 vec(x,y,z);
	
	randomMatrix.setRotation(randomAngle,vec);
	
	TransformationProcessor randomTransformation(randomMatrix);
	copy->apply(randomTransformation);
	
	TranslationProcessor translation2;
	translation2.setTranslation(shift_back);
	
	copy->apply(translation2);
	
	vector<Vector3> position  = data.savePositions(copy);

	float newscore = scoring(position);
	
	//nur wenn der score höher ist interessierr er uns
	if(newscore > score){

		System opt;
		opt.insert(*copy);
		data.writeFinalComplex(s1, opt, score, newscore);

	}

}
コード例 #3
0
ファイル: Scorer.cpp プロジェクト: FaithZL/DontCrash
void Scorer::update(float d){
    if (_car) {
        _car->update(d);
    }
    for(auto iter : _enemies){
        iter->update(d);
    }
    scoring(d);
    recordCircleCount(d);
    checkSameTrack();
    
}
コード例 #4
0
ファイル: Docking.C プロジェクト: HeyJJ/DockingProject
//Nachoptimierung ohne random elemente
void Docking::NachoptimierungEigen(Protein* p,int score,Vector3 v, System s1){
	
	Protein copy1(*p, true);
	Protein* copy = &copy1;
	
	TranslationProcessor translation;
	Vector3 vneg = v*(-1);
	translation.setTranslation(vneg);
	
	copy->apply(translation);
		
	Matrix4x4 Matrix;
	
	//nachoptimierung nur minimal da score schon gut
	
	float winkel = 7;
	
	Angle angle(winkel, false);
	
	//Random Vektor als rotationsaxe
	Vector3 axe(1,1,1);
	
	Matrix.setRotation(angle,axe);
	
	TransformationProcessor EigenTransformation(Matrix);
	copy->apply(EigenTransformation);
	
	
	TranslationProcessor translation2;
	
	translation2.setTranslation(v);
	
	copy->apply(translation2);
	
	
	vector<Vector3> pos = data.savePositions(copy);
	float newscore = scoring(pos);
	//nur wenn der score höher ist interessierr er uns
	if(newscore>score){
		System opt;
		opt.insert(*copy);
		int id = 1111; // zum erkennen dass es nachoptimiert wurde mit eigen
		data.writeFinalComplex(s1, opt, id, newscore);
	}
	
	

}
コード例 #5
0
ファイル: Docking.C プロジェクト: HeyJJ/DockingProject
void Docking::applyConformations(System s1, System s2){

	this->positionsA = data.savePositions(s1.getProtein(0));
	this->grid = createHashGrid();

	vector<Conformation>::iterator it = confList.begin();

	float min = 10000;
	float current = 10000;

	vector<tuple<Conformation, int, float>> listPos;

	vector<pair<int,Conformation>> scores;

	int currentPos = 0;
	float score;
	float schrankeScoring = 530 ;//Scoring Schranke TODO in der main in Abhängigkeit von Molekülgrößen definieren

	vector<Vector3> transPosB;

	for (; it != confList.end(); ++it){

		Protein copy1(*s2.getProtein(0), true);
		Protein* copy = &copy1;

		it->translateProtein(copy); //sollte über Pointer unser Protein verändern

		transPosB = data.savePositions(copy);

		score = scoring(transPosB); //scoring kann jetzt auf die transPosB zugreifen,da innerhalb der Klasse

		if (score > schrankeScoring){

				//sehr gute komplexe werden zusätzlich noch Nachoptimiert
				NachoptimierungR(copy,score,(*it).shiftBack,s1);
				scores.push_back(make_pair(score,*it));
		}

		++currentPos;

	}

//	conformations.close();

	//TODO LÖSCHNEN ALLES WAS MIT RMSD ZU TUN HAT!
	cout << "Number of complexes with score > " << schrankeScoring << ": "  << scores.size() << endl;

	//Sortiere Liste mit den guten Scores:

	sort(scores.begin(), scores.end(), pairSort);

	//Wähle k besten!
	vector<pair<int,Conformation>>::iterator sc_it = scores.begin();

	for (int k = 1; k < 31; ++k){

		if (sc_it == scores.end()) break;

		Protein copy1(*s2.getProtein(0), true);
		Protein* copy = &copy1;

		sc_it->second.translateProtein(copy);

		System s3;
		s3.insert(*copy);

		data.writeFinalComplex(s1, s3, k, sc_it->first);
		++sc_it;

	}
}
コード例 #6
0
ファイル: Docking.C プロジェクト: HeyJJ/DockingProject
void Docking::applywithRMSD(System s1, System s2){

	
	this->positionsA = data.savePositions(s1.getProtein(0));
	this->grid = createHashGrid();
	
	
	/*
	 * Für RMSD Berechnung: speichere Atom-Positionen von B in einem Vektor, um später mit translatierten Positionen vergleichen zu können!
	 *///TODO: löschen!!!
	this->positionsB = data.savePositions(s2.getProtein(0));
	
	RMSD rmsd (positionsB);

	//ofstream conformations;
	//conformations.open("ScoresChallenge.txt", ios::out);

	vector<Conformation>::iterator it = confList.begin();
	
	float minRMSD = 10000;
	float maxRMSD = -10000;
	float minwithScore = 10000;
	float maxwithScore = -10000;

	float minScore = 10000;
	float maxScore = -10000;
	float RMSDtominScore, RMSDtomaxScore;

	float current;

	vector<tuple<Conformation, int, float>> listPos;
	
	vector<pair<int,Conformation>> scores;
	
	//float schranke = 20;//RMSD Schranke
	
	int currentPos = 0;
	float score;
	float schrankeScoring = 500 ;//Scoring Schranke
	
	vector<Vector3> transPosB;

	for (; it != confList.end(); ++it){
		
		Protein copy1(*s2.getProtein(0), true);
		Protein* copy = &copy1;
		
		it->translateProtein(copy); //sollte über Pointer unser Protein verändern
		
		transPosB = data.savePositions(copy);
		
		score = scoring(transPosB); //scoring kann jetzt auf die transPosB zugreifen,da innerhalb der Klasse
		
		current = rmsd.calcRMSD(copy);
	//	conformations << "Score No. " << currentPos << ": " << score << " || RMSD: "<< current << endl;

/*		if (current < schranke){
			listPos.push_back(make_tuple(*it, currentPos, current));
		}
	*/
		
		if (current < minRMSD) {
			 minRMSD = current;
			 minwithScore = score;
		}
		//Zusammenhang zwischen scores und molelülgr
		if (current > maxRMSD) {
				maxRMSD = current;
				maxwithScore = score;
		}

		if (score < minScore) {
				 minScore = score;
				 RMSDtominScore = current;
			}
			//Zusammenhang zwischen scores und molelülgr
			if (score > maxScore) {
				 maxScore = score;
				 RMSDtomaxScore = current;
			}


		if (score > schrankeScoring){
				//sehr gute komplexe werden zusätzlich noch Nachoptimiert
				//NachoptimierungR(copy,score,(*it).shiftBack,s1);
				scores.push_back(make_pair(score,*it));
		}
	
		++currentPos;

	}
	
//	conformations.close();
	
	//TODO LÖSCHNEN ALLES WAS MIT RMSD ZU TUN HAT!
	//cout << "Number of complexes with score > " << schrankeScoring << ": "  << scores.size() << endl;
	cout << "Minimal RMSD: " << minRMSD  << " with Score: "  << minwithScore<< endl;
	cout << "Maximal RMSD: " << maxRMSD  << " with Score: " << maxwithScore << endl;

	cout << "Minimal Score: " << minScore << " with RMSD: " << RMSDtominScore << endl;
	cout << "Maximal Score: " << maxScore << " with RMSD: " << RMSDtomaxScore << endl;
	

	//Sortiere Liste mit den guten Scores:
	sort(scores.begin(), scores.end(), pairSort);

	//Wähle k besten!
	vector<pair<int,Conformation>>::iterator sc_it = scores.begin();

	for (int k = 1; k < 31; ++k){
		
		if (sc_it == scores.end()) break;
		
		Protein copy1(*s2.getProtein(0), true);
		Protein* copy = &copy1;

		sc_it->second.translateProtein(copy); 

		System s3;
		s3.insert(*copy);

		data.writeFinalComplex(s1, s3, k, sc_it->first);
		++sc_it;

	}

/*

		//TODO:Scoring 
		//und erst wenn alles passt die RMSD berechnen, 
		//die besten Komplexe zwischenspeichern, dann ranken und 
		//von den endgültigen die Dateien erstellen!

	int i = 0;
		for (vector<tuple<Conformation,int,float>>::iterator c_it = listPos.begin(); c_it != listPos.end(); ++c_it){
	
			if (i >= 30) break;
			Protein copy1(*s2.getProtein(0), true);
			Protein* copy = &copy1;

			get<0>(*c_it).translateProtein(copy); //sollte über Pointer unser Protein verändern

			System s3;
			s3.insert(*copy);

			data.writeComplex(s1, s3, get<1>(*c_it), get<2>(*c_it));
			++i;
		}
*/
}
コード例 #7
0
ファイル: postp.old.c プロジェクト: ivanamihalek/c-utils
int main ( int argc, char * argv[]) {

    Options options;
    Protein protein;
    Alignment * alignment = NULL;
    int retval;
    int almtctr1, almtctr2;
    double **score = NULL, corr,  pctg_gaps;
    double **clustering_score = NULL;
    double *area, *distance;
    int **rank_order= NULL,**res_rank=NULL,**int_cvg=NULL ;
    int ** correlated = NULL, **almt2prot = NULL, **prot2almt = NULL;
    /* command file is required */
    if ( argc < 2 ) {
	fprintf ( stderr, "Usage: %s <command file>.\n", argv[0]);
	exit (0);
    }
    retval = read_cmd_file ( argv[1], &options);
    if (retval) exit(retval);
    retval = logger (&options, INTRO, "");
    if (retval) exit(retval);
   

    /*******************************************/
    /*                                         */
    /*  PDB input                              */
    /*                                         */
    /*******************************************/
    if ( ! options.pdbname[0]) {
	fprintf (stderr, "%s cannot work without structure (cmd file was %s).\n",
		 argv[0], argv[1]);
	exit (1);
	
    } else {

	/* warn if no chain given */
	if ( !options.chain) {
	    retval = logger (&options, WARN, "No chain specified. Using the first one.");
	    if ( retval) exit (1);
	}
	if (retval) exit(retval);
	/* read in the structure */
	retval = read_pdb (options.pdbname, &protein, options.chain);
	if (retval) exit(retval);

   }

    
    /*******************************************/
    /*                                         */
    /*  alignment scoring                      */
    /*                                         */
    /*******************************************/
    if ( ! ( alignment = emalloc ( options.no_of_alignments*sizeof(Alignment)) )) return 1;
    if ( ! ( score = emalloc ( options.no_of_alignments*sizeof(double*)) )) return 1;
    if ( ! ( rank_order = emalloc ( options.no_of_alignments*sizeof(int*)) )) return 1;
    if ( ! ( clustering_score = emalloc ( options.no_of_alignments*sizeof(double*)) )) return 1;
    if ( ! ( res_rank = emalloc ( options.no_of_alignments*sizeof(int*)) )) return 1;
    if ( ! ( int_cvg = emalloc ( options.no_of_alignments*sizeof(int*)) )) return 1;
    if ( ! ( almt2prot = emalloc ( options.no_of_alignments*sizeof(int*)) )) return 1;
    if ( ! ( prot2almt = emalloc ( options.no_of_alignments*sizeof(int*)) )) return 1;
    if ( ! ( area = emalloc ( options.no_of_alignments*sizeof(double)) )) return 1;
    if ( ! ( distance = emalloc ( options.no_of_alignments*sizeof(double)) )) return 1;

    printf ( "\t%8s   %20s  %8s  %8s  %8s  \n", "almt#", "name        ",  "<dist to qry>", "%gaps", "area");
    
    for ( almtctr1 = 0; almtctr1 < options.no_of_alignments; almtctr1++) {

	/* read in the alignment */
	retval = read_clustalw (options.almtname[almtctr1], alignment + almtctr1);
	if (retval) exit(retval);
	/* pairwise distances btw the seqs */
	retval   = seq_pw_dist (alignment+almtctr1);
	if ( retval) return retval;
	/* average dist to the query in this alignment: */ 
	distance[almtctr1] = avg_dist_to_special (&options, alignment + almtctr1);
	/* percentage of gaps in the alignment: */
	pctg_gaps = (double) alignment->total_gaps/ ( (alignment+almtctr1)->length*(alignment+almtctr1)->number_of_seqs);
	/* make the residue scoring array */
	score[almtctr1] = emalloc ( alignment[almtctr1].length*sizeof(double));
	/* fill in the score array */ 
	scoring (&options,  alignment+almtctr1, score[almtctr1]);
	
	/* translate the scoring into rank order */
	rank_order[almtctr1] = emalloc ( alignment[almtctr1].length*sizeof(int));
	score2rank (score[almtctr1], rank_order[almtctr1], alignment[almtctr1].length);
	
	/* mapping between the protein and the alignment almtctr1 */
	if ( ! (almt2prot[almtctr1] = (int *) emalloc (alignment[almtctr1].length*sizeof(int))) )exit (1);
	if ( ! (prot2almt[almtctr1] = (int *) emalloc (protein.length*sizeof(int))) )exit (1);
	retval    = struct_almt_mapping (&protein, alignment+almtctr1, options.query,  prot2almt[almtctr1], almt2prot[almtctr1]);
	if (retval) exit(retval);
	
	/* find coverage info implied by the scoring array */
	if ( ! (res_rank[almtctr1] = (int*) emalloc (protein.length*sizeof(int))) ) exit (1);
	if ( ! (int_cvg[almtctr1] =  (int*) emalloc (protein.length*sizeof(int))) ) exit (1);
	coverage ( &protein, almt2prot[almtctr1], score[almtctr1], alignment[almtctr1].length,
		   res_rank[almtctr1], int_cvg[almtctr1] );
	/*clustering score*/
	clustering_score[almtctr1]  =  (double*) emalloc (protein.length*sizeof(double));
	if (!clustering_score[almtctr1]) exit(retval);
	clustering ( &protein,  res_rank[almtctr1], int_cvg[almtctr1], clustering_score[almtctr1]);
	/* cumulative clustering score*/
	area[almtctr1]  = area_over_coverage (int_cvg[almtctr1], clustering_score[almtctr1], protein.length);
					     
	printf ( "\t   %4d   %20s   %8.3lf     %8.3lf  %8.3lf \n",
		 almtctr1, options.almtname[almtctr1], distance[almtctr1], pctg_gaps, area[almtctr1]);
    }

    /* find the table of correlations */
    if ( ! (correlated = intmatrix ( options.no_of_alignments, options.no_of_alignments) ) ) return 1;
    for ( almtctr1 = 0; almtctr1 < options.no_of_alignments -1; almtctr1++) {
	correlated[almtctr1][almtctr1] = 1;
	for ( almtctr2 = almtctr1+1; almtctr2 < options.no_of_alignments; almtctr2++) {
	    if ( alignment[almtctr1].length != alignment[almtctr2].length  ) {
		fprintf ( stderr, "Error alignments in the files %s and %s ",
			  options.almtname[almtctr1], options.almtname[almtctr2]);
		fprintf ( stderr, "seem to be of unequal length: %d and %d.\n",
			  alignment[almtctr1].length ,  alignment[almtctr2].length);
		return 1;
	    }
	    corr = spearman ( rank_order[almtctr1], rank_order[almtctr2], alignment[almtctr1].length );
	    printf ( " %3d  %3d  %8.4lf\n", almtctr1, almtctr2, corr);
	    correlated[almtctr1][almtctr2] = ( corr > 0.9 );
	}
    }

    
    /* find corelated clusters (of sequence selections)*/
    {
	int  *cluster_count_per_size;
	int  no_of_clusters;
	int  max_size, secnd_max_size , ** cluster;
	int size = options.no_of_alignments;
	int i,j;
	double dist, ar, max_area, dist_at_max_area;
	double min_dist_at_max_area, min_dist, max_area_at_min_dist;
	int almt_no, min_dist_almt;
	int cluster_counter (int  no_of_things,  int *neighbors[],
			      int cluster_count_per_size[], int * no_of_clusters,
			      int * max_size, int * secnd_max_size , int * cluster[]);
	
	
	if ( ! ( cluster_count_per_size = emalloc (size*sizeof(int)))) return 1; 
	if ( ! (cluster = intmatrix ( size+1, size+1) ) ) return 1;
	retval = cluster_counter (size,  correlated,  cluster_count_per_size,  &no_of_clusters,
			 & max_size,  &secnd_max_size , cluster);
	if ( retval ) return 1;

	printf ( "number of clusters: %d \n", no_of_clusters);
	for (i=0; i<=size; i++ ) {
	    if ( ! cluster[i][0] ) continue;
	    if ( !i ) {
		printf ( "\t isolated:\n");
	    } else {
		printf ("\t cluster size: %3d \n", cluster[i][0]); 
	    }
	    for (j=1; j <= cluster[i][0]; j++ ) {
		printf ( "%3d ", cluster[i][j] );
	    }
	    printf ( "\n");
	}

	
	/* which cluster is the closest to the singled out sequence ("special") */
	min_dist_at_max_area = dist_at_max_area = 10;
	max_area_at_min_dist = min_dist = -10;
	min_dist_almt = -1;
	for (i=0; i<=size; i++ ) {
	    if ( ! cluster[i][0] ) continue;
	    
	    max_area = -100;
	    almt_no =  dist_at_max_area = -1;
	    
	    for (j=1; j <= cluster[i][0]; j++ ) {
		dist = distance[cluster[i][j]] ;
		ar =  area[cluster[i][j]] ;
		if ( max_area < ar ) {
		    max_area = ar;
		    dist_at_max_area = dist;
		    almt_no = cluster[i][j];
		}
	    }
	    if ( almt_no < 0 ) {
		fprintf ( stderr, "Error selecting the alignment (1)\n");
		exit (1);
	    }
	    
	    if ( min_dist_at_max_area > dist_at_max_area ) {
		min_dist = dist_at_max_area;
		max_area_at_min_dist = max_area;
		min_dist_almt = almt_no;
	    }
	}
	if ( min_dist_almt < 0 ) {
	    fprintf ( stderr, "Error selecting the alignment (2)\n");
	    exit (1);
	}
	
	printf ( "choosing alignment %d %s (distance: %5.3f  area: %6.3f)\n",
		min_dist_almt, options.almtname[min_dist_almt],  min_dist, max_area_at_min_dist);
	
	
	free (cluster_count_per_size);
	free_matrix ( (void **) cluster);
    }
    free (score);

    logger ( &options, NOTE, "");
    return 0;
}
コード例 #8
0
ファイル: PRO24.CPP プロジェクト: RITIK-SRIVASTAVA/diad
int side(int kk[6][6],int &jj,int pos[200][8],int &score)
{  int i,a,b,j,e,r,x,y,l,m,n,temp,w=0;
   char ch,str[3]={"   "};

 for(i=5;i>=0;i--)
  { for(j=4;j>=0;j--)
   {
   r=375;
   e=390;
   strcpy(str,"   ");
      for(l=5;l>=1;l--)
     { if(i==l)
	 { m=r;
	 }
	  r=r-45;
     }

      for(l=4;l>=0;l--)
      {if(j==l)
	{ n=e;
	 }
	  e=e-45;
       }
    if((kk[i][j]>0)&&(kk[i][j-1]>0))
    {
      if(kk[i][j]>=kk[i][j-1])
      {a=kk[i][j];
      }
      else
      {a=kk[i][j-1];
      }

      for(x=a;x>=1;x--)
      {
       if(((kk[i][j]%x)==0)&&((kk[i][j-1]%x)==0))
	{
	  kk[i][j]=kk[i][j]/x;
		ascii(kk[i][j],str,score);
		setcolor(8);
		setfillstyle(1,10);
		bar(n-20,m-20,n+20,m+20);

		if(kk[i][j]>=100)
		   {outtextxy(n-15,m-7,str);
		   }
		else if(kk[i][j]<100)
		   {outtextxy(n-7,m-7,str);
		   }

		delay(200);
		w=0;
		kk[i][j-1]=kk[i][j-1]/x;

	    ascii(kk[i][j-1],str,score);
	    bar(n-65,m-20,n-25,m+20);

	    if(kk[i][j-1]>=100)
		 {outtextxy(n-60,m-7,str);
		 }
	    else if(kk[i][j-1]<100)
		 {outtextxy(n-52,m-7,str);
		 }

	    setcolor(15);
	      if(x>1)
	      {
	       score=score+x;
	       scoring(score,pos);
	      }
  }
	}
      }
    }

 }

 return 0;
}
コード例 #9
0
ファイル: PRO24.CPP プロジェクト: RITIK-SRIVASTAVA/diad
int result(int kk[6][6],int pos[200][8],int &jj,int &score)
{int i,j,p,a,b,l,r,e,m,n;

 for(i=5;i>=1;i--)
 { for(j=4;j>=0;j--)
  {
  r=375;
  e=390;

     for(l=5;l>=1;l--)
    {if(i==l)
	{ m=r;
	}
	r=r-45;
     }

      for(l=4;l>=0;l--)
      {if(j==l)
	{ n=e;
	 }
       e=e-45;
      }
    a=kk[i][j];
    b=kk[i-1][j];
    if((a!=0)&&(b!=0))
    {

    if(a>=b)
       {
	if((a%b)==0)
	  { if(b>1)
	     {
	      score=score+(a/b);
	     }
	scoring(score,pos);
	setfillstyle(1,14);

	bar(n-20,m-65,n+20,m-25);
	bar(n-20,m-20,n+20,m+20);
	edit(n,m,i,j,kk,pos,jj,score);
	edit2(kk,pos,jj,score);
	   }
	}
     else if(b>a)
     {
     if((b%a)==0)
      {
	  if(a>1)
	  { score=score-(b/a);
	  }
       scoring(score,pos);
       setfillstyle(1,12);
       bar(n-20,m-65,n+20,m-25);
       bar(n-20,m-20,n+20,m+20);
       edit(n,m,i,j,kk,pos,jj,score);
       edit2(kk,pos,jj,score);
      }
     }
    }

    }
  }
  delay(100);
  return 0;

}
コード例 #10
0
ファイル: PRO24.CPP プロジェクト: RITIK-SRIVASTAVA/diad
int main()
{int i=300,jj=0,p=0,q=0,a,v,h,b,res,w=0,e=0,r=0,j=100,x=0,kk[6][6],y=0,ch=0,gd=DETECT,gm,k,l;
 int str[18][5]={222,420,140,35,100,
		 13,260,150,70,60,
		 435,120,35,456,354,
		 35,54,32,432,98,
		 334,30,545,24,12,
		 10,90,49,46,234,
		 112,32,121,600,225,
		 729,16,98,564,875,
		 76,86,86,974,36,
		 780,660,732,96,208,
		 31,75,568,930,836,
		 32,22,765,312,54,
		 65,54,86,50,90,
		 570,352,46,27,35,
		 786,540,314,876,289,
		 230,372,948,938,732,
		 328,244,144,134,385,
		 456,382,395,85,384
		 };
 char pop[5],arr[2][25]={" ","RULES AND REGULATION :"};
 int score=0;
 initgraph(&gd,&gm,"C:\\TC\\BGI");

int pos[200][8];
setbkcolor(5);

for(a=0;a<=200;a++)
{ for(b=0;b<=8;b++)
  {pos[a][b]=0;
  }
}
for(a=0;a<=6;a++)
{for(b=0;b<=6;b++)
 {kk[a][b]=0;
 }
}
b=0;

for(a=2;a<30;a++)
{line(1,a,1000,a);
a++;
}

 setfillstyle(1,14);
 settextstyle(TRIPLEX_FONT,HORIZ_DIR,9);
 b=0;
 setfillstyle(1,8);
 bar(550,60+b,620,160+b);
 b=b+100;
 setfillstyle(1,58);
 bar(550,60+b,620,160+b);
 b=b+100;

 setfillstyle(1,14);
 bar(550,60+b,620,160+b);

 b+=100;
 setfillstyle(1,1);
 bar(550,60+b,620,160+b);

  setcolor(15);
  outtextxy(560,50,"T");
  setcolor(0);
  outtextxy(560,150,"E");
  setcolor(2);
  outtextxy(560,250,"C");
  setcolor(14);
  outtextxy(555,350,"H");
  setcolor(9);
  settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
  setcolor(15);
  outtextxy(160,50,"MATHEMATICAL DYAD");
  setfillstyle(6,15);
  bar(140,90,500,95);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
setcolor(15);
outtextxy(30,120,arr[1]);
bar(20,145,270,150);
outtextxy(30,160,"Rule 1: Points are awarded when numbers are paired");
outtextxy(90,180," as multiples (vertically) and the lower number");
outtextxy(90,200," is greater. ");
outtextxy(30,230,"Rule 2: Points are deducted when numbers are paired");
outtextxy(90,250," as multiples (vertically) and the lower number");
outtextxy(90,270," is smaller. ");
outtextxy(30,300,"Rule 3: The HCF of the two adjacent numbers");
outtextxy(90,320," (horizontally) is divided from both the numbers");
outtextxy(90,340," and points are awarded accordingly.");
outtextxy(30,370,"Rule 4: 1 being a special number, no points are ");
outtextxy(90,390," awarded or deducted when numbers are paired");
outtextxy(90,410," with 1. ");
outtextxy(90,430,"            Press spacebar to continue");

  settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
  ch=getch();
for(a=0;;a++)
{if(ch==32)
  {break;
  }
  else
 {ch=getch();
 }
}
  cleardevice();
  setbkcolor(9);
  for(a=2;a<30;a++)
{line(1,a,1000,a);
a++;
}
setfillstyle(1,14);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,9);
   b=0;
   setfillstyle(1,8);
   bar(550,60+b,620,160+b);
   b=b+100;
   setfillstyle(1,58);
   bar(550,60+b,620,160+b);
   b=b+100;

setfillstyle(1,14);
bar(550,60+b,620,160+b);
b+=100;
setfillstyle(1,1);

bar(550,60+b,620,160+b);

setcolor(15);
  outtextxy(560,50,"T");
  setcolor(0);
  outtextxy(560,150,"E");
  setcolor(2);
  outtextxy(560,250,"C");
  setcolor(14);
  outtextxy(555,350,"H");
  setcolor(9);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
setcolor(15);
outtextxy(160,50,"MATHEMATICAL DYAD");
setfillstyle(8,15);
bar(140,90,510,95);

  settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
  setfillstyle(5,15);
  b=0;

  for(a=0;a<=6;a++)
  {
   bar(185, 125+b,415,130+b);
   b+=45;
   }
   b=0;
   for(a=0;a<=5;a++)
    { bar(185+b,125,190+b,395);
      b+=45;
    }
	setcolor(15);
	settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
	setfillstyle(1,1);
	bar3d(55,130,155,170,5,5);
	bar3d(55,180,155,220,5,5);
	bar3d(55,230,155,270,5,5);
	bar3d(55,280,155,320,5,5);
	bar3d(55,330,155,370,5,5);
	     outtextxy(65,140,"LEFT");
	     outtextxy(65,190,"DOWN");
	     outtextxy(65,240,"RIGHT");
	     outtextxy(65,290,"ESC");
	     outtextxy(65,340,"'H' HALT");

 for(p=0;p<=18;p++)
 {
  for(q=0;q<5;q++)
   { setcolor(15);
    i=300;
    j=150;
    x=0;
    y=0;
    ascii(str[p][q],pop,score);
    res=check(kk,pos,i,j,x,y,jj,score);
    if(res==1)
    {scoring(score,pos);
    }

   while(ch!=1)
   {
    settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);

    /*"DEFAULT font","TRIPLEX fontSMALL font","SMALL font",
      "SANS SERIF font","GOTHIC font" */

   a=result(kk,pos,jj,score);
   a=side(kk,jj,pos,score);
   a=result(kk,pos,jj,score);
   setfillstyle(1,1);
   bar(i-20,j-20,i+20,j+20);
   if(str[p][q]>=100)
   {outtextxy(i-15,j-7,pop);
   }
   else if(str[p][q]<100)
   {outtextxy(i-7,j-7,pop);
   }

   delay(500);

   if(kbhit())
    {  a=side(kk,jj,pos,score);
       ch=getch();

      if(ch==75)
	{x=-45;
	 y=0;

       }
      if(ch==77)
      {x=45;
       y=0;
      }

      if(ch==72||ch==104)
     {  settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
	ch=0;

	for(a=2;;a++)
       {setfillstyle(1,60);
	bar(420,130,540,180);
	setcolor(15);
	settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
	outtextxy(445,140,"HALT");

	setfillstyle(1,1);
	bar(420,190,540,250);
	setfillstyle(1,15);
	bar(460,200,475,240);
	bar(485,200,500,240);
	delay(1000);

	setfillstyle(1,1);
	bar(420,190,540,250);

	delay(1000);

	setcolor(15);
	settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
	outtextxy(90,420,"       Press 'R' to resume the game !!");

	if(kbhit())
	 {ch=getch();
	  if(ch==82||ch==114)
	   {ch=0;
	   setfillstyle(1,9);
	   bar(420,130,540,180);
	   bar(420,190,540,250);
	   bar(80,410,500,450);

	   goto lable2;
	   }
       }

     }
     }
     lable2:
     settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
     setcolor(15);

      if(ch==97||ch==65)
      { goto lable;
      }
      if(ch==80)
      {x=0;
       y=45;
      }
      if(ch==27)
      {  delay(2000);
	 cleardevice();
	 setbkcolor(14);
	 setcolor(1);
	 settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);

	 outtextxy(220,110,"GAME OVER !!");
	 setfillstyle(1,4);
	 bar(210,170,430,250);
	 setcolor(15);
	 outtextxy(230,200,"SCORE : " );
	 ascii(score,pop,score);
	 if(score==0)
	   {outtextxy(475,200,"0");
	    }
	 else if(score>0&&score<10)
	   { outtextxy(370,200,pop );
	   }
	 else if(score>=10&&score<100)
	   { outtextxy(365,200,pop );
	   }
	 else if(score>99&&score<1000)
	   { outtextxy(350,200,pop);
	    }
	 else if(score>999)
	   { outtextxy(345,200,pop);
	   }



	 setcolor(2);
	 settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);

	 outtextxy(120,250,"We hope that you enjoyed our game" );
	 outtextxy(120,290,"to the fullest. Please give your " );
	 outtextxy(120,330,"prescious feedback on our website " );
	 setcolor(12);
	 outtextxy(200,370,"www.catexpo_games.com " );
	 getch();
	 closegraph();
	 exit(0);
	      }

      if((i+x)>390)
      {x=0;
      }
      if((i+x)<210)
      {x=0;
      }
     if((y+j)>375)
     { y=0;
       ch=1;
     }
      setfillstyle(3,9);
      res=check(kk,pos,i,j,x,y,jj,score);
      if(res==0)
       {
      delay(100);
      bar(i-20,j-20,i+20,j+20);
      i=i+x;
      j=j+y;

      setfillstyle(1,1);
      bar(i-20,j-20,i+20,j+20);
       if(str[p][q]>=100)
	  {outtextxy(i-15,j-7,pop);
	  }
       else if(str[p][q]<100)
	 {outtextxy(i-7,j-7,pop);
	 }

      x=0;
      y=0;

      a=result(kk,pos,jj,score);
      a=side(kk,jj,pos,score);
      scoring(score,pos);
      a=result(kk,pos,jj,score);
      scoring(score,pos);
       }

      }

  else
  {
   if((j+45)>375)
   {
    y=0;

    ch=1;
    a=result(kk,pos,jj,score);
    scoring(score,pos);
    a=side(kk,jj,pos,score);
    scoring(score,pos);
    a=result(kk,pos,jj,score);
    scoring(score,pos);
   }
   else
   {y=45;
    x=0;
    res=check(kk,pos,i,j,x,y,jj,score);
    if(res==0)
       {
	setfillstyle(1,9);
	bar(i-20,j-20,i+20,j+20);
	j=j+45;
	i=i+x;
       }
      else
      {
      ch=1;
      }

    }
    a=result(kk,pos,jj,score);
    scoring(score,pos);
    a=side(kk,jj,pos,score);
    scoring(score,pos);
    a=result(kk,pos,jj,score);
    scoring(score,pos);
 }
 }
 pos[jj][0]=i;
 pos[jj][1]=j;

 w=0;
 e=0;
 r=0;

 for(a=210;a<=390;)
 {
  if(i==a)
   { e=r;
   }
   r++ ;
   a=a+45;
 }
 r=5;

 for(b=375;b>=100;)
 {if(j==b)
   { w=r;
   }
   r-- ;
   b=b-45;
 }

kk[w][e]=str[p][q];

ch=0;
r=0;
i=300;
j=150;
e=0;
w=0;
x=0;
jj++;
y=0;

}

    a=result(kk,pos,jj,score);
    scoring(score,pos);
    a=side(kk,jj,pos,score);
    scoring(score,pos);
    a=result(kk,pos,jj,score);
    scoring(score,pos);
}
lable:
cleardevice();
closegraph();
getch();
return 0;
}
コード例 #11
0
ファイル: pear.c プロジェクト: B-UMMI/INNUca
/** @brief Assemble two pair-end reads
    
    Attempts to assemble two pair-ends reads \a left and \a right using a 
    scoring method and then checks whether the assembly is successful based
    on user-defined parameters and a statistical test. The assembly is done
    by first checking all possible overlaps and picking the one with the best
    score. Constrain checks for not assemblying are:
      - Minimum assembly length (user-defined)
      - Maximum assembly length (user-defined)
      - Minimum overlap (user-defined)
      - Number of uncalled bases (user-defined)
      - Statistical test based on a user-defined p-value

    @param left
      The forward read

    @param right
      The reverse read which has already been reversed and complemented

    @param sw
      Structure containing the user-defined parameters

    @return
      In case the assembly is successful returns \b 1, otherwise \b 0
*/
inline int
assembly (struct read_t * left, struct read_t * right, struct user_args  * sw)
{
  int                   i,j;
  int                   n;
  double                score;
  double                best_score = 0;
  int                   best_overlap = 0;       /* overlap of the best alignment */
  int                   run_through = 0;
  int                   nMatch;
  int                   asm_len = 0;
  int                   st_pass;
  int                   uncalled = 0;
  
  n = strlen (left->data);
     
  /* compute score for every overlap */
  score = 0;
  for (i = 0; i <= n; ++ i)    /* the size of the overlap */
   {     
     nMatch = 0;
     score = 0;
     for (j = 0; j < i; ++ j)
      {
        scoring (left->data[n - i + j], 
                 right->data[j], 
                 left->qscore[n - i + j], 
                 right->qscore[j], 
                 sw->score_method, 
                 &score, 
                 PEAR_MATCH_SCORE, 
                 PEAR_MISMATCH_SCORE);
        if (left->data[n - i + j] == right->data[j]) ++nMatch;
      }
     if (score > best_score)
      {
        best_overlap = i;
        best_score   = score;
      }
   }

  /* compute for score for runthrough case */
  for (i = n - 1; i > 0; --i)
   {
     score  = 0;
     nMatch = 0;
     for (j = 0; j < i; ++j)
      {
        scoring (left->data[j], 
                 right->data[n - i + j], 
                 left->qscore[j], 
                 right->qscore[n - i + j], 
                 sw->score_method, 
                 &score, 
                 PEAR_MATCH_SCORE, 
                 PEAR_MISMATCH_SCORE);
        if (left->data[n - i + j] == right->data[j]) ++nMatch;
      }

     if (score > best_score)
      {
        run_through  = 1;
        best_overlap = i;
        best_score   = score;
      }
   }


  if (sw->test == 1)
   {
     st_pass = stat_test2 (sw->p_value, best_score, sw->min_overlap, 0.25);
   }
  else
   {
     st_pass = stat_test2 (sw->p_value, best_score, best_overlap, 0.25);
   }

  if (!st_pass) return (0);


  /* do the assembly!!!! */
  if (!run_through)
   {
     if (best_overlap == 0)
      {
        asm_len = 2 * n;

        for (j = 0; j < n; ++ j)
          if (left->data[j] == 'N' || left->data[j] == 'n')  ++uncalled;
        for (j = 0; j < n; ++ j)
          if (right->data[j] == 'N' || right->data[j] == 'n')  ++uncalled;
        uncalled /= asm_len;

        if (2 * n - asm_len >= sw->min_overlap && asm_len >= sw->min_asm_len && asm_len <= sw->max_asm_len && uncalled <= sw->max_uncalled)
         {
           *(left->data - 1) = 1;
         }
        else
         {
           return (0);
         }
      }
     else if (best_overlap == n )
      {
        asm_len         = n;

        for (j = 0; j < asm_len; ++ j)
          if ((left->data[j] == 'N' || left->data[j] == 'n') && (right->data[j] == 'N' || right->data[j] == 'n')) ++uncalled;
        uncalled /= asm_len;

        if (2 * n - asm_len >= sw->min_overlap && asm_len >= sw->min_asm_len && asm_len <= sw->max_asm_len && uncalled <= sw->max_uncalled)
         {
           *(left->data - 1) = 0;
           assemble_overlap (left, right, 0, 0, n, left);
           left->data[n]   = 0;
           left->qscore[n] = 0;
         }
        else
         {
           return (0);
         }
      }
     else
      {
        asm_len = 2 * n - best_overlap;
        for (j = 0; j < n - best_overlap; ++ j)
          if (left->data[j] == 'N' || left->data[j] == 'n')  ++uncalled;
        for (j = n - best_overlap; j < n; ++ j)
          if ((left->data[j] == 'N' || left->data[j] == 'n') && (right->data[j - n + best_overlap] == 'N' || right->data[j - n + best_overlap] == 'n'))  ++uncalled;
        for (j = best_overlap; j < n; ++ j)
          if (right->data[j] == 'N' || right->data[j] == 'n')  ++uncalled;
        uncalled /= asm_len;

        if (2 * n - asm_len >= sw->min_overlap && asm_len >= sw->min_asm_len && asm_len <= sw->max_asm_len && uncalled <= sw->max_uncalled)
         {
           *(left->data - 1) = 1;
           
           assemble_overlap (left, right, n - best_overlap, 0, best_overlap, left);
           memmove (right->data,   right->data   + best_overlap,  n - best_overlap);
           memmove (right->qscore, right->qscore + best_overlap,  n - best_overlap);

           right->data[n   - best_overlap] = 0;
           right->qscore[n - best_overlap] = 0;
         }
        else
         {
           return (0);
         }
      }
   }     /* run-through case */
  else
   {
     asm_len = best_overlap;
     
     /* compute uncalled */
     for (j = 0; j < asm_len; ++ j)
       if ((left->data[j] == 'N' || left->data[j] == 'n') && (right->data[n - best_overlap + j] == 'N' || right->data[n - best_overlap + j] == 'n')) ++uncalled;
     uncalled /= asm_len;

     if (asm_len >= sw->min_overlap && asm_len >= sw->min_asm_len && asm_len <= sw->max_asm_len && uncalled <= sw->max_uncalled)
      {
        assemble_overlap (left, right, 0, n - best_overlap, best_overlap, left);
        
        left->data[best_overlap]   = 0;
        left->qscore[best_overlap] = 0;
        *(left->data - 1) = 0;   /* flag that it's one piece */
      }
     else
      {
        return (0);
      }
   }

  /* TODO: Remember to reset *(let->data - 1) */

  /* TODO: Optimize this in assemble_overlap? */

  return (1);
}
コード例 #12
0
ファイル: main.cpp プロジェクト: Aarons100/Kryptos
int main() {

	char command;
	string main_menu = "\nMAIN MENU\n1: Base64 options\n2: Xor options\nh: Print this menu\nq: Quit\n\n";
	string base64_options = "\nBASE64 OPTIONS\n1: Convert Hex to Base 64 \n2: Convert Base 64 to Hex\nh: Print this menu\nb: Back to main menu\n\n";
	string Xor_options = "\nXOR OPTIONS\n1: Fixed Xor of two hex strings (equal length)\n2: Break single byte Xor\n3: Detect and break single byte Xor\n4: Perform repeating key Xor\n5: Break Repeating Key Xor\nh: Print this menu\nb: Back to main menu\n\n";
	cout << main_menu;
	cout << "Kryptos>";

	while(1) {		

		command = cin.get();

		if(command == '\n') {
			cout << "Kryptos>";
		}
				
		switch (command) {

			{case '1' :
				cout << base64_options;
				bool loop = true;
				while(loop) {
					command = cin.get();

					if(command == '\n') {
						cout << "Kryptos/b64>";
					}

					switch(command) {
						{case '1':
							string input;
							cout << "Hex string: ";
							cin >> input;
							cout << "\noutput: " << hextob64(input) << "\n";
							break;
						}
						{case '2':
							string input;
							cout << "Base 64 string: ";
							cin >> input;
							cout << "\noutput: " << b64tohex(input) << "\n";
						}
						{case 'h':
							cout <<base64_options;
							break;
						}
						{case 'b':
							cout << main_menu;
							loop=false;
							break;
						}
						{case 'q':
							cout << main_menu;
							loop=false;
							break;
						}
					}
				}
				break;
			}
			{case '2':
				cout << Xor_options;
				bool loop = true;
				while(loop) {
					command = cin.get();

					if(command == '\n') {
						cout << "Kryptos/Xor>";
					}

					switch(command) {
						{case '1':
							string inputone;
							string inputtwo;
							cout << "First hex string: ";
							cin >> inputone;
							cout << "Second hex string: ";
							cin >> inputtwo;

							cout << "\noutput: " << fixedXor(inputone,inputtwo) << "\n";
							break;
						}
						{case '2':
							string input;
							cout << "Hex to break: ";
							cin >> input;
							sByteXor(input);
							scoring();
						break;
						}
						{case '3':
							detectXor();
							scoring();
						}
						{case '4':
							string input;
							cout << "Enter a key: ";
							cin >> input;
							repeating_Xor(input);
							cout << "Output written to repeating_xor_output.txt\n";
						}
						{case '5':
							break_Rkey_Xor();
						}
						{case 'h':
							cout << Xor_options;
							break;
						}
						{case 'b':
							cout << main_menu;
							loop=false;
							break;
						}
						{case 'q':
							cout << main_menu;
							loop=false;
							break;
						}
					}
				}
				break;
			}
			{case 'h':
				cout << main_menu;
				break;
			}
			{case 'q':
				return 0;
			}
		}
	}
	return 0;
}
コード例 #13
0
ファイル: level4.cpp プロジェクト: talha08/combat_zone
bool level4()
{
    char bname[25];
    coor player, enemy[3], pshot[25], enshot[3];
    int plife=3, enlife[3]={7,7, 7};
    int fb =0, input, bo=0;
    player.xl= 20, player.yt=200, player.xr=100, player.yb=300;
    enemy[0].xl=550, enemy[0].yt=50, enemy[0].xr=630, enemy[0].yb=150;
    enemy[1].xl=550, enemy[1].yt=400, enemy[1].xr=630, enemy[1].yb=500;
    enemy[2].xl=650, enemy[2].yt=200, enemy[2].xr=730, enemy[2].yb=300;
    readimagefile("background.jpg", 0, 0, 800, 600);
    readimagefile("player.jpg", player.xl, player.yt, player.xr, player.yb);
    readimagefile("enemy3.jpg", enemy[0].xl, enemy[0].yt, enemy[0].xr, enemy[0].yb);
    readimagefile("enemy4.jpg", enemy[1].xl, enemy[1].yt, enemy[1].xr, enemy[1].yb);
    while(1)
    {
       scoring(0);
     //  p_life(plife);
        for(int i=0; i<3; i++)
        {
            char name[30];
           if(enshot[i].xl<=0 || fb==i)
            {
                fb++;
                enshot[i].xl = enemy[i].xl - 30;
                enshot[i].xr = enemy[i].xl;
                enshot[i].yb = enemy[i].yb - 45;
                enshot[i].yt = enemy[i].yt + 45;
                readimagefile("background.jpg", 0, 0, 800, 600);
                sprintf(name, "enbullet%d.jpg", i);
                readimagefile(name, enshot[i].xl, enshot[i].yt, enshot[i].xr, enshot[i].yb);
            }
            enemy[i].yb += 4, enemy[i].yt += 4 ;
            if(enshot[i].xl > 0)
            {
                enshot[i].xl-= 5, enshot[i].xr -=5;
                sprintf(name, "enbullet%d.jpg", i);
                readimagefile(name, enshot[i].xl, enshot[i].yt, enshot[i].xr, enshot[i].yb);
            }
            if(enemy[i].yb> 600)
            {
                enemy[i].yt =0, enemy[i].yb = 100;
                readimagefile("background.jpg", 0, 0, 800, 600);
            }
            sprintf(name, "enemy%d.jpg", i+2);
            readimagefile(name, enemy[i].xl, enemy[i].yt, enemy[i].xr, enemy[i].yb);
        }
        if(kbhit())
        {
            input = getch();
            if(input == 32)
            {
                scoring(-5);
                readimagefile("background.jpg", 0, 0, 800, 600);
                PlaySound(TEXT("shoot.wav"), NULL, SND_ASYNC);
                for(int k=0; k<2; k++)
            {
                pshot[bo].xl = player.xr;
                pshot[bo].xr = player.xr + 30;
                if(k==0)
                {
                    pshot[bo].yb = player.yb - 40;
                    pshot[bo].yt = player.yt + 50;
                    sprintf(bname, "pbullet%d.jpg", bo);
                readimagefile(bname, pshot[bo].xl, pshot[bo].yt, pshot[bo].xr, pshot[bo].yb);
                bo++;
                }
               /* if(k==1)
               {
                    pshot[bo].yb = player.yb - 50;
                    pshot[bo].yt = player.yt + 40;
                    sprintf(bname, "pbullet%d.jpg", bo);
                readimagefile(bname, pshot[bo].xl, pshot[bo].yt, pshot[bo].xr, pshot[bo].yb);
                bo++;
                }*/

            }
            input =0;
            }
            else if(input == 72)
            {
            if(player.yt>= 0) player.yb-=5, player.yt-=5;
            input =0;
            }
            else if(input == 80)
            {
            if(player.yb <= 600) player.yb+=5, player.yt+=5;
            input =0;
            }
            else if(input == 75)
            {
            if(player.xl >=0) player.xl-=5, player.xr-=5;
            input =0;
            }
            else if(input == 77)
            {
            if(player.xr<=800) player.xl+=5, player.xr+=5;
            input =0;
            }
  /*           else if(input == 13)
            {
                system("pause");
                setcolor(5);
                settextstyle(8, HORIZ_DIR, 3);
                outtextxy(300, 350, "Game Paused");
                outtextxy(270, 380, "Press Any Key To Continue");
                getch();
            }*/
        }
        readimagefile("player.jpg", player.xl, player.yt, player.xr, player.yb);
        for(int i=0; i<bo; i++)
        {
            if(pshot[i].xr>0 && pshot[i].xr<800)
            {
                pshot[i].xl +=6, pshot[i].xr +=6;
                sprintf(bname, "pbullet%d.jpg", i);
                readimagefile(bname, pshot[i].xl, pshot[i].yt, pshot[i].xr, pshot[i].yb);
            }
            if(pshot[i].xr >= 800)
            {
                pshot[i].xl =-1, pshot[i].xr = -1, pshot[i].yb =-1, pshot[i].yt =-1;
                readimagefile("background.jpg", 0, 0, 800, 600);
            }
        }
        for(int j=0; j<3; j++)
        {
            if((enshot[j].yt>= player.yt && enshot[j].yb <= player.yb) && (enshot[j].xl>=player.xl && enshot[j].xl <player.xr))
            {
                PlaySound(TEXT("explosion.wav"), NULL, SND_ASYNC);
                readimagefile("Explosion.jpg" , player.xl, player.yt, player.xr , player.yb );
                delay(200);
                readimagefile("background.jpg", 0, 0, 800, 600);
                readimagefile("player.jpg", player.xl, player.yt, player.xr, player.yb);
                enshot[j].xl = 0, plife--;
            }
            if(((player.xl>=enemy[j].xl && player.xl<=enemy[j].xr) || (player.xr>=enemy[j].xl && player.xr<=enemy[j].xr)) &&
                 ((player.yt>=enemy[j].yt && player.yb<=enemy[j].yt) || (player.yb>=enemy[j].yb && player.yt<=enemy[j].yb))) plife=0, enlife[j] =0;
             for(int i=0; i<bo; i++) if((pshot[i].yt>= enemy[j].yt && pshot[i].yb<= enemy[j].yb) && (pshot[i].xl>= enemy[j].xl && pshot[i].xr<= enemy[j].xr))
            {
                PlaySound(TEXT("explosion.wav"), NULL, SND_ASYNC);
                readimagefile("Explosion.jpg" , enemy[j].xl , enemy[j].yt , enemy[j].xr , enemy[j].yb );
                delay(200);
                pshot[i].xl =-1, pshot[i].xr = -1, pshot[i].yb =-1, pshot[i].yt =-1, enlife[j]--;
                if(enlife[j]>0)
                {
                    char name[30];
                    sprintf(name, "enemy%d.jpg", j+2);
                    readimagefile(name, enemy[j].xl, enemy[j].yt, enemy[j].xr, enemy[j].yb);
                }
                scoring(20);
                readimagefile("background.jpg", 0, 0, 800, 600);
            }
        }

        if(plife ==0 || ptszero())

        {
            PlaySound(TEXT("over.wav"), NULL, SND_ASYNC);
            readimagefile("Game over.jpg", 0, 0, 800, 600);
            delay(2000);
            sethighscores();
            showscores();
            cleardevice();
            return 0;
        }
         if(enlife[0] ==0 && enlife[1] == 0)
        {
            PlaySound(TEXT("win.wav"), NULL, SND_ASYNC);
            readimagefile("win.jpg", 0, 0, 800, 600);
            cleardevice();
            return 1;
        }
    }
}