icfp11/src/main.c

40 lines
648 B
C

#include "control.h"
#include "path.h"
#include <stdio.h>
void trial_loop(trial *t) {
path *p;
do {
if (-1 == trial_wait_for_start(t)) return;
if (t->finished) break;
/*create trivial path towards the origin*/
p = path_new(&t->map, &t->vehicle);
while (t->alive) {
path_execute(t,p);
if (-1 == trial_check_input(t)) return;
}
path_free(p);
} while (!t->finished);
}
int main(int argc, char **argv) {
trial *t;
if (argc <= 2) {
fprintf(stderr, "Syntax: %s hostname port\n", argv[0]);
return 1;
}
if (NULL == (t = trial_new(argv[1], argv[2]))) {
return 2;
}
trial_loop(t);
trial_free(t);
return 0;
}