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/main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 7d4d0fc..a6da033 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,17 +2,27 @@ #include #include "graphics.hpp" #include "game.hpp" +#include "ai.hpp" +#include "rand_ai.hpp" #define WINDOW_TITLE "2048" #define WINDOW_WIDTH 640 #define WINDOW_HEIGHT 480 #define GAME_GRID_SIZE 6 -int main() +int main(int argc, char **argv) { + Graphics *graphics; + srand(time(NULL)); Game game = Game(GAME_GRID_SIZE); - Graphics *graphics = new Graphics(&game, WINDOW_TITLE, WINDOW_WIDTH, WINDOW_HEIGHT); + if (argc == 2 && strcmp(argv[1], "--ai") == 0) + { + RandAI ai = RandAI(&game); + graphics = new Graphics(&game, WINDOW_TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, &ai); + } + else + graphics = new Graphics(&game, WINDOW_TITLE, WINDOW_WIDTH, WINDOW_HEIGHT); while (graphics->isRunning()) graphics->update(); delete graphics; -- cgit