Update last_ts

This commit is contained in:
Stefan Bühler 2008-07-12 03:52:33 +02:00
parent 3c6f6f92f8
commit 17248320b7
3 changed files with 37 additions and 35 deletions

View File

@ -27,7 +27,7 @@ static timestamp extract_ts(context *ctx, char *fpc) {
return atoi(ctx->tmp->str);
}
#line 113 "control_parser.rl"
#line 114 "control_parser.rl"
@ -240,7 +240,7 @@ static const int control_parser_error = 0;
static const int control_parser_en_main = 1;
#line 116 "control_parser.rl"
#line 117 "control_parser.rl"
static int control_parser_has_error(context *ctx) {
return ctx->cs == control_parser_error;
@ -257,7 +257,7 @@ void control_parser_new(trial *t) {
{
( ctx->cs) = control_parser_start;
}
#line 128 "control_parser.rl"
#line 129 "control_parser.rl"
ctx->buffer = g_string_sized_new(0);
ctx->tmp = g_string_sized_new(0);
ctx->mark = -1;
@ -271,7 +271,7 @@ void control_parser_reset(trial *t) {
{
( ctx->cs) = control_parser_start;
}
#line 137 "control_parser.rl"
#line 138 "control_parser.rl"
g_string_truncate(ctx->tmp, 0);
ctx->mark = -1;
ctx->pos = 0;
@ -384,131 +384,132 @@ _match:
#line 37 "control_parser.rl"
{
g_queue_push_tail(&t->telemetry, ctx->tm);
t->last_ts = ctx->tm->ts;
ctx->tm = NULL;
t->alive = 1;
}
break;
case 4:
#line 42 "control_parser.rl"
#line 43 "control_parser.rl"
{
ctx->tm->ts = ctx->ts;
t->vehicle.x = ctx->x;
t->vehicle.y = ctx->y;
t->vehicle.dir = ctx->dir;
t->vehicle.speed = ctx->speed;
printf("Vehicle at %f / %f\n", ctx->x, ctx->y);
/* printf("Vehicle at %f / %f\n", ctx->x, ctx->y); */
}
break;
case 5:
#line 55 "control_parser.rl"
#line 56 "control_parser.rl"
{ t->map.dx = extract_double(ctx, p); }
break;
case 6:
#line 56 "control_parser.rl"
#line 57 "control_parser.rl"
{ t->map.dy = extract_double(ctx, p); }
break;
case 7:
#line 57 "control_parser.rl"
#line 58 "control_parser.rl"
{ t->map.min_sensor = extract_double(ctx, p); }
break;
case 8:
#line 58 "control_parser.rl"
#line 59 "control_parser.rl"
{ t->map.max_sensor = extract_double(ctx, p); }
break;
case 9:
#line 59 "control_parser.rl"
#line 60 "control_parser.rl"
{ t->map.max_speed = extract_double(ctx, p); }
break;
case 10:
#line 60 "control_parser.rl"
#line 61 "control_parser.rl"
{ t->map.max_turn = extract_double(ctx, p); }
break;
case 11:
#line 61 "control_parser.rl"
#line 62 "control_parser.rl"
{ t->map.max_hard_turn = extract_double(ctx, p); }
break;
case 12:
#line 65 "control_parser.rl"
#line 66 "control_parser.rl"
{ ctx->x = extract_double(ctx, p); }
break;
case 13:
#line 66 "control_parser.rl"
#line 67 "control_parser.rl"
{ ctx->y = extract_double(ctx, p); }
break;
case 14:
#line 67 "control_parser.rl"
#line 68 "control_parser.rl"
{ ctx->r = extract_double(ctx, p); }
break;
case 15:
#line 68 "control_parser.rl"
#line 69 "control_parser.rl"
{ ctx->dir = extract_double(ctx, p); }
break;
case 16:
#line 69 "control_parser.rl"
#line 70 "control_parser.rl"
{ ctx->speed = extract_double(ctx, p); }
break;
case 17:
#line 71 "control_parser.rl"
#line 72 "control_parser.rl"
{ ctx->tm->vehicle.accel = ACCEL; }
break;
case 18:
#line 72 "control_parser.rl"
#line 73 "control_parser.rl"
{ ctx->tm->vehicle.accel = ROLL; }
break;
case 19:
#line 73 "control_parser.rl"
#line 74 "control_parser.rl"
{ ctx->tm->vehicle.accel = BREAK; }
break;
case 20:
#line 75 "control_parser.rl"
#line 76 "control_parser.rl"
{ ctx->tm->vehicle.turn = TURN_HARD_LEFT; }
break;
case 21:
#line 76 "control_parser.rl"
#line 77 "control_parser.rl"
{ ctx->tm->vehicle.turn = TURN_LEFT; }
break;
case 22:
#line 77 "control_parser.rl"
#line 78 "control_parser.rl"
{ ctx->tm->vehicle.turn = TURN_STRAIGHT; }
break;
case 23:
#line 78 "control_parser.rl"
#line 79 "control_parser.rl"
{ ctx->tm->vehicle.turn = TURN_RIGHT; }
break;
case 24:
#line 79 "control_parser.rl"
#line 80 "control_parser.rl"
{ ctx->tm->vehicle.turn = TURN_HARD_RIGHT; }
break;
case 25:
#line 81 "control_parser.rl"
#line 82 "control_parser.rl"
{ ctx->ts = extract_ts(ctx, p); }
break;
case 26:
#line 82 "control_parser.rl"
#line 83 "control_parser.rl"
{ printf("Score %u\n", extract_ts(ctx, p)); }
break;
case 27:
#line 84 "control_parser.rl"
#line 85 "control_parser.rl"
{
object o = { BOLDER, ctx->x, ctx->y, ctx->r, 0, 0 };
g_array_append_val(ctx->tm->objects, o);
}
break;
case 28:
#line 88 "control_parser.rl"
#line 89 "control_parser.rl"
{
object o = { CRATER, ctx->x, ctx->y, ctx->r, 0, 0 };
g_array_append_val(ctx->tm->objects, o);
}
break;
case 29:
#line 93 "control_parser.rl"
#line 94 "control_parser.rl"
{
object o = { MARTIAN, ctx->x, ctx->y, ctx->r, ctx->dir, ctx->speed };
g_array_append_val(ctx->tm->objects, o);
}
break;
#line 512 "control_parser.c"
#line 513 "control_parser.c"
}
}
@ -520,7 +521,7 @@ _again:
_test_eof: {}
_out: {}
}
#line 160 "control_parser.rl"
#line 161 "control_parser.rl"
ctx->pos = p - ctx->buffer->str;
if (ctx->mark == -1) {

View File

@ -36,6 +36,7 @@ static timestamp extract_ts(context *ctx, char *fpc) {
action telemetrystart { ctx->tm = telemetry_new(); }
action telemetrystop {
g_queue_push_tail(&t->telemetry, ctx->tm);
t->last_ts = ctx->tm->ts;
ctx->tm = NULL;
t->alive = 1;
}
@ -45,7 +46,7 @@ static timestamp extract_ts(context *ctx, char *fpc) {
t->vehicle.y = ctx->y;
t->vehicle.dir = ctx->dir;
t->vehicle.speed = ctx->speed;
printf("Vehicle at %f / %f\n", ctx->x, ctx->y);
/* printf("Vehicle at %f / %f\n", ctx->x, ctx->y); */
}
SP = " ";

View File

@ -22,8 +22,8 @@ int main(int argc, char **argv) {
trial_wait_for_start(t);
p = path_new(&t->map,&t->vehicle);
while(t->alive){
trial_wait_for_input(t);
path_execute(t,p);
trial_wait_for_input(t);
}
path_free(p);