Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about giving the user the option to create personalities

Author: José Carlos

Date: 09:45:58 04/20/04

Go up one level in this thread


On April 20, 2004 at 12:30:06, Uri Blass wrote:

>I want to give users of movei the option to create personality by changing text
>files.
>The question is what is the best way to do it.
>
>I have a way that can work but I do not like it.
>Here is my code to let the user to change the futilityprune array
>
>Movei is using an array to tell it to prune based on evaluation and remaining
>depth and other factors.
>
>I have in the latest version
>int futilityprune[6]={0,180,720,1620,2880,4500} when
>the numbers in that array are never changed.
>
>I can let the users to change numbers in a text file by the following code and
>generate the text file in case that it does not exist but I do not like that
>code and the question is if programmers use a better code to let the user to
>change weights in the search or in the evaluation.
>
>FILE *evalfile=fopen("movei_eval_details.ini", "r+t");
>
>if (!evalfile)
>	{
>		evalfile=fopen("movei_eval_details.ini", "w+t");
>		fputs("0 180 720 1620 2880 4500",evalfile);
>	}
>	fseek(evalfile,0,SEEK_SET);
>	fgets(evalcharinfo,60,evalfile);
>	j=0;
>	i=0;
>	while (j<6)
>	{
>		futilityprune[j]=0;
>		while ((i<60)&&(evalcharinfo[i]>='0')&&(evalcharinfo[i]<='9'))
>		{
>			futilityprune[j]*=10;
>			futilityprune[j]=futilityprune[j]+(int)evalcharinfo[i]-(int)'0';
>			i++;
>		}
>		while (evalcharinfo[i]==' ')
>			i++;
>		j++;
>	}
>
>Uri

  I don't have time now to read your code (I'm at work) but here's what I do to
read personality file in Averno (I open the file as binary and fscanf() until
EOF:

int CargarPersonaje(char *NomFich)
{
	FILE	* Av_Pers;
	char	stWord[256] = "\0";
	int	nNumber;

	strcat(NomFich,".per");
	Av_Pers = fopen(NomFich,"rb");
	if (Av_Pers == NULL)
	{
#if !defined(WINBOARD)
		printf("\nError reading personality file. Not found: %s\n",NomFich);
#endif
		return(FALSE);
	}
	while (fscanf(Av_Pers,"%s",stWord) != EOF)
	{
		if (!strcmp(stWord,"APRENDER"))
		{
			fscanf(Av_Pers,"%s",stWord);
			nNumber = atoi(stWord);
			APRENDER = nNumber;
		}
		else if (!strcmp(stWord,"TABLA_HASH"))
		{
			fscanf(Av_Pers,"%s",stWord);
			nNumber = atoi(stWord);
			TABLA_HASH = nNumber;
		}
		else if (!strcmp(stWord,"TABLA_HASH_PEONES"))
		{
			fscanf(Av_Pers,"%s",stWord);
			nNumber = atoi(stWord);
			TABLA_HASH_PEONES = nNumber;
		}
		else if (!strcmp(stWord,"NALIMOV_PATH"))
		{
			fscanf(Av_Pers,"%s",NALIMOV_PATH);
		}
		else if (!strcmp(stWord,"EGTB_CACHE_SIZE"))
		{
			fscanf(Av_Pers,"%s",stWord);
			nNumber = atoi(stWord);
			EGTB_CACHE_SIZE = nNumber*1024*1024;
		}
		else if (!strcmp(stWord,"LIBROB_FICH"))
		{
			fscanf(Av_Pers,"%s",LIBROB_FICH);
		}
		else if (!strcmp(stWord,"LIBRON_FICH"))
		{
			fscanf(Av_Pers,"%s",LIBRON_FICH);
		}
		else if (!strcmp(stWord,"ICS"))
		{
			fscanf(Av_Pers,"%s",stWord);
			nNumber = atoi(stWord);
			ICS = nNumber;
		}
		else if (!strcmp(stWord,"AP_SEGUNDOS_MIN"))
		{
			fscanf(Av_Pers,"%s",stWord);
			nNumber = atoi(stWord);
			AP_SEGUNDOS_MIN = nNumber;
		}
		else if (!strcmp(stWord,"SELECTIVIDAD_LIBRO"))
		{
			fscanf(Av_Pers,"%s",stWord);
			nNumber = atoi(stWord);
			SELECTIVIDAD_LIBRO = nNumber;
		}
		else if (!strcmp(stWord,"LIMITE_ACEPTACION"))
		{
			fscanf(Av_Pers,"%s",stWord);
			nNumber = atoi(stWord);
			LIMITE_ACEPTACION = nNumber;
		}
	}
#if !defined(WINBOARD)
	printf("Dimensionando tabla hash...\n");
#endif
	DimensionarTablaHash(TABLA_HASH);
	DimensionarTablaHashPeones(TABLA_HASH_PEONES);
	DimensionarTablaHashAtaques(TABLA_HASH_ATAQUES);
	return(TRUE);
}

  José C.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.