Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USE C++ PLEASE for a tic tac toe game do the following please: a) Implement an a

ID: 3787076 • Letter: U

Question

USE C++ PLEASE

for a tic tac toe game do the following please:

a) Implement an abstract Player class with the following functionality:

Default constructor, copy constructor, destructor, assignment operator.

o Remember: This class will be inherited, so the destructor must be declared with the virtual keyword.

A way to set the symbol placed by this Player.

o This can be done as either a function or as an additional constructor with a parameter.

Determine the symbol placed by this Player.

Determine the next move for this Player. This function should take a const reference to a Board as a parameter and must be a pure virtual function.

Hint: Add a class invariant that ensures that a Player always has a valid symbol.

b) Implement a PlayerHuman class the following functionality:

Default constructor, copy constructor, destructor, assignment operator.

Determine the next move. This must be a virtual function and override the corresponding function in Player.

Detect and reject invalid user input.

c) Implement a PlayerRandom class with the following functionality:

Default constructor, copy constructor, destructor, assignment operator.

Determine the next move. This must be a virtual function and override the corresponding function in Player.

Explanation / Answer

#include<iostream>
#include<string>
#include<stdlib>


// during this example items aer represented as number values
// we are going to build them constants, in order that if at any time we would like to alter their values we will do thus here
// however can still ought to recompile

const int pawn = 100;
const int bishop = 305;
const int knight = 300;
const int rook = 500;
const int queen = 900;
const int king = 2000;

// an alternate would be to use string constants or another information kind

//now we want a board to place the items on and move around on
//the board information kind ought to match the items information kind
// the board in regular chess is usually 8x8, except for speedy legal move generator
//other programs use larger than 8x8 wherever Associate in Nursing 8x8 real board exists in an exceedingly larger array id est 12x14
// except for simplicity of understanding we are going to use the easy 8x8

int board[8][8];

// board [rank] [file];
// wherever rank = zero - seven (1 to eight on a true chess board) and file = zero - seven (a - h)

const startup[8][8] = ;

// the startup constant contains the quality beginning position of all chess games (not variants)
//each facet has eight items and eight pawns / all pawns ar on the colors individual ranks
// for black items we have a tendency to use -piecetype. (negative)

void setup (void) {
int i, j;
   for (i = 0; i < 8; i++){
       for (j = 0; j < 8; j++){
           board[i][j] = startup[i][j]; //setup beginning position
   }
       }

}

//the 2 for loops run through all the iteratins of the 8x8 array and replica the beginning position to the important board.

// next we want a operate which will show the board how either graphics or text
// during this case we are going to print to the screen a text version of the boards contents

//it is commonplace in FEN notations and different text of a chess board to specific each bit by it's 1st letter
// except the knight that uses 'N'

// the black items ar minuscule whereas the white items ar capital letter
// otherwise it's not possible to differentiate black items from white items

void printb (void)should be here so as to start mistreatment strings.
int a, b;
string piece;
for (a = seven; a > -1; a--){ // we have a tendency to should tell the ranks down from 7 to zero otherwise the board are going to be the wrong way up
cout << endl;
for (b = 0; b < 8; b++)
       if (passd.substr(0, 5) == "print") { // show the board
       printb();
       }
       if (passd.substr(0, 3) == "new") enkindle a brand new game
       setup();
       }
       if (passd.substr(0, 1) >= "a" && passd.substr(0, 1) <= "h" && passd.substr(1, 1) >= "1" && passd.substr(1, 1) <= "8" && passd.substr(2, 1) >= "a" && passd.substr(2, 1) <= "h" && passd.substr(3, 1) >= "1" && passd.substr(3, 1) <= "8") certain each squares ar on the chess board once capital punishment //a move
       // execute move
       // then show new board position

       int a, b, c, d;


       a = passd[0] - 'a';
       b = passd[1] - '1';
       c = passd[2] - 'a';
       d = passd[3] - '1';

//executes the move if its on the board!
       board[d][c] = board[b][a];
       board[b][a] = 0;

       printb(); //prints bent the screen the updated position when moving the items
       }
       }
}