#include <cmath>
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
bool InitializeBoard(int** connectNBoard, int numRowsInBoard );
bool MakeMove(int** connectNBoard, int numRowsInBoard, int player, int columnChosen);
bool DisplayBoard( int** connectNBoard, int numRowsInBoard);
bool CheckWinner( int** connectNBoard, int numRowsInBoard, int numConnect, int columnChosen, int player);
int main()
{
int numRows, numToConnect, maxMove, counter;
bool check, check2;
cout <<"Please enter size of the board between 8~25";
cin >>numRows;
if(numRows<8 || numRows>25)
{
cout <<"You have entered a wrong value. Please enter the value again";
cin >>numRows;
}
cout <<"Please enter a value for the player to win the game (numbers to connect) between 4 <= numToConnect <= numRows - 4 ";
cin >>numToConnect;
cout <<endl;
if(numToConnect <4 || numToConnect> (numRows-4))
{
cout <<"You have entered a wrong value. Please enter the value again";
cin >>numToConnect;
}
int **myConnectNBoard;
myConnectNBoard = new int*[numRows];
for (int i=0; i<numRows; i++)
{
myConnectNBoard[i] = new int[numRows];
}
check = InitializeBoard(myConnectNBoard, numRows);
if (check==false)
{
cout<<"Initialization was not done proerply";
return 1;
}
check2 = DisplayBoard(myConnectNBoard,numRows);
if (check==false)
{
cout<<"Diaplaying of the board was not done proerply";
return 1;
}
maxMove= numRows*numRows;
for(counter=0; counter<maxMove/2; counter++)
{
if(counter%2 ==0)
{
cout<<"Red Moves"<<endl;
}
else
{
cout<<"Black Moves"<<endl;
}
}
}
bool InitializeBoard(int** connectNBoard, int numRowsInBoard)
{
int i,j;
for(i=0; i<numRowsInBoard; i++)
{
for(j=0; j<numRowsInBoard; j++)
{
connectNBoard[i][j]=0;
}
}
return true;
}
bool DisplayBoard( int** connectNBoard, int numRowsInBoard)
{
int i,j;
cout<<" ";
for (i=0; i<numRowsInBoard; i++)
{
cout <<setw(3)<<i;
}
cout<<endl;
for(i=0; i<numRowsInBoard; i++)
{
cout<<setw(3)<<i;
for(j=0; j<numRowsInBoard; j++)
{
cout<<setw(3) <<connectNBoard[i][j];
}
cout<<endl<<endl;
}
return true;
}
bool MakeMove(int** connectNBoard, int numRowsInBoard, int player, int columnChosen)
{
cout<<"Enter the column you want to enter your piece";
cin>>columnChosen;
if(columnChosen>numRowsInBoard || connectNBoard[i][j] !=0 || columnChosen<0 || )
{
cout <<"Illegal Move";
return false;
}
I have written here so far. The currently problem that I am facing is that I have no idea how I can write the MakeMove function. I am totally stuck and can't even think of a way to insert a move and not sure how I am going to insert move alternating Black player and Red Player and I am also confused how I am going to check whether if there's already a game piece in there or not. Can anyone help me?