diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-03-19 15:22:00 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-03-19 15:22:00 +0100 |
| commit | 19ae4e74aedbbfde9aaed9241f616decc3ec9059 (patch) | |
| tree | c4eca1b207261e24b645d5d861b3b27631ead75e /src/main.cpp | |
| parent | c435852cc6147a0af23ef12cc0a07a195ac60756 (diff) | |
| download | 2048-19ae4e74aedbbfde9aaed9241f616decc3ec9059.tar.gz 2048-19ae4e74aedbbfde9aaed9241f616decc3ec9059.tar.bz2 2048-19ae4e74aedbbfde9aaed9241f616decc3ec9059.zip | |
Interface for ai (tested with random AI)
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
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 <cstdlib> #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; |
