I'm Working on A Game Called Super Tic Tac Toe Haven't Programmed In A While Really Need Some Help/Ideas Here Are The Requirements For The Game Below:
1. The Program Will Allow Up to 5 Players Capture First And Last Names 1 Player At a Time Then Using First Name Afterwards.
2. The First Players Piece is "a" second is "b" and so on throughout the entire game.
3. The Players can choose the board (up to 10 by 15) for each game. Each game can have a different size.
4. Starts with player "a". Subsequent game starts with the winner of the previous and follows with players in the round robin sequence "a"..."e". If it ends in a draw the next game starts with the most recent winner.
5. Move is specified as row character (A...J) followed by column number (1...15) i.e. D5, J11
6. Must Redraw board after each move.
Below Is the Code I Have So Far It's Due In A Little Over A Week. Once Again Any Suggestion/Help/Ideas Will Be Helpful. Thanks.
Code:
#include <iostream>
#include <string>
using namespace std;
void displayBoard();
void clear();
void stat();
void GetName(string&, string&);
bool checkWin();
void move(bool):
bool isLegal(int);
char board[9] = {'1','2','3','4','5','6','7','8','9'};
string FirstPlName, SecondPlName;
int main()
{
bool player = false;
char H;
string FirstName;
string SecondName;
GetNames(FirstName, SecondName);
displayBoard(;
while(!checkWin())
{
if(player == true)
player = false;
else
player = true;
move(player);
}
if(player == true)
cout << FirstPlName << "Wins" << endl;
else
cout << SecondPlName << "Wins" << endl;
cout << " Would you like to play again? Y or N" << endl;
cin >> H;
if (H='y')
{
clear();
bool player = false;
displayBoard();
while(!checkWin());
}
else
if(H='n')
{
cout << endl << " Thank You for playing";
}
void displayBoard()
{
system("cls");
cout << "\n -------------" << endl
<< "|" << board[0] << "|" << board[1]<< "|" << board[2] << "|" << endl
<< " ---------------" << endl
<< "|" << board[3] << "|" << board[4]<< "|" << board[5] << "|" << endl
<< " ---------------" << endl
<< "|" << board[6] << "|" << board[7]<< "|" << board[8] << "|" << endl
<< " ---------------" << endl;
}
bool checkWin()
{
if(board[0] == board[1] && board[2] == board[0] )
return true;
else if (board[3] == board[4] && board[5] == board[3])
return true;
else if (board[6] == board[7] && board[8] == board[6])
return true;
else if (board[0] == board[3] && board[6] == board[0])
return true;
else if (board[1] == board[4] && board[7] == board[1])
return true;
else if (board[2] == board[5] && board[8] == board[2])
return true;
else if (board[0] == board[4] && board[8] == board[0])
return true;
else if (board[2] == board[4] && board[6] == board[2])
return true;
else
return false;
}
void move(bool who)
{
int spot;
if (who == true)
cout << "\nEnter your mmove " <<FirstPlName <<"; ";
else
cout << "\nEnter your mmove " <<SecondPlName <<"; ";
cin >> spot;
if(isLegal(spot))
{
if (who == true)
board[spot-1] = 'x';
else
board[spot-1] = 'o';
}
else
move(who);
displayBoard();
}
bool isLegal(int spot)
{
if(board[spot-1] == 'X' || board[spot-1] == 'O')
return false;
else
return true;
}