From 19ae4e74aedbbfde9aaed9241f616decc3ec9059 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 19 Mar 2020 15:22:00 +0100 Subject: Interface for ai (tested with random AI) --- src/rand_ai.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/rand_ai.cpp (limited to 'src/rand_ai.cpp') diff --git a/src/rand_ai.cpp b/src/rand_ai.cpp new file mode 100644 index 0000000..db2cf4f --- /dev/null +++ b/src/rand_ai.cpp @@ -0,0 +1,13 @@ +#include "rand_ai.hpp" + +RandAI::RandAI(Game *g) +{ + game = g; +} + +Direction RandAI::move() +{ + Direction directions[4] = {DIRECTION_LEFT, DIRECTION_RIGHT, + DIRECTION_DOWN, DIRECTION_UP}; + return directions[rand() % 4]; +} -- cgit