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 /include | |
| 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 'include')
| -rw-r--r-- | include/ai.hpp | 17 | ||||
| -rw-r--r-- | include/graphics.hpp | 7 | ||||
| -rw-r--r-- | include/rand_ai.hpp | 17 |
3 files changed, 40 insertions, 1 deletions
diff --git a/include/ai.hpp b/include/ai.hpp new file mode 100644 index 0000000..bdb6764 --- /dev/null +++ b/include/ai.hpp @@ -0,0 +1,17 @@ +#ifndef AI_HPP +# define AI_HPP + +#include "2048.hpp" +#include "game.hpp" + +class AI +{ + public: + // AI(Game *g); + virtual Direction move() = 0; + + private: + Game *game; +}; + +#endif diff --git a/include/graphics.hpp b/include/graphics.hpp index ebb596b..6951fc0 100644 --- a/include/graphics.hpp +++ b/include/graphics.hpp @@ -11,11 +11,12 @@ #include <SDL2/SDL_ttf.h> #include "game.hpp" #include "2048.hpp" +#include "ai.hpp" class Graphics { public: - Graphics(Game *g, std::string t, int w, int h); + Graphics(Game *g, std::string t, int w, int h, AI *ai = NULL); ~Graphics(); void update(); @@ -34,6 +35,10 @@ class Graphics SDL_Texture *scoreText; std::vector< std::pair<int, SDL_Texture*> > numberTexBuf; std::map< int, SDL_Color > palette; + AI *ai; + Uint32 aiTimeStep; + Uint32 aiNextTime; + void drawGame(); void drawCell(int x, int y); diff --git a/include/rand_ai.hpp b/include/rand_ai.hpp new file mode 100644 index 0000000..9739dae --- /dev/null +++ b/include/rand_ai.hpp @@ -0,0 +1,17 @@ +#ifndef RAND_AI_HPP +# define RAND_AI_HPP + +#include "ai.hpp" +#include "game.hpp" + +class RandAI : public AI +{ + public: + RandAI(Game *g); + Direction move(); + + private: + Game *game; +}; + +#endif |
