Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- #define pb push_back
- #define pr(x) for(auto i : x) {cout << i << " " ; } cout << "\n";
- #define loop(i, x, y) for(int i = x; i < y; i++)
- #define ll long long
- using namespace std;
- class Board{
- private:
- vector<vector<int>> a;
- public:
- Board(){
- a.resize(3, vector<int> (3, 0));
- }
- void print(){
- for(auto i : a){
- for(auto j : i){
- cout << j;
- }
- cout << "\n";
- }
- }
- bool go_check(int i, int j){
- return (a[i][j] == 0 and i <= 2 and j <= 2);
- }
- // проверка выполнения условия победы
- //или ничьей после сделанного хода;
- int res(){
- // gor
- for(auto i : a){
- bool win = true;
- for(int j = 0; j < a.size()-1; j++){
- if(i[j] != i[j+1] or i[j] == 0 or i[j+1] == 0){
- win = false;
- }
- }
- if(win){
- return i[0]; // победа по горизонтали
- }
- }
- // vert
- for(int j = 0; j < a[0].size(); j++){
- bool win = true;
- for(int i = 0; i < a.size() - 1; i++){
- if(a[i][j] != a[i+1][j] or a[i][j] == 0 or a[i+1][j] == 0 ){
- win = false;
- }
- }
- if(win){
- return a[0][j]; // победа по горизонтали
- }
- }
- if(a[0][0] == a[1][1] and a[1][1] == a[2][2] and a[0][0] != 0){
- return a[0][0];
- }
- if(a[0][2] == a[1][1] and a[1][1] == a[2][0] and a[1][1] != 0){
- return a[1][1];
- }
- bool nec = false;
- for(int i = 0; i < a.size(); i++){
- for(int j = 0; j < a[0].size(); j++){
- if(a[i][j] == 0){
- nec = true;
- }
- }
- }
- if(!nec){
- return 2;
- }
- return 0;
- }
- };
- class ComputerPlayer: public Board{
- private:
- bool hard;
- public:
- ComputerPlayer(){
- hard = false;
- }
- void play(){
- if(hard){
- cout << "123";
- }
- }
- };
- class Game: public ComputerPlayer{
- private:
- bool hard;
- string name1, name2;
- char gamemod;
- int fp;
- public:
- Game(){
- hard = false;
- gamemod = 'p';
- fp = 1; // fist player starts
- }
- void start(){
- if(hard){
- cout << "123";
- }
- }
- void endg(){
- }
- void check_state(){
- }
- void ch_gamemod(){
- cout << "player vs computer (p/c)?\n";
- int c;
- cin >> c;
- gamemod = c;
- }
- void who_first(){
- cout << "who first?(1/2) \n";
- int x;
- cin >> x;
- if(x != 1 and x != 2){
- cout << "error. Try again\n";
- who_first();
- }
- }
- void chech_coords(){
- cout << "enter 2 coords:\n";
- int x, y;
- cin >> x >> y;
- x--, y--;
- ComputerPlayer::Board::go_check(x, y);
- }
- };
- void solve(){
- // vector<vector<int>> a(3, vector<int> (3, 0));
- // 0 - non field
- // 1 - x
- // -1 - 0
- Board test;
- test.print();
- }
- //vector<int> b()
- int main(){
- // solve();
- int n = 1;
- // cin >> n;
- loop(i, 0, n){
- // cout << i+1 << "---\n";
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment