求遗传算法(GA)C语言代码
的有关信息介绍如下:x=220; for(i=0;i<12;i++) { y=202+i*16; for(j=bits [ i][0];j<=bits [ i][1];j++) if(g[j]==0) g_text(x+(j-bits [ i][0])*16,y,4,"0"); else g_text(x+(j-bits [ i][0])*16,y,4,"1"); } } } void g_disp_char(x,y,x1,y1,x2,y2,v) int x,y,x1,y1,x2,y2; unsigned char v; { char c[10]; if(x>=x1&& x<=x2-8 && y>=y1 && y<=y2-10) { switch(v) { case 0: strcpy(c,"0");break; case 1: strcpy(c,"+");break; case 2: strcpy(c,"-");break; case 3: strcpy(c,"x"); } g_text(x,y,15,c); } } void remove_life(n) /* 消除第n个个体 */ int n; { iflg[n]=0; world[iatr[n][0]][iatr[n][1]]=0; 者袭 g_disp_unit(iatr[n][0],iatr[n][1],0); if(food_size+1<=MAX_FOOD) { food_size++; fatr[food_size-1][0]=iatr[n][0]; fatr[food_size-1][1]=iatr[n][1]; fatr[food_size-1][2]=1; fatr[food_size-1][3]=0; fflg[food_size-1]=1; world[iatr[n][0]][iatr[n][1]]=5; g_disp_unit(iatr[n][0],iatr[n][1],5); } } void remove_food(n) /* 消除第n个食物 */ int n; { fflg[n]=0; world[fatr[n][0]][fatr[n][1]]=0; g_disp_unit(fatr[n][0],fatr[n][1],0); } void make_lives_and_foods() /* 设置虚拟环境中生物与食物 */ { int x,y,i,j; pop_size=0; food_size=0; for(y=0;y