From f973a438dad7c450e36bdaea42d184020405e35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Fri, 26 Jun 2009 23:23:39 +0200 Subject: [PATCH] First task debug with skip --- ovm/base.h | 2 ++ ovm/task.h | 3 ++- ovm/task1.c | 22 +++++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ovm/base.h b/ovm/base.h index ff48de6..fc8649d 100644 --- a/ovm/base.h +++ b/ovm/base.h @@ -9,6 +9,8 @@ #define GSTR_LEN(x) (x) ? (x)->str : "", (x) ? (x)->len : 0 #define GSTR_SAFE_STR(x) ((x && x->str) ? x->str : "(null)") +#define UNUSED(x) ((void)(x)) + #include #include diff --git a/ovm/task.h b/ovm/task.h index 5b360ac..341b845 100644 --- a/ovm/task.h +++ b/ovm/task.h @@ -17,12 +17,13 @@ void task_free(task_t *task); void ovm_init(); void ovm_step(gdouble scenario, gdouble *in, gdouble *out); -static inline void task_run(task_t *task, task_app_t app) { +static inline gdouble task_run(task_t *task, task_app_t app) { ovm_init(); while (task->out[0] == 0.0) { app(task); ovm_step(task->scenario, task->in, task->out); } + return task->out[0]; } #endif \ No newline at end of file diff --git a/ovm/task1.c b/ovm/task1.c index e4a2955..7a29b0a 100644 --- a/ovm/task1.c +++ b/ovm/task1.c @@ -1,6 +1,26 @@ -#include "base.h" +#include "task.h" + +static void debug(task_t * task) { + gdouble *o = task->out; + g_debug( + "Score: %5f Fuel: %5f x: %5f y: %5f r: %5f\n", + o[0], o[1], o[2], o[3], o[4]); +} + +static void run(task_t *task) { + debug(task); +} int main(int argc, char **argv) { + task_t *task; + gdouble score; + + UNUSED(argc); + UNUSED(argv); + + task = task_new(1001.0, 4, 5); + score = task_run(task, run); + printf("Final Score: %f\n", score); return 0; } \ No newline at end of file