-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.hpp
29 lines (23 loc) · 900 Bytes
/
board.hpp
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
#ifndef BOARD_HPP
#define BOARD_HPP
#include <string>
enum class WinningDirection { kHorizontal, kVertical, kRightDiag, kLeftDiag };
enum class DiskType { kPlayer1 = 82, kPlayer2 = 66, kEmpty = 32 };
struct Board {
static constexpr int kBoardWidth = 7;
static constexpr int kBoardHeight = 6;
DiskType board[kBoardHeight][kBoardWidth];
};
void InitBoard(Board& b);
void DropDiskToBoard(Board& b, DiskType disk, int col);
bool CheckForWinner(Board& b, DiskType disk);
bool SearchForWinner(Board& b, DiskType disk, WinningDirection to_check);
bool BoardLocationInBounds(int row, int col);
bool DiagonalRight(Board& b, DiskType disk);
bool DiagonalLeft(Board& b, DiskType disk);
bool CheckHorizontal(Board& b, DiskType disk);
bool CheckVertical(Board& b, DiskType disk);
// provided
std::string BoardToStr(const Board& b);
std::string CenterStr(const std::string& str, int col_width);
#endif