Checkerboard Game Logic

im at a point where, i cant continue. im totally stuck.
i want to switch all the valid empty pieces that can move with "E" for empty.
im also having trouble with the logic of the c++
how would i change the color of @ or $

[code]
include <iostream>
#include <fstream>

using namespace std;
const int ROWS = 8;
const int COLS = 8;


void initialize(char board[][COLS]);
void display(char board[][COLS]);
void save(char board[][COLS]);
void readSaved(char board[][COLS]);

int main()
{
cout << "!CHECKER GAME! \n";
cout << "Player 1 [$] \n";
cout << "Player 2 [@] \n\n";
cout << "Multiple leaps are supported.\n";
cout << "A capital letter represents a king piece.\n";
cout << "Rows and columns are counted starting from 0, not 1.\n";
cout << "<------COLUMNS------>\n";
cout << "^\n";
cout << "|\n";
cout << "|\n";
cout << "|\n";
cout << "ROWS\n";
cout << "|\n";
cout << "|\n";
cout << "|\n";
cout << "v\n\n";
cout << "_____________________________________________________________________________________\n\n" << endl;
cout << "Press enter to begin...";
cin.get();




char board[ROWS][COLS];
initialize(board);
display(board);
board[7][0] = '$';
board[7][2] = '$';
board[7][4] = '$';
board[7][6] = '$';
board[6][1] = '$';
board[6][3] = '$';
board[6][5] = '$';
board[6][7] = '$';
board[5][0] = '$';
board[5][2] = '$';
board[5][4] = '$';
board[5][6] = '$';
save(board);
readSaved(board);
display(board);
return 0;
}
void initialize(char board[][COLS])
{
int i, j;
for (i = 0; i < ROWS; i++) //row to row
for (j = 0; j < COLS; j++) // col elem
board[i][j] = '-';
board[0][1] = '@';
board[0][3] = '@';
board[0][5] = '@';
board[0][7] = '@';
board[1][0] = '@';
board[1][2] = '@';
board[1][4] = '@';
board[1][6] = '@';
board[2][1] = '@';
board[2][3] = '@';
board[2][5] = '@';
board[2][7] = '@';

return;
}
void display(char board[][COLS])
{
int i, j;
// column labels
printf("+---+---+---+---+---+---+---+---+\n");
cout << " ";
for (i = 0; i < COLS; i++)
cout << ' ' << i << ' ';

for (i = 0; i < ROWS; i++)
{
cout << endl;
//row label
cout << i << " ";
for (j = 0; j < COLS; j++)
//don't display the -
if (board[i][j] == '-')
cout << " E ";
else
cout << ' ' << board[i][j] << ' ';
cout << endl;
}
return;
}
void save(char board[][COLS])
{
ofstream fout;
int i, j;
fout.open("gameBoard.txt");
for (i = 0; i < ROWS; i++)
{
for (j = 0; j < COLS; j++)
fout << board[i][j] << ' ';
fout << endl;
}
fout.close();
return;
}

void readSaved(char board[][COLS])
{
int i, j;
ifstream fin;
fin.open("gameBoard.txt");
for (i = 0; i < ROWS; i++)
for (j = 0; j < COLS; j++)
fin >> board[i][j];
fin.close();
return;
}
/*
void Display_fancy(int d[][COLS])
{
int rr, cc;

printf(" +---+---+---+---+---+---+---+---+\n");

for (rr = 0; rr<ROWS; ++rr)
{
printf("%d |", rr + 1);
for (cc = 0; cc<COLS; ++cc)
{
printf(" %c |", value_symbol(d[rr][cc]));
}
printf("\n");
printf(" +---+---+---+---+---+---+---+---+\n");
}

printf(" a b c d e f g h\n");
}
void swapIJKL(int d[ROWS][COLS], int i, int j, int k, int l)
{
int temp;

printf("SWAP: %d,%d to %d,%d\n", i, j, k, l);

temp = d[i][j];

d[i][j] = d[k][l];

d[k][l] = temp;


}



char value_symbol(int i)
{

switch (i)
{
case 0:
return ' ';
case 1:
return 'E';
case 2:
return '$';
case 3:
return '@';
}
return ('?');
}
*/
i know for the "E" it would be a switch statement, but i have no clue on how to go to that
Topic archived. No new replies allowed.