-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame2.h
More file actions
87 lines (76 loc) · 2.04 KB
/
Copy pathGame2.h
File metadata and controls
87 lines (76 loc) · 2.04 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
//
// Created by DELL on 12/17/2023.
//
#ifndef INCLUDE_GAME2_H
#define INCLUDE_GAME2_H
#include <bits/stdc++.h>
using namespace std;
class Board2{
protected:
int n_rows, n_cols;
char** board;
int n_moves = 0;
static int cnt;
public:
// Return true if move is valid and put it on board
// within board boundaries in empty cell
// Return false otherwise
virtual bool update_board2 ( int y, char symbol) = 0;
// Returns true if there is any winner
// either X or O
// Written in a complex way. DO NOT DO LIKE THIS.
virtual bool is_winner2() = 0;
// Return true if all moves are done and no winner
virtual bool is_draw2() = 0;
// +9Display the board and the pieces on it
virtual void display_board2() = 0;
// Return true if game is over
virtual bool game_is_over2() = 0;
};
class Connect_four_Board:public Board2 {
public:
// Set the board
Connect_four_Board();
bool update_board2(int y, char symbol) ;
void display_board2() ;
bool game_is_over2() ;
bool is_draw2() ;
bool is_winner2();
};
class Player2 {
protected:
string name;
char symbol;
public:
Player2 (char symbol); // Needed for computer players
Player2 (int order, char symbol);
virtual void get_move( int &x,int& y);
string to_string();
char get_symbol() ;
};
class RandomPlayer2: public Player2 {
protected:
int dimension1;
public:
// Take a symbol and pass it to parent
RandomPlayer2 (char symbol, int dimension1);
// Generate a random move
void get_move(int&x,int &y) override;
};
class GameManager2 {
private:
Board2* boardPtr;
Player2* players[2];
public:
GameManager2(Board2*, Player2* playerPtr[2]);
void run();
// This method creates board and players
// It displays board
// While True
// For each player
// It takes a valid move as x, y pair (between 0 - 2)
// It updates board and displays otit
// If winner, declare so and end
// If draw, declare so and end
};
#endif //INCLUDE_GAME2_H