Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
easea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Arnaud Kress
easea
Commits
4b013a30
Commit
4b013a30
authored
Dec 11, 2009
by
maitre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Un-broken INSTEAD_EVAL CUDA.tpl
parent
2434f345
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1881 additions
and
84 deletions
+1881
-84
Easea.h
Easea.h
+2
-0
EaseaLex.l
EaseaLex.l
+3
-1
EaseaParse.y
EaseaParse.y
+9
-1
dev/tgp_regression/data.csv
dev/tgp_regression/data.csv
+0
-78
dev/tgp_regression/tgp_regression.ez
dev/tgp_regression/tgp_regression.ez
+17
-3
examples/ant/ant.ez
examples/ant/ant.ez
+648
-0
examples/cmaes_cuda_test/cigtabGPU.ez
examples/cmaes_cuda_test/cigtabGPU.ez
+120
-0
examples/cmaes_tests/cigtab.ez
examples/cmaes_tests/cigtab.ez
+125
-0
examples/weierstrass_gpu/weierstrass.ez
examples/weierstrass_gpu/weierstrass.ez
+172
-0
examples/weierstrass_std/.RData
examples/weierstrass_std/.RData
+0
-0
examples/weierstrass_std/weierstrass.ez
examples/weierstrass_std/weierstrass.ez
+176
-0
tpl/CUDA.tpl
tpl/CUDA.tpl
+6
-1
tpl/CUDA_GP.tpl
tpl/CUDA_GP.tpl
+603
-0
No files found.
Easea.h
View file @
4b013a30
...
...
@@ -27,6 +27,8 @@ Centre de Math
#define CUDA_FLAVOR_SO 0
#define CUDA_FLAVOR_MO 1
#define CUDA_FLAVOR_CMAES 2
#define CUDA_FLAVOR_GP 3
#define UNIX 1
#define WINDOWS 2
...
...
EaseaLex.l
View file @
4b013a30
...
...
@@ -1828,7 +1828,7 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
strcat(sTemp,"CUDA.tpl");
else if(TARGET_FLAVOR == CUDA_FLAVOR_CMAES )
strcat(sTemp,"CMAES_CUDA.tpl");
else
else
strcat(sTemp,"CUDA_MO.tpl");
if (!(yyin = fpTemplateFile = fopen(sTemp, "r"))){
...
...
@@ -1842,6 +1842,8 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
strcat(sTemp,"STD.tpl");
else if (TARGET_FLAVOR == STD_FLAVOR_CMAES)
strcat(sTemp,"CMAES.tpl");
else if( TARGET_FLAVOR == CUDA_FLAVOR_GP )
strcat(sTemp,"CUDA_GP.tpl");
else
strcat(sTemp,"STD_MO.tpl");
if (!(yyin = fpTemplateFile = fopen(sTemp, "r"))){
...
...
EaseaParse.y
View file @
4b013a30
...
...
@@ -657,6 +657,10 @@ int main(int argc, char *argv[]){
TARGET=CUDA;
TARGET_FLAVOR = CUDA_FLAVOR_MO;
}
else if( !mystricmp(sTemp,"cuda_gp") ){
TARGET=STD;
TARGET_FLAVOR = CUDA_FLAVOR_GP;
}
else if (!mystricmp(sTemp,"std")) {
TARGET=STD;
...
...
@@ -675,8 +679,12 @@ int main(int argc, char *argv[]){
TARGET_FLAVOR = CUDA_FLAVOR_CMAES;
}
else if (!mystricmp(sTemp,"v")) bVERBOSE=true;
else if (!mystricmp(sTemp,"tl")) bLINE_NUM_EZ_FILE=false;
else if (!mystricmp(sTemp,"tl")){
printf("yopyop true line\n");
bLINE_NUM_EZ_FILE=false;
}
else if (!mystricmp(sTemp,"path")) {
if (argv[++nParamNb][0]=='"') {
strcpy(sEZ_PATH,&(argv[nParamNb][1]));
...
...
dev/tgp_regression/data.csv
deleted
100644 → 0
View file @
2434f345
77
0.05,0.61,0.3,5,27.2
0.05,0.61,0.3,15,44.9
0.05,0.61,0.3,30,59.3
0.05,0.61,0.3,45,68.7
0.05,0.61,0.3,75,80.1
0.05,0.61,0.3,120,87.2
0.05,0.61,0.3,180,94.2
0.05,0.86,0.61,5,27.2
0.05,0.86,0.61,15,41.6
0.05,0.86,0.61,30,56.4
0.05,0.86,0.61,45,64.7
0.05,0.86,0.61,75,74
0.05,0.86,0.61,120,81.4
0.05,0.86,0.61,180,86.2
0.05,0.76,0.76,5,8.7
0.05,0.76,0.76,15,21.3
0.05,0.76,0.76,30,33.9
0.05,0.76,0.76,45,42.9
0.05,0.76,0.76,75,57.3
0.05,0.76,0.76,120,65.5
0.05,0.76,0.76,180,69.2
0.06,0.86,0.61,5,17.7
0.06,0.86,0.61,15,30.1
0.06,0.86,0.61,30,43.9
0.06,0.86,0.61,45,52
0.06,0.86,0.61,75,64.7
0.06,0.86,0.61,120,74.6
0.06,0.86,0.61,180,82
0.25,0.86,0.61,5,8.5
0.25,0.86,0.61,15,20.9
0.25,0.86,0.61,30,33.6
0.25,0.86,0.61,45,44.6
0.25,0.86,0.61,75,56.6
0.25,0.86,0.61,120,68.2
0.25,0.86,0.61,180,76
0.35,0.76,0.76,5,5
0.35,0.76,0.76,15,14.9
0.35,0.76,0.76,30,28.6
0.35,0.76,0.76,45,37.3
0.35,0.76,0.76,75,51.3
0.35,0.76,0.76,120,63.6
0.35,0.76,0.76,180,72.1
0.5,0.86,0.61,5,5
0.5,0.86,0.61,15,14.5
0.5,0.86,0.61,30,27.6
0.5,0.86,0.61,45,36.4
0.5,0.86,0.61,75,52.3
0.5,0.86,0.61,120,64.3
0.5,0.86,0.61,180,72
0.5,1.52,0.76,5,10.5
0.5,1.52,0.76,15,20.4
0.5,1.52,0.76,30,34
0.5,1.52,0.76,45,46.4
0.5,1.52,0.76,75,61.2
0.5,1.52,0.76,120,76.2
0.5,1.52,0.76,180,80
0.5,1.07,0.76,5,10.5
0.5,1.07,0.76,15,19.7
0.5,1.07,0.76,30,32.3
0.5,1.07,0.76,45,42.3
0.5,1.07,0.76,75,57.1
0.5,1.07,0.76,120,70.8
0.5,1.07,0.76,180,76
0.5,0.94,0.76,5,9.1
0.5,0.94,0.76,15,18.4
0.5,0.94,0.76,30,31.7
0.5,0.94,0.76,45,40.3
0.5,0.94,0.76,75,54.1
0.5,0.94,0.76,120,67.8
0.5,0.94,0.76,180,74
0.5,0.76,0.76,5,9.5
0.5,0.76,0.76,15,17.3
0.5,0.76,0.76,30,28.3
0.5,0.76,0.76,45,37.2
0.5,0.76,0.76,75,49
0.5,0.76,0.76,120,61.7
0.5,0.76,0.76,180,66
dev/tgp_regression/tgp_regression.ez
View file @
4b013a30
...
...
@@ -10,6 +10,11 @@ __________________________________________________________*/
#include <errno.h>
#include <sstream>
#include <math.h>
#include <cutil.h>
#define OPERAND 0
...
...
@@ -191,7 +196,7 @@ void toDotFile(GPNode* root, const char* baseFileName, int treeId){
std::ostringstream oss;
oss << baseFileName << "-" << treeId << ".gv";
FILE* outputFile = fopen(oss.str().c_str(),"
w
");
FILE* outputFile = fopen(oss.str().c_str(),"
a
");
if( !outputFile ){
perror("Opening file for outputing dot representation ");
exit(-1);
...
...
@@ -356,9 +361,15 @@ GPNode* selectNode( GPNode* root, int* childId, int* depth){
fitnessCasesSetLength = load_data(&inputs,&outputs,"quadra_reg_data.csv");
cout << "number of point in fitness cases set : " << fitnessCasesSetLength << endl;
INSTEAD_EVAL_STEP=true;
// Adding another stopping, as we are minimizing, the goal is 0
CGoalCriterion* gc = new CGoalCriterion(0,true);
EA->stoppingCriteria.push_back(gc);
// Here starts the CUDA parts
cudaSetDevice(1); // on GTX295 ;) we want to use the second card for computation
}
\end
...
...
@@ -393,7 +404,11 @@ GPNode* selectNode( GPNode* root, int* childId, int* depth){
\end
\Instead evaluation function:
cout << "yopyop" << endl;
{
for( int i=0 ; i<popSize ; i++ ){
cout << population[i] << endl;
}
}
\end
\User classes :
...
...
@@ -627,7 +642,6 @@ GenomeClass {
\end
\User Makefile options:
CPPFLAGS+=
\end
\Default run parameters : // Please let the parameters appear in this order
...
...
examples/ant/ant.ez
0 → 100644
View file @
4b013a30
/* ANTPROJECT */
\User declarations:
int nbEvalTotal = 0; //Le nombre d'evaluations
short nbPasMax = 600; //Le nombre max de mouvements autorises
double pMutPerGene=0.05; // La probabilité de muter un gene
enum symboles {food_ahead, progn2, progn3, LEFT, RIGHT, MOVE}; //L'ensemble des valeurs que peut prendre un noeud de l'arbre
enum orientations {nord, est, sud, ouest}; //Les 4 orientations possibles
int profondeurMax = 2; //La profondeur max d'un arbre a sa cration (racine = 0)
int profondeurMax1 = 9; //La profondeur max d'un arbre au cours de l'évolution
int taille = 32; //taille de la grille
int SIZE=0;//taille d'un individu
int carte[32][32]; //la grille
inline void swap(int& a,int& b) {int c=a; a=b; b=c;}
\end
\User functions:
#include <math.h>
void echangeNoeud(Element *child, Element *parent){
swap(child->Value,parent->Value);
}
/*
Creation de la carte avec le chemin.
*/
void initCarte(){
int i,j;
for(i=0;i<32;i++)
for(j=0;j<32;j++)
carte[i][j]=0;
carte[0][1]=1;carte[0][2]=1;carte[0][3]=1;carte[1][3]=1;carte[2][3]=1;
carte[3][3]=1;carte[4][3]=1;carte[5][3]=1;carte[5][4]=1;carte[5][5]=1;
carte[5][6]=1;carte[5][8]=1;carte[5][9]=1;carte[5][10]=1;carte[5][11]=1;
carte[5][12]=1;carte[6][12]=1;carte[7][12]=1;carte[8][12]=1;carte[9][12]=1;
carte[11][12]=1;carte[12][12]=1;carte[13][12]=1;carte[14][12]=1;carte[17][12]=1;
carte[18][12]=1;carte[19][12]=1;carte[20][12]=1;carte[21][12]=1;carte[22][12]=1;
carte[23][12]=1;carte[24][11]=1;carte[24][10]=1;carte[24][9]=1;carte[24][8]=1;
carte[24][7]=1; carte[24][4]=1;carte[24][3]=1;carte[25][1]=1;carte[26][1]=1;
carte[27][1]=1;carte[28][1]=1;carte[30][2]=1;carte[30][3]=1;carte[30][4]=1;
carte[30][5]=1;carte[29][7]=1;carte[28][7]=1;carte[27][8]=1;carte[27][9]=1;//50
carte[27][10]=1;carte[27][11]=1;carte[27][12]=1;carte[27][13]=1;carte[27][14]=1;
carte[26][16]=1;carte[25][16]=1;carte[24][16]=1;carte[21][16]=1;carte[20][16]=1;
carte[19][16]=1;carte[18][16]=1;carte[15][17]=1;carte[14][20]=1;carte[13][20]=1;
carte[10][20]=1;carte[9][20]=1;carte[8][20]=1;carte[7][20]=1;carte[5][21]=1;
carte[5][22]=1;carte[4][24]=1;carte[3][24]=1;carte[2][25]=1;carte[2][26]=1;
carte[2][27]=1;carte[3][29]=1;carte[4][29]=1;carte[6][29]=1;carte[9][29]=1;//80
carte[12][29]=1;carte[14][28]=1;carte[14][27]=1;carte[14][26]=1;carte[15][23]=1;
carte[18][24]=1;carte[19][27]=1;carte[22][26]=1;carte[23][23]=1;//89
}
/*
Creation de la carte avec le chemin sans trou.
*/
void initCarteFull(){
int i,j;
for(i=0;i<32;i++)
for(j=0;j<32;j++)
carte[i][j]=0;
carte[0][1]=1;carte[0][2]=1;carte[0][3]=1;carte[1][3]=1;carte[2][3]=1;
carte[3][3]=1;carte[4][3]=1;carte[5][3]=1;carte[5][4]=1;carte[5][5]=1;
carte[5][6]=1;carte[5][7]=1;carte[5][8]=1;carte[5][9]=1;carte[5][10]=1;
carte[5][11]=1;carte[5][12]=1;carte[6][12]=1;carte[7][12]=1;carte[8][12]=1;
carte[9][12]=1;carte[10][12]=1;carte[11][12]=1;carte[12][12]=1;carte[13][12]=1;
carte[14][12]=1;carte[15][12]=1;carte[16][12]=1;carte[17][12]=1;carte[18][12]=1;
carte[19][12]=1;carte[20][12]=1;carte[21][12]=1;carte[22][12]=1;carte[23][12]=1;
carte[24][12]=1;carte[24][11]=1;carte[24][10]=1;carte[24][9]=1;carte[24][8]=1;
carte[24][7]=1;carte[24][6]=1;carte[24][5]=1;carte[24][4]=1;carte[24][3]=1;
carte[24][2]=1;carte[24][1]=1;carte[25][1]=1;carte[26][1]=1;carte[27][1]=1;//50
carte[28][1]=1;carte[29][1]=1;carte[30][1]=1;carte[30][2]=1;carte[30][3]=1;
carte[30][4]=1;carte[30][5]=1;carte[30][6]=1;carte[30][7]=1;carte[29][7]=1;
carte[28][7]=1;carte[27][7]=1;carte[27][8]=1;carte[27][9]=1;carte[27][10]=1;
carte[27][11]=1;carte[27][12]=1;carte[27][13]=1;carte[27][14]=1;carte[27][15]=1;
carte[27][16]=1;carte[26][16]=1;carte[25][16]=1;carte[24][16]=1;carte[23][16]=1;
carte[22][16]=1;carte[21][16]=1;carte[20][16]=1;carte[19][16]=1;carte[18][16]=1;
carte[17][16]=1;carte[16][16]=1;carte[15][16]=1;carte[15][17]=1;carte[15][18]=1;
carte[15][19]=1;carte[15][20]=1;carte[14][20]=1;carte[13][20]=1;carte[12][20]=1;
carte[11][20]=1;carte[10][20]=1;carte[9][20]=1;carte[8][20]=1;carte[7][20]=1;
carte[6][20]=1;carte[5][20]=1;carte[5][21]=1;carte[5][22]=1;carte[5][23]=1;//100
carte[5][24]=1;carte[4][24]=1;carte[3][24]=1;carte[2][24]=1;carte[2][25]=1;
carte[2][26]=1;carte[2][27]=1;carte[2][28]=1;carte[2][29]=1;carte[3][29]=1;
carte[4][29]=1;carte[5][29]=1;carte[6][29]=1;carte[7][29]=1;carte[8][29]=1;
carte[9][29]=1;carte[10][29]=1;carte[11][29]=1;carte[12][29]=1;carte[13][29]=1;
carte[14][29]=1;carte[14][28]=1;carte[14][27]=1;carte[14][26]=1;carte[14][25]=1;
carte[14][24]=1;carte[14][23]=1;carte[15][23]=1;carte[16][23]=1;carte[17][23]=1;
carte[18][23]=1;carte[18][24]=1;carte[18][25]=1;carte[18][26]=1;carte[18][27]=1;
carte[19][27]=1;carte[20][27]=1;carte[21][27]=1;carte[22][27]=1;carte[22][26]=1;
carte[22][25]=1;carte[22][24]=1;carte[22][23]=1;carte[23][23]=1;//144
}
/*
Fonction qui recopie un sous arbre. Il s'agit d'un vrai clonage et pas d'un
simple echange de références !
*/
Element *copierSousArbreRec(Element* ssArbreSource, int profondeur, int pMax){
Element *elt = new Element;
elt->numero = SIZE++;
elt->profondeur = profondeur;
if(ssArbreSource==NULL)
return NULL;
if(profondeur == pMax){
elt->filsG = NULL;
elt->filsD = NULL;
elt->filsC = NULL;
double rnd = random(0.,1.);
//Left
if(rnd<1./3.)
elt->Value = LEFT;
else if(rnd<2./3.)
elt->Value = RIGHT;
else
elt->Value = MOVE;
}
else{
elt->Value=ssArbreSource->Value;
elt->filsG=copierSousArbreRec(ssArbreSource->filsG,profondeur+1,pMax);
elt->filsC=copierSousArbreRec(ssArbreSource->filsC,profondeur+1,pMax);
elt->filsD=copierSousArbreRec(ssArbreSource->filsD,profondeur+1,pMax);
}
return elt;
}
/*
Fonction de génération d'un noeud.
*/
Element *genererNoeud(int profondeur, int profondeurMaxAutorisee){
Element *elt = new Element;
elt->numero = SIZE++;
elt->profondeur = profondeur;
//Cas d'un symbole terminal (feuille)
if(profondeur == profondeurMaxAutorisee ){
elt->filsG = NULL;
elt->filsD = NULL;
elt->filsC = NULL;
double rnd = random(0.,1.);
//Left
if(rnd<1./3.){
elt->Value = LEFT;
}
else if(rnd<2./3.){
elt->Value = RIGHT;
}
else{
elt->Value = MOVE;
}
}
//Cas d'une fonction (noeud non feuille)
else{
double rnd = random(0.,1.);
if(rnd<1./3.){
elt->Value = food_ahead;
elt->filsG = genererNoeud(profondeur+1,profondeurMaxAutorisee);
elt->filsC = NULL;
elt->filsD = genererNoeud(profondeur+1,profondeurMaxAutorisee);
}
else if(rnd<2./3.){
elt->Value = progn2;
elt->filsG = genererNoeud(profondeur+1,profondeurMaxAutorisee);
elt->filsC = NULL;
elt->filsD = genererNoeud(profondeur+1,profondeurMaxAutorisee);
}
else{
elt->Value = progn3;
elt->filsG = genererNoeud(profondeur+1,profondeurMaxAutorisee);
elt->filsC = genererNoeud(profondeur+1,profondeurMaxAutorisee);
elt->filsD = genererNoeud(profondeur+1,profondeurMaxAutorisee);
}
}
return elt;
}
/*
Cette fonction cherche un noeud dont le numero est passé en paramètre
dans l'arbre passé également en paramètre.
*/
Element *chercheNoeud(Element *eltDepart, int numero){
fflush(stdout);
if(eltDepart == NULL){
return NULL;
}
if(eltDepart->numero == numero){
return eltDepart;
}
else{
Element *tmp = NULL;
if(eltDepart->filsG !=NULL)
tmp = chercheNoeud(eltDepart->filsG, numero);
if(tmp != NULL)
return tmp;
if(eltDepart->filsC !=NULL)
tmp = chercheNoeud(eltDepart->filsC, numero);
if(tmp != NULL)
return tmp;
if(eltDepart->filsD !=NULL)
tmp = chercheNoeud(eltDepart->filsD, numero);
if(tmp != NULL)
return tmp;
}
return NULL;
}
/*
Cette fonction remplace le noeud numero "numero" dans l'arbre de racine "dst"
par l'element src.
*/
void remplace(Element *dst, Element *src, int numero){
if(dst == NULL){
return;
}
if(dst->numero == numero){
dst->Value=src->Value;
dst->filsG=src->filsG;
dst->filsC=src->filsC;
dst->filsD=src->filsD;
}
else{
if(dst->filsG !=NULL)
remplace(dst->filsG, src, numero);
if(dst->filsC !=NULL)
remplace(dst->filsC, src, numero);
if(dst->filsD !=NULL)
remplace(dst->filsD, src, numero);
}
}
/*
Renumerote les noeuds de l'arbre et regenere sa taille
*/
void regenSizeRec(Element *racine, int p){
racine->numero=SIZE++;
racine->profondeur=p;
if(racine->filsG!=NULL)
regenSizeRec(racine->filsG, p+1);
if(racine->filsC!=NULL)
regenSizeRec(racine->filsC, p+1);
if(racine->filsD!=NULL)
regenSizeRec(racine->filsD, p+1);
}
void regenSize(Element *racine){
SIZE=0;
regenSizeRec(racine, 0);
}
int evaluerFoodAhead(int *orientationCourante, int *ligneCourante, int *colCourante){
switch(*orientationCourante){
case nord : {
int l = ((*ligneCourante)-1<0)?(*ligneCourante)-1+taille:(*ligneCourante)-1;
if(carte[l][(*colCourante)]!=1)
return 0;
else
return 1;
}
case sud : {
int l = ((*ligneCourante)+1==taille)?0:(*ligneCourante)+1;
if(carte[l][(*colCourante)]!=1)
return 0;
else
return 1;
}
case est : {
int c = ((*colCourante)+1==taille)?0:(*colCourante)+1;
if(carte[(*ligneCourante)][c]!=1)
return 0;
else
return 1;
}
case ouest : {
int c = ((*colCourante)-1<0)?(*colCourante)-1+taille:(*colCourante)-1;
if(carte[(*ligneCourante)][c]!=1)
return 0;
else
return 1;
}
default:return 0;
}
}
void evaluerMove(int *orientationCourante, int *ligneCourante, int *colCourante, int *fitnessCourant){
switch(*orientationCourante){
case nord : {
(*ligneCourante) = ((*ligneCourante)-1<0)?(*ligneCourante)-1+taille:(*ligneCourante)-1;
break;
}
case sud : {
(*ligneCourante) = ((*ligneCourante)+1==taille)?0:(*ligneCourante)+1;
break;
}
case est : {
(*colCourante) = ((*colCourante)+1==taille)?0:(*colCourante)+1;
break;
}
case ouest : {
(*colCourante) = ((*colCourante)-1<0)?(*colCourante)-1+taille:(*colCourante)-1;
break;
}
}
if(carte[(*ligneCourante)][(*colCourante)]==1){
*fitnessCourant = *fitnessCourant-1;
carte[(*ligneCourante)][(*colCourante)]=-1;
//Partie utile si l'on veut stopper l'évolution immédiatement apres avoir trouve l'individu
//(pour calculer le nombre d'évaluations precis)
/* if(*fitnessCourant==0){
FILE *fichier;
fichier = fopen("sortie.txt","a");
fprintf(fichier,"Individu idéal trouvé après %d évaluations\t %d\n",nbEvalTotal,nbEvalTotal);
fclose(fichier);
exit(0);
} */
}
}
void evaluerNoeud(Element *elt, int *orientationCourante, int *ligneCourante, int *colCourante, int *fitnessCourant, int *nbPas){
if(*nbPas>=nbPasMax)
return;
switch(elt->Value){
case food_ahead : {
if(evaluerFoodAhead(orientationCourante, ligneCourante, colCourante)>0)
evaluerNoeud(elt->filsG,orientationCourante, ligneCourante, colCourante, fitnessCourant, nbPas);
else
evaluerNoeud(elt->filsD,orientationCourante, ligneCourante, colCourante, fitnessCourant, nbPas);
break;
}
case progn2 : {
evaluerNoeud(elt->filsG,orientationCourante, ligneCourante, colCourante, fitnessCourant, nbPas);
evaluerNoeud(elt->filsD,orientationCourante, ligneCourante, colCourante, fitnessCourant, nbPas);
break;
}
case progn3 : {
evaluerNoeud(elt->filsG,orientationCourante, ligneCourante, colCourante, fitnessCourant, nbPas);
evaluerNoeud(elt->filsC,orientationCourante, ligneCourante, colCourante, fitnessCourant, nbPas);
evaluerNoeud(elt->filsD,orientationCourante, ligneCourante, colCourante, fitnessCourant, nbPas);
break;
}
case LEFT : {
switch(*orientationCourante){
case est:*orientationCourante=nord;(*nbPas)++;break;
case sud:*orientationCourante=est;(*nbPas)++;break;
case ouest:*orientationCourante=sud;(*nbPas)++;break;
case nord:*orientationCourante=ouest;(*nbPas)++;break;
}
break;
}
case RIGHT : {
switch(*orientationCourante){
case est:*orientationCourante=sud;(*nbPas)++;break;
case sud:*orientationCourante=ouest;(*nbPas)++;break;
case ouest:*orientationCourante=nord;(*nbPas)++;break;
case nord:*orientationCourante=est;(*nbPas)++;break;
}
break;
}
case MOVE : {
evaluerMove(orientationCourante, ligneCourante, colCourante, fitnessCourant);(*nbPas)++;
break;
}
}
}
void imprimerArbre(Element *elt){
switch(elt->Value){
case food_ahead : {
printf("IF_FOOD-");
imprimerArbre(elt->filsG);
imprimerArbre(elt->filsD);
break;
}
case progn2 : {
printf("PROGN2-");
imprimerArbre(elt->filsG);
imprimerArbre(elt->filsD);
break;
}
case progn3 : {printf("PROGN3-");
imprimerArbre(elt->filsG);
imprimerArbre(elt->filsC);
imprimerArbre(elt->filsD);
break;
}
case LEFT : {printf("LEFT-");
break;
}
case RIGHT : {printf("RIGHT-");
break;
}
case MOVE : {printf("MOVE-");
break;
}
}
}
void imprimerArbreDansFichier(Element *elt, FILE *fichier){
switch(elt->Value){
case food_ahead : {
fprintf(fichier,"IF_FOOD-");
imprimerArbreDansFichier(elt->filsG, fichier);
imprimerArbreDansFichier(elt->filsD, fichier);
break;
}
case progn2 : {
fprintf(fichier,"PROGN2-");
imprimerArbreDansFichier(elt->filsG, fichier);
imprimerArbreDansFichier(elt->filsD, fichier);
break;
}
case progn3 : {fprintf(fichier,"PROGN3-");
imprimerArbreDansFichier(elt->filsG, fichier);
imprimerArbreDansFichier(elt->filsC, fichier);
imprimerArbreDansFichier(elt->filsD, fichier);
break;
}
case LEFT : {fprintf(fichier,"LEFT-");
break;
}
case RIGHT : {fprintf(fichier,"RIGHT-");
break;
}
case MOVE : {fprintf(fichier,"MOVE-");
break;
}
}
}
\end
\Before everything else function:
if ((argc>1)&&(!strcmp(argv[1],"size"))) SIZE=atoi(argv[2]);
\end
\User classes:
Element {
int Value;
int numero;
int profondeur;
Element *filsG;
Element *filsC;
Element *filsD;
}
GenomeClass {
Element *arbre;