In C++ Create a function that checks the best immediate possible move for the ga
ID: 3840572 • Letter: I
Question
In C++
Create a function that checks the best immediate possible move for the game Othello. There are pieces already on the board. I am confused on how to check surrounding elements of the array.
int resultOfMove(int row, int col, char color){}// returns the number of color - number of other color
// when a disk of color is placed at (row, col)
int bestMove(int & row, int &col, char color){} // returns the max resultOfMove(row,col)
// when a disk of color is placed at (row, col)
The array (board) contains char 'W' and 'B' but I am not sure how to use statemeents to check if the move is legal.
I uploaded the pdf of the assignment so you get the idea.
http://docdro.id/O9kDdWL
Explanation / Answer
Please find the below-working code
************
*********
Board.h
*********
piece.h
***************
Common.h
****************
#pragma once #include "Common.h" class Piece { public: Piece(Cell, Kind); char repr() const; Cell getPosition() const; Kind getKind() const; void setKind(Kind); ~Piece(); private: Kind kind; Cell cell; };