156Fermer158
Yoshi NoirLe 08/05/2008 à 00:00
moi aussi je veux jouer trilove :

extrait de mon code de mille bornes psp :
int ia_nme(int tour, int curscard)
{
	int poubelle=-1,i=-1,cj=15,cx=-1,dmax;
	if (curscard<106) mains[tour][6]=tas[curscard];

	if (nbj==4) dmax=1000;
	else dmax=700;

	//cherche bottes si adversaire > 800
	//oslWarning("bottes %d",cj);
	if ((scores[0]>=(dmax-200)) || (curscard>92))
	{
		for(i=0; i<7; i++)
		{
			if (mains[tour][i]>15)
			{
				cj=mains[tour][i];
				cx=i;
				i=8;
			}
		}
	}

	//cherche feu vert
	//oslWarning("feuvert %d",cj);
	for(i=0; i<7; i++)
	{
		if ((mains[tour][i]==5) && (cj==15))
		{
			if (etat[1]%10 == 0)
			{
			cj=mains[tour][i];
			cx=i;
			i=8;
			}
		}
	}

	//cherche attaques
	//oslWarning("attaque %d",cj);
	for(i=0; i<7; i++)
	{
		if ((etat[0]%10 == 1) && (cj == 15))
		{
			if ((mains[tour][i]>9) && (mains[tour][i] != 11) && (mains[tour][i]<15))
			{
				cj=mains[tour][i];
				cx=i;
				i=8;
			}
		}
	}

	//cherche limites
	//oslWarning("limites %d",cj);
	for(i=0; i<7; i++)
	{
		if ((mains[tour][i]==11) && (cj==15))
		{
			if (etat[0] < 10)
			{
			cj=mains[tour][i];
			cx=i;
			i=8;
			}
		}
	}

	//cherche parades
	//oslWarning("contre %d",cj);
	for(i=0; i<7; i++)
	{
		if ((etat[1]%10 != 1) && (cj==15))
		{
			if ((etat[1]>9) && (mains[tour][i]==6))
			{
				cj=mains[tour][i];
				cx=i;
				i=8;
			}
			if ((etat[1]%10==0) && (mains[tour][i]==5))
			{
				cj=mains[tour][i];
				cx=i;
				i=8;
			}
			if ((etat[1]%10==2) && (mains[tour][i]==7))
			{
				cj=mains[tour][i];
				cx=i;
				i=8;
			}
			if ((etat[1]%10==3) && (mains[tour][i]==8))
			{
				cj=mains[tour][i];
				cx=i;
				i=8;
			}
			if ((etat[1]%10==4) && (mains[tour][i]==9))
			{
				cj=mains[tour][i];
				cx=i;
				i=8;
			}
		}
	}

[...]

}


Du code non commenté, des int de partout, des répétitions de code, que même le plus téméraire en deviendra depréssif à la lecture tongue