/* ** Sets up a combatant for each player and 5 + difficulty/2 robots. */ standard_combatants() { Combatant *c; int i; num_combatants = num_terminals + 5 + settings.difficulty / 2; for (i = 0; i < num_combatants; i++) { c = &combatant[i]; if (i < num_terminals) { /* Set up a vehicle for each player */ c->num_players = 1; c->player[0] = i; c->num_programs = 0; c->team = (i + 1) % MAX_TEAMS; c->vdesc = terminal[i]->vdesc; } else { /* Set up everyone else as neutral robots */ c->num_players = 0; c->num_programs = 1; c->program[0] = choose_program(); c->team = NEUTRAL; c->vdesc = 0; } } }
int main(int argc, char const *argv[]){ char prog[512]=""; // paths to external files can be big char *args[6]; if( argc < 5 || !check_main_args(argc, argv) ){ printf("\nUsage: %s seq1_file seq2_file [gaps|indels] [dp|dpp -b=NUMBER] [-ss=FILE] [--no-traceback]\n", argv[0]); printf("\nOptions:\n"); printf(" seq1_file\t\tpath to the 1st sequence file (FASTA format)\n"); printf(" seq2_file\t\tpath to the 2nd sequence file (FASTA format)\n"); printf(" gaps\t\t\tspecify the problem to be relative to gaps.\n"); printf(" indels\t\tspecify the problem to be relative to indels.\n"); printf(" dp\t\t\tuse Dynamic Programming approach.\n"); printf(" dpp\t\t\tuse Dynamic Programming approach with pruning (need to specify -b=NUMBER).\n"); printf(" -ss=FILE\t\tuse substitution score(ss) instead of #matches (path to the ss table).\n"); printf(" -b=NUMBER\t\tspecify the number of MID bounds to prune.\n"); printf(" --no-traceback\toutput only the scores without the result alignments.\n"); return -1; } // relative path to program from the location execution started char path_to_prog[300]; char * last_slash = strrchr(argv[0], '/'); memcpy( path_to_prog, argv[0], last_slash-argv[0] ) ; path_to_prog[last_slash-argv[0]] = '\0'; // add relative path to current program strcat(prog, path_to_prog); choose_program( prog, args, argc, argv ); printf("running \"%s ", prog); int i; for( i = 1; i < 5; ++i ) if(args[i]) printf("%s ", args[i]); printf("\"\n"); if (execv(prog, args) == -1) perror("Error executing program"); return 0; }
/* ** Sets up 5 + difficulty robot combatants on different teams. */ robot_combatants() { Combatant *c; int i; num_combatants = 5 + settings.difficulty; for (i = 0; i < num_combatants; i++) { c = &combatant[i]; c->num_players = 0; c->num_programs = 1; c->program[0] = choose_program(); c->team = i % MAX_TEAMS; c->vdesc = 0; } }