示例#1
0
int main() {
	srand(time(NULL));
	int i;

	// RPC

	SVCXPRT *transp;

	// initialize map
	M_init(&map, 100, 85, PERCENTAGE, OBS_SIZE);

	// initialize populations
	for(i=0; i < NB_POP; i++) {
		pop_tab[i] = Population_new();
		Population_init(pop_tab[i], &map);
		pop_tab[i]->id = i + 1;
		pop_status[i] = 1;
	}


	Population_sort(pop_tab[0]);
	best_dna = pop_tab[0]->dna_tab[0];
	printf("Best DNA of first population: %f\n", pop_tab[0]->dna_tab[0].score);


	// initialize RPC

	pmap_unset(MWAP, MWAP_V1);

	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
	if (transp == NULL) {
		fprintf (stderr, "%s", "cannot create tcp service.");
		exit(1);
	}
	if (!svc_register(transp, MWAP, MWAP_V1, dispatch, IPPROTO_TCP)) {
		fprintf (stderr, "%s", "unable to register (MWAP, MWAP_V1, tcp).");
		exit(1);
	}

	svc_run();
	return 0;
}
示例#2
0
文件: knight.c 项目: ffavela/knight
int main(int argc, char *argv[])
{
	int m=0, n=0;
	int mvnum = 1, i=0;
	int M[ROWS][COLS], mvchoice[TOT+1];/*mvchoice[0] is not used... yet*/
	if(argc==3)
		m=atoi(argv[1])-1, n=atoi(argv[2])-1;
	
/*Initialize the arrays*/
	Aones(mvchoice);
	M_init(M, m, n);

	while(mvnum){
		while(mvnum < TOT)
			mvnum = move(M, mvnum, mvchoice, &m, &n);
		printb(M);
		printf("%d\n", ++i);
		while(mvnum == TOT)
			mvnum = move(M, mvnum, mvchoice, &m, &n);
		//mvchoice[--mvnum] = 9;
	}
	return 0;
}