-
Notifications
You must be signed in to change notification settings - Fork 1
/
grid.h
52 lines (32 loc) · 754 Bytes
/
grid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Created by user on 27/10/2023.
//
#include <stdint.h>
#pragma once
#define SIZE 4
enum direction {
UP=0,
DOWN=1,
LEFT=2,
RIGHT=3
};
const int DIRECTIONS[4] = {UP, DOWN, LEFT, RIGHT};
class grid {
public:
grid();
grid(int8_t tiles[SIZE * SIZE], int64_t score);
grid(const grid &g);
void show();
bool up();
bool down();
bool left();
bool right();
bool move(int direction);
inline int64_t getScore() const { return score; }
inline int16_t getEmpty() const { return empty; }
private:
bool add();
int8_t tiles[SIZE * SIZE]; // tiles on the grid (0 = empty, 2^x = tile with value x)
int64_t score; // current score
int16_t empty; // number of empty tiles
};