From 1da480b331d4637459e1e5e664a3de45835d2f6f Mon Sep 17 00:00:00 2001 From: Tiehuis Date: Wed, 25 Feb 2015 14:53:49 +1300 Subject: [PATCH] Add the ai files that were forgotten in previous commit --- src/ai.c | 10 ++++++++++ src/ai.h | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/ai.c create mode 100644 src/ai.h diff --git a/src/ai.c b/src/ai.c new file mode 100644 index 0000000..ed82d41 --- /dev/null +++ b/src/ai.c @@ -0,0 +1,10 @@ +#include "ai.h" +#include "engine.h" + +const char moves[] = {'w', 'a', 's', 'd'}; + +int ai_move(struct gamestate *g) +{ + if (g->opts->interactive) usleep(50000); + return moves[rand() % 4]; +} diff --git a/src/ai.h b/src/ai.h new file mode 100644 index 0000000..05e437f --- /dev/null +++ b/src/ai.h @@ -0,0 +1,8 @@ +#ifndef AI_H +#define AI_H + +#include "engine.h" + +int ai_move(struct gamestate *g); + +#endif