Ejemplo n.º 1
0
int main( const int argc,char* const argv[ ] ) {
	bool help = false;
	FILE* infile = stdin;
	unsigned edge_stride = 1;

	int opt;
	while( ( opt = getopt( argc,argv,"a:n:" ) )!=-1 ) {
		switch( opt ) {
		case 'a':
			edge_stride = strtoul( optarg,NULL,0 );
			if( edge_stride<1 )
				help = true;
			break;
		}
	}

	if( help ) {
		printf( "%s %s\n",argv[ 0 ],usage );
		exit( EXIT_FAILURE );
	}

	struct NodeStorage* sys = new_from_file( infile,edge_stride );

	// TODO

	destroy( sys );

	return( EXIT_SUCCESS );
}
Ejemplo n.º 2
0
int main(int argc, char *argv[]){
	struct state *s = new_from_file(argv[1]);
	struct state *t, *s0;
	char *answer;
	int status, stage, i, j, bestv=0;
	char *result = malloc (((s-> world_w+1) * s->world_h * sizeof(char)));
	char *best = malloc (((s-> world_w+1) * s->world_h * sizeof(char)));

	s0 = copy(s);
	srand(time(NULL));

  for(j=1; j<150; j++){
    stage=0;
	strcpy(result, "");
	free(s);
	s = copy(s0);
	i= j%80+1;
		
	do{
		t = copy(s);
		status=goSomewhere(t, &answer, i);
//		free(t);
		t = copy(s);
		if(status==0) 
			s = make_moves(s, answer);
		if(status==1 || s->condition == C_LOSE || (j>30 && rand()*100>180-j)){
			free(s);
			s=copy(t);
			anyMove(t, &answer, rand()*5);
			stage++;
     		s = make_moves(s, answer);
		}
		strcat(result, answer);
		free(t);
	}while(s->condition == C_NONE && stage < s->world_h*8 && s->score>-1000 );
	
	s = make_moves(s0, result);
	printf("%d: %ld\n", j, s->score);
	if(s->score > bestv){
		strcpy(best, result);
		bestv = s->score;
	}
  }
  s = make_moves(s0, best);
  dump(s);
  printf("%s\n", best);
  fflush(stdout);
  return 0;
}