-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.h
More file actions
executable file
·91 lines (68 loc) · 2.16 KB
/
Copy pathgame.h
File metadata and controls
executable file
·91 lines (68 loc) · 2.16 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// ECE 469: Artificial Intelligence, Prof. Sable
// Checkers - by Miraj Patel
// game.h - Setuping the game itself and internal functions to play the game (with an 8x4 array representing the 8x8 field)
#ifndef GAME_H
#define GAME_H
#include <string>
#include <vector>
#include <unistd.h>
#define NUMPIECES 12
#define MAXMOVES 32
#define NE 1
#define NW 2
#define SE 3
#define SW 4
#define JUMPMOVE 1
#define NONJUMPMOVE 2
// These are used for modulo 2 logic to determine which player's piece it is quickly
#define P1REGULAR 1
#define P2REGULAR 2
#define P1KING 3
#define P2KING 4
#define PEMPTY 0
// These are used to represent the board using ASCII characters
#define P1RegularPiece 'x'
#define P2RegularPiece 'o'
#define P1KingPiece 'K'
#define P2KingPiece 'Q'
#define EmptyPiece ' '
#define MOVESTODRAW 50
using namespace std;
extern const string INVALIDSQCOLOR;
extern const string VALIDSQCOLOR;
extern const string PLAYER1COLOR;
extern const string PLAYER2COLOR;
struct Location {
short row, column;
Location() { row = -1, column = -1; }
};
struct Move {
int startPiece, numJumps;
Location end, jumpedLocations[NUMPIECES];
Move() { startPiece = -1; numJumps = 0;}
};
class Game {
private:
char *colorPieces (char piece);
string nameSquare(int row, int column);
void addMove(Move &newMove, char type);
void setEndLocation(Location *start, Location &end, int direction, int distance);
bool getJumps(Move &firstJump, int (&directions)[4], int numDirections);
void getNonJumps(Move &firstJump, int (&directions)[4], int numDirections);
bool takePiece(Location &captured);
public:
Game();
// curTurn = 0 => player 2's turn, curTurn = 1 => player 1's turn
unsigned int curTurn, numMoves, numNonJumpMoves;
bool onlyShowJumps;
char board[8][4];
std::vector<Location> pieces[2];
Move movesAvailable[MAXMOVES];
// getNextMoves find the next moves for whoever's turn it is
void getNextMoves();
void printNextMoves();
void chooseMove(int choice);
void printBoard();
};
void copyGame(Game &destGame, Game &srcGame);
#endif