finished board to string
This commit is contained in:
parent
2146af2581
commit
c037ea48cc
3 changed files with 30 additions and 0 deletions
28
Board.cpp
28
Board.cpp
|
@ -114,6 +114,34 @@ void Board::displayBoard(){
|
||||||
cout<<'\n'<<endl;
|
cout<<'\n'<<endl;
|
||||||
cout<<"turn: "<<turn << "\n";
|
cout<<"turn: "<<turn << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string Board::boardToString(){
|
||||||
|
string output = "";
|
||||||
|
output += "; A B C D E F G H\n";
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
int label = 8 - i;
|
||||||
|
output += "; ";
|
||||||
|
output += label;
|
||||||
|
output += " ";
|
||||||
|
for (int j = 0; j < 8; ++j){
|
||||||
|
if (isPiece(i, j))
|
||||||
|
if (getPiece(i, j)->getType() == 'X')
|
||||||
|
output += "|X";
|
||||||
|
else
|
||||||
|
output += "|O";
|
||||||
|
else
|
||||||
|
output += "|_";
|
||||||
|
}
|
||||||
|
|
||||||
|
output += "|\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
output += "\n\nturn: ";
|
||||||
|
output += turn;
|
||||||
|
output += "\n";
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
int Board::charToIntColumn(char input){
|
int Board::charToIntColumn(char input){
|
||||||
int kolumn;
|
int kolumn;
|
||||||
|
|
1
Board.h
1
Board.h
|
@ -35,6 +35,7 @@ public:
|
||||||
bool isGameOver();
|
bool isGameOver();
|
||||||
void changeTurns();
|
void changeTurns();
|
||||||
void displayBoard();
|
void displayBoard();
|
||||||
|
string boardToString();
|
||||||
int charToIntColumn(char input);
|
int charToIntColumn(char input);
|
||||||
char intToCharColumn(int input);
|
char intToCharColumn(int input);
|
||||||
void move(string inputMove);
|
void move(string inputMove);
|
||||||
|
|
1
test.cpp
1
test.cpp
|
@ -7,6 +7,7 @@ int main()
|
||||||
{
|
{
|
||||||
//board testing
|
//board testing
|
||||||
Board b;
|
Board b;
|
||||||
|
cout << b.boardToString();
|
||||||
|
|
||||||
//engine testing
|
//engine testing
|
||||||
Engine e;
|
Engine e;
|
||||||
|
|
Reference in a new issue